Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef TextInputStreamH
00033 #define TextInputStreamH
00034
00035 #include <zeusbase/System/FilterInputStream.h>
00036
00037 BEGIN_NAMESPACE_Zeus
00038
00039
00040
00049
00050 zeusbase_class TTextInputStream : public TFilterInputStream
00051 {
00052 public:
00053
00056
00057 enum EEncodingType
00058 {
00059 etAutoDetect = 0,
00060 etISO_8859_1 = 1,
00061 etUTF_16 = 2
00062 };
00063
00064
00067
00068 enum EEndianType
00069 {
00070 etLittleEndian = 0,
00071 etBigEndian = 1
00072 };
00073
00074 TTextInputStream(IInputStream& rParentStream,
00075 EEncodingType eEncoding = etAutoDetect,
00076 EEndianType eEndian = etLittleEndian);
00077 TTextInputStream(const IString& rFileName,
00078 EEncodingType eEncoding = etAutoDetect,
00079 EEndianType eEndian = etLittleEndian);
00080
00081 Retval readLine(IString& rLine) const;
00082 Retval readText(IString& rText) const;
00083 Retval readText(IString& rText, Int iBlockSize, Int iExpectedStreamSize) const;
00084 EEndianType getEndianType() const;
00085 EEncodingType getEncodingType() const;
00086
00087 protected:
00088 virtual ~TTextInputStream();
00089
00090
00091 virtual Int8 MQUALIFIER readInt8(BOOL_ERRORRETVAL(pError)) const;
00092 virtual Int16 MQUALIFIER readInt16(BOOL_ERRORRETVAL(pError)) const;
00093 virtual Int32 MQUALIFIER readInt32(BOOL_ERRORRETVAL(pError)) const;
00094 virtual Int64 MQUALIFIER readInt64(BOOL_ERRORRETVAL(pError)) const;
00095 virtual Uint16 MQUALIFIER readUint16(BOOL_ERRORRETVAL(pError)) const;
00096 virtual Uint32 MQUALIFIER readUint32(BOOL_ERRORRETVAL(pError)) const;
00097 virtual Uint64 MQUALIFIER readUint64(BOOL_ERRORRETVAL(pError)) const;
00098 virtual Float32 MQUALIFIER readFloat32(BOOL_ERRORRETVAL(pError)) const;
00099 virtual Float64 MQUALIFIER readFloat64(BOOL_ERRORRETVAL(pError)) const;
00100 virtual bool MQUALIFIER readBool(BOOL_ERRORRETVAL(pError)) const;
00101 virtual Retval MQUALIFIER readArray(IByteArray& rData) const;
00102 virtual Retval MQUALIFIER readString(IString& rData) const;
00103 virtual Retval MQUALIFIER read(char* pBuffer, Int iBufferSize, Int& rValidSize) const;
00104 virtual Int MQUALIFIER readItem() const;
00105
00106 private:
00107
00108 EEncodingType m_eEncoding;
00110 EEndianType m_eEndian;
00111
00112 void autoDetectEncoding();
00113 void strReadUTF16Line(IString& rData) const;
00114 void strReadISO8859_1Line(IString& rData) const;
00115
00116 };
00117
00118
00119
00122
00123 inline TTextInputStream::EEndianType TTextInputStream::getEndianType() const
00124 {
00125 return m_eEndian;
00126 }
00127
00128
00131
00132 inline TTextInputStream::EEncodingType TTextInputStream::getEncodingType() const
00133 {
00134 return m_eEncoding;
00135 }
00136
00137
00143
00144 inline Retval TTextInputStream::readText(IString& rText) const
00145 {
00146 return readText(rText, 4096, 100000);
00147 }
00148
00149
00152
00153 inline Int8 MQUALIFIER TTextInputStream::readInt8(bool* pError) const
00154 {
00155 if (pError != NULL)
00156 {
00157 *pError = true;
00158 }
00159 return 0;
00160 }
00161
00162
00165
00166 inline Int16 MQUALIFIER TTextInputStream::readInt16(bool* pError) const
00167 {
00168 if (pError != NULL)
00169 {
00170 *pError = true;
00171 }
00172 return 0;
00173 }
00174
00175
00178
00179 inline Int32 MQUALIFIER TTextInputStream::readInt32(bool* pError) const
00180 {
00181 if (pError != NULL)
00182 {
00183 *pError = true;
00184 }
00185 return 0;
00186 }
00187
00188
00191
00192 inline Int64 MQUALIFIER TTextInputStream::readInt64(bool* pError) const
00193 {
00194 if (pError != NULL)
00195 {
00196 *pError = true;
00197 }
00198 return 0;
00199 }
00200
00201
00204
00205 inline Uint16 MQUALIFIER TTextInputStream::readUint16(bool* pError) const
00206 {
00207 if (pError != NULL)
00208 {
00209 *pError = true;
00210 }
00211 return 0;
00212 }
00213
00214
00217
00218 inline Uint32 MQUALIFIER TTextInputStream::readUint32(bool* pError) const
00219 {
00220 if (pError != NULL)
00221 {
00222 *pError = true;
00223 }
00224 return 0;
00225 }
00226
00227
00230
00231 inline Uint64 MQUALIFIER TTextInputStream::readUint64(bool* pError) const
00232 {
00233 if (pError != NULL)
00234 {
00235 *pError = true;
00236 }
00237 return 0;
00238 }
00239
00240
00243
00244 inline Float32 MQUALIFIER TTextInputStream::readFloat32(bool* pError) const
00245 {
00246 if (pError != NULL)
00247 {
00248 *pError = true;
00249 }
00250 return 0;
00251 }
00252
00253
00256
00257 inline Float64 MQUALIFIER TTextInputStream::readFloat64(bool* pError) const
00258 {
00259 if (pError != NULL)
00260 {
00261 *pError = true;
00262 }
00263 return 0;
00264 }
00265
00266
00269
00270 inline bool MQUALIFIER TTextInputStream::readBool(bool* pError) const
00271 {
00272 if (pError != NULL)
00273 {
00274 *pError = true;
00275 }
00276 return false;
00277 }
00278
00279
00282
00283 inline Retval MQUALIFIER TTextInputStream::readArray(IByteArray& ) const
00284 {
00285 return RET_REQUEST_FAILED;
00286 }
00287
00288
00291
00292 inline Retval MQUALIFIER TTextInputStream::readString(IString& ) const
00293 {
00294 return RET_REQUEST_FAILED;
00295 }
00296
00297
00300
00301 inline Retval MQUALIFIER TTextInputStream::read(char* pBuffer, Int iBufferSize, Int& rValidSize) const
00302 {
00303 return TFilterInputStream::read(pBuffer, iBufferSize, rValidSize);
00304 }
00305
00306
00309
00310 inline Int MQUALIFIER TTextInputStream::readItem() const
00311 {
00312 return TFilterInputStream::readItem();
00313 }
00314
00315
00316 END_NAMESPACE_Zeus
00317
00318
00319 #endif