00001
00002 #ifndef XSIL_STREAM_HH
00003 #define XSIL_STREAM_HH
00004
00005 #include "xsil/xobj.hh"
00006 #include <string>
00007 #ifdef __GNU_STDC_OLD
00008 #include <gnusstream.h>
00009 #else
00010 #include <sstream>
00011 #endif
00012
00013
00014
00015
00016 #define USEILWDCHAR
00017
00018 namespace xsil {
00019
00025 struct UCVec {
00028 UCVec(void) {}
00029
00033 UCVec(const int* pN, const unsigned char* pD);
00034
00038 UCVec(const int* pN, const char* pD);
00039
00041 const int* pNBytes;
00042
00044 const unsigned char* pData;
00045 };
00046
00047 inline
00048 UCVec::UCVec(const int* pN, const unsigned char* pD)
00049 : pNBytes(pN), pData(pD)
00050 {}
00051
00052 inline
00053 UCVec::UCVec(const int* pN, const char* pD)
00054 : pNBytes(pN), pData(reinterpret_cast<const unsigned char*>(pD))
00055 {}
00056
00064 class Stream : public xobj {
00065 public:
00066
00070 Stream(void);
00071
00075 Stream(const char* Name, const char* Type=0, const char* Data=0);
00076
00079 Stream(const Stream& x);
00080
00083 ~Stream();
00084
00087 Stream& operator=(const Stream& x);
00088
00091 void Spew(Xwriter& xout) const;
00092
00102 void append(const std::string& s);
00103
00108 Stream* Clone(void) const;
00109
00113 bool empty(void) const;
00114
00118 const char* getDelimit(void) const;
00119
00123 const char* getEncode(void) const;
00124
00127 const char* getObjType(void) const;
00128
00133 void delimit(char Delim);
00134
00139 void Add(float x);
00140
00146 void Add(const std::string& x, bool escsp=false);
00147
00152 void Add(int x);
00153
00158 void Add(double x);
00159
00164 void Add(const UCVec& x);
00165
00169 void Clear(void);
00170
00177 void Fill(int N, const float* x, int perLine=0);
00178
00185 void Fill(int N, const double* x, int perLine=0);
00186
00193 void Fill(int N, const int* x, int perLine=0);
00194
00201 void Fill(int N, const std::string x[], int perLine=0);
00202
00213 bool decode64Data(void* data, int dLen, int N);
00214
00220 void encode64Data(const char* data, int N);
00221
00224 void open(void);
00225
00229 void lineBreak(void);
00230
00237 bool read(double data[], int N);
00238
00245 bool read(float data[], int N);
00246
00253 bool read(int data[], int N);
00254
00261 bool read(std::string data[], int N);
00262
00263
00268 void setRemote(const char* File);
00269
00274 void setData(const char* Data);
00275
00280 void setEncode(const char* Code);
00281
00286 void setSize(int Size);
00287
00288 private:
00291 void estLength(std::string::size_type len);
00292
00299 void estDone(double frac);
00300
00301 private:
00302 std::string mData;
00303 std::string mRemote;
00304 int mLineSz;
00305 int mMaxSz;
00306 std::string mDelimit;
00307 bool mEndLine;
00308 std::string mEncoding;
00309 std::istream* mInput;
00310 };
00311
00312 }
00313
00314
00315 inline bool
00316 xsil::Stream::empty(void) const {
00317 return mData.empty();
00318 }
00319
00320
00321 inline const char*
00322 xsil::Stream::getEncode(void) const {
00323 return mEncoding.c_str();
00324 }
00325
00326
00327 inline const char*
00328 xsil::Stream::getDelimit(void) const {
00329 return mDelimit.c_str();
00330 }
00331
00332 #endif // !defined(XSIL_STREAM_HH)
00333
00334