00001
00002 #ifndef RecordOutputStream_Binary_h
00003 #define RecordOutputStream_Binary_h
00004
00005 #include <fstream>
00006 #include "RecordInputStream.h"
00007 #include "RecordOutputStream.h"
00008
00009 namespace BIE {
00010
00011
00013 class RecordInputStream_Binary : public RecordInputStream {
00014
00015 public:
00016
00019 RecordInputStream_Binary (RecordType * type, string filename);
00020
00021
00024 RecordInputStream_Binary(RecordType * type, istream * binarystream);
00025
00026
00029 RecordInputStream_Binary (string filename);
00030
00031
00034 RecordInputStream_Binary(istream * binarystream);
00035
00037 ~RecordInputStream_Binary();
00038
00039
00040 bool nextRecord();
00041
00042
00044 bool eos();
00045
00046
00047
00048 bool error();
00049
00050 private:
00051
00052 RecordType * readMetaData();
00053
00054
00055 void initialize();
00056
00057 void setArrayFieldValue(int fieldindex, BasicType *type, int length);
00058
00060
00061 void readStream(unsigned char * buffer, int bytes);
00062 int readInt();
00063 double readReal();
00064 bool readBool();
00065 const char * readString();
00067
00069 istream * risb_binarystream;
00070
00072 bool risb_streamismine;
00073
00076 char * risb_stringbuffer;
00077
00079 int risb_stringbuffersize;
00080
00082 bool risb_eof;
00083
00085 bool risb_error;
00086 };
00087
00088
00091 class RecordOutputStream_Binary : public RecordOutputStream{
00092
00093 public:
00094
00099 RecordOutputStream_Binary
00100 (RecordOutputStream * stream, string filename, bool writemetadata);
00101
00102
00107 RecordOutputStream_Binary
00108 (RecordOutputStream * stream, ostream * binarystream, bool writemetadata);
00109
00111 ~RecordOutputStream_Binary();
00112
00114 virtual void pushRecord();
00115
00116 private:
00117
00118 void initialize (RecordOutputStream * stream, bool writemetadata);
00119
00123
00124 void writeInt(int value);
00125 void writeReal(double value);
00126 void writeBool(bool value);
00127 void writeString(string value);
00129
00130
00131 void writeMetaData();
00132
00133
00134 bool rosb_streamismine;
00135
00136
00137 ostream * rosb_outputstream;
00138 };
00139 }
00140
00141 #endif