00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 INLINE StreamWrapperBase::
00022 StreamWrapperBase() {
00023 #ifdef SIMPLE_THREADS
00024 _lock_flag = false;
00025 #endif
00026 }
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 INLINE void StreamWrapperBase::
00047 acquire() {
00048 _lock.acquire();
00049 #ifdef SIMPLE_THREADS
00050 while (_lock_flag) {
00051 thread_yield();
00052 }
00053 _lock_flag = true;
00054 #endif
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064 INLINE void StreamWrapperBase::
00065 release() {
00066 #ifdef SIMPLE_THREADS
00067 assert(_lock_flag);
00068 _lock_flag = false;
00069 #endif
00070 _lock.release();
00071 }
00072
00073
00074
00075
00076
00077
00078 INLINE IStreamWrapper::
00079 IStreamWrapper(istream *stream, bool owns_pointer) :
00080 _istream(stream),
00081 _owns_pointer(owns_pointer)
00082 {
00083 }
00084
00085
00086
00087
00088
00089
00090 INLINE IStreamWrapper::
00091 IStreamWrapper(istream &stream) :
00092 _istream(&stream),
00093 _owns_pointer(false)
00094 {
00095 }
00096
00097
00098
00099
00100
00101
00102 INLINE istream *IStreamWrapper::
00103 get_istream() const {
00104 return _istream;
00105 }
00106
00107
00108
00109
00110
00111
00112 INLINE int IStreamWrapper::
00113 get() {
00114 int result;
00115 acquire();
00116 result = _istream->get();
00117 release();
00118 return result;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127 INLINE OStreamWrapper::
00128 OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack) :
00129 _ostream(stream),
00130 _owns_pointer(owns_pointer),
00131 _stringstream_hack(stringstream_hack)
00132 {
00133 }
00134
00135
00136
00137
00138
00139
00140 INLINE OStreamWrapper::
00141 OStreamWrapper(ostream &stream) :
00142 _ostream(&stream),
00143 _owns_pointer(false),
00144 _stringstream_hack(false)
00145 {
00146 }
00147
00148
00149
00150
00151
00152
00153 INLINE ostream *OStreamWrapper::
00154 get_ostream() const {
00155 return _ostream;
00156 }
00157
00158
00159
00160
00161
00162
00163
00164 INLINE bool OStreamWrapper::
00165 put(char c) {
00166 bool success;
00167 acquire();
00168 _ostream->put(c);
00169 success = !_ostream->bad();
00170 release();
00171 return success;
00172 }
00173
00174
00175
00176
00177
00178
00179 INLINE StreamWrapper::
00180 StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack) :
00181 IStreamWrapper(stream, false),
00182 OStreamWrapper(stream, false, stringstream_hack),
00183 _iostream(stream),
00184 _owns_pointer(owns_pointer)
00185 {
00186 }
00187
00188
00189
00190
00191
00192
00193 INLINE StreamWrapper::
00194 StreamWrapper(iostream &stream) :
00195 IStreamWrapper(&stream, false),
00196 OStreamWrapper(&stream, false),
00197 _iostream(&stream),
00198 _owns_pointer(false)
00199 {
00200 }
00201
00202
00203
00204
00205
00206
00207 INLINE iostream *StreamWrapper::
00208 get_iostream() const {
00209 return _iostream;
00210 }