00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef STREAMWRAPPER_H
00016 #define STREAMWRAPPER_H
00017
00018 #include "dtoolbase.h"
00019 #include "mutexImpl.h"
00020
00021
00022
00023
00024
00025
00026
00027 class EXPCL_DTOOLCONFIG StreamWrapperBase {
00028 protected:
00029 INLINE StreamWrapperBase();
00030
00031 PUBLISHED:
00032 INLINE void acquire();
00033 INLINE void release();
00034
00035 private:
00036 MutexImpl _lock;
00037 #ifdef SIMPLE_THREADS
00038
00039
00040
00041
00042 bool _lock_flag;
00043 #endif
00044 };
00045
00046
00047
00048
00049
00050
00051
00052
00053 class EXPCL_DTOOLCONFIG IStreamWrapper : virtual public StreamWrapperBase {
00054 public:
00055 INLINE IStreamWrapper(istream *stream, bool owns_pointer);
00056 PUBLISHED:
00057 INLINE IStreamWrapper(istream &stream);
00058 ~IStreamWrapper();
00059
00060 INLINE istream *get_istream() const;
00061
00062 public:
00063 void read(char *buffer, streamsize num_bytes);
00064 void read(char *buffer, streamsize num_bytes, streamsize &read_bytes);
00065 void read(char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof);
00066 void seek_read(streamsize pos, char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof);
00067 INLINE int get();
00068 streamsize seek_gpos_eof();
00069
00070 private:
00071 istream *_istream;
00072 bool _owns_pointer;
00073 };
00074
00075
00076
00077
00078
00079
00080
00081 class EXPCL_DTOOLCONFIG OStreamWrapper : virtual public StreamWrapperBase {
00082 public:
00083 INLINE OStreamWrapper(ostream *stream, bool owns_pointer);
00084 PUBLISHED:
00085 INLINE OStreamWrapper(ostream &stream);
00086 ~OStreamWrapper();
00087
00088 INLINE ostream *get_ostream() const;
00089
00090 public:
00091 void write(const char *buffer, streamsize num_bytes);
00092 void write(const char *buffer, streamsize num_bytes, bool &fail);
00093 void seek_write(streamsize pos, const char *buffer, streamsize num_bytes, bool &fail);
00094 INLINE bool put(char c);
00095
00096 private:
00097 ostream *_ostream;
00098 bool _owns_pointer;
00099 };
00100
00101
00102
00103
00104
00105
00106 class EXPCL_DTOOLCONFIG StreamWrapper : public IStreamWrapper, public OStreamWrapper {
00107 public:
00108 INLINE StreamWrapper(iostream *stream, bool owns_pointer);
00109 PUBLISHED:
00110 INLINE StreamWrapper(iostream &stream);
00111 ~StreamWrapper();
00112
00113 INLINE iostream *get_iostream() const;
00114
00115 private:
00116 iostream *_iostream;
00117 bool _owns_pointer;
00118 };
00119
00120 #include "streamWrapper.I"
00121
00122 #endif