34 #include <suplibxx/str.h> 36 #include <rdbxx/RDBErr.h> 37 #include <rdbxx/RDBComment.h> 38 #include <rdbxx/RDBColumnTmplt.h> 46 friend istream& operator>>( istream& is,
RDB& rdb );
49 friend ostream& operator<<( ostream& os,
RDB& rdb );
55 enum Status { REOF=0x00, REOL=0x01, REOG=0x02, RBOG=0x04 };
61 RDB(
const string& name=
"", ios::openmode mode=ios::in );
64 RDB( istream* isptr );
66 RDB( ostream* osptr );
75 void open(
const string& name, ios::openmode mode=ios::in );
78 void open( istream* isptr );
80 void open( ostream* osptr );
82 void open(
const RDB& rdb );
96 bool autoIdx(
void )
const;
99 void autoIdx(
const bool on );
101 void advanceIdx(
void );
106 void setGroup(
const string& name,
bool group=
true );
109 void setGroup(
const int idx,
bool group=
true );
111 bool getGroup(
const string& name );
113 bool getGroup(
const int idx );
115 bool newGroup(
void );
120 void setComment(
const string& comm,
const int idx=-1 );
123 void setComment(
RDBComment& comm,
const int idx=-1 );
125 void setComment(
RDBComment& comm,
const string& name,
const size_t idx=0 );
127 void setComment(
const RDB& rdb );
132 RDBComment& getComment(
const string& name,
const size_t idx=0 );
137 void setColumn(
const string& name,
const string& def,
const int idx=-1 );
140 void setColumn(
RDBColumn* col,
const int idx=-1 );
142 void setColumn(
RDBColumn* col,
const string& name,
const size_t idx=0 );
144 void setColumn(
const RDB& rdb );
147 RDBColumn* getColumn(
const size_t idx );
149 RDBColumn* getColumn(
const string& name,
const size_t idx=0 );
154 void setName(
const size_t idx,
const string& name );
157 void setDef(
const size_t idx,
const string& def );
159 void setWidth(
const size_t idx,
const long width );
165 void setDesc(
const size_t idx,
const string& desc );
167 void mapData(
const size_t idx,
double data[],
const size_t nelems=1 );
169 void mapData(
const size_t idx,
long data[],
const size_t nelems=1 );
171 void mapData(
const size_t idx,
string data[],
const size_t nelems=1 );
173 void setData(
const size_t idx,
const double data );
175 void setData(
const size_t idx,
const long data );
177 void setData(
const size_t idx,
const string& data );
180 void getName(
const size_t idx,
string& name )
const;
182 void getDef(
const size_t idx,
string& def );
184 void getWidth(
const size_t idx,
long& width )
const;
190 void getDesc(
const size_t idx,
string& desc )
const;
192 void getData(
const size_t idx,
double& data );
194 void getData(
const size_t idx,
long& data );
196 void getData(
const size_t idx,
string& data );
199 string getName(
const size_t idx )
const;
201 string getDef(
const size_t idx );
203 long getWidth(
const size_t idx )
const;
209 string getDesc(
const size_t idx )
const;
211 double getDataDouble(
const size_t idx );
213 long getDataLong(
const size_t idx );
215 string getDataString(
const size_t idx );
220 void setName(
const string& name,
const string& newname );
223 void setDef(
const string& name,
const string& def );
225 void setWidth(
const string& name,
const long width );
231 void setDesc(
const string& name,
const string& desc );
233 void mapData(
const string& name,
double data[],
const size_t nelems=1 );
235 void mapData(
const string& name,
long data[],
const size_t nelems=1 );
237 void mapData(
const string& name,
string data[],
const size_t nelems=1 );
239 void setData(
const string& name,
const double data );
241 void setData(
const string& name,
const long data );
243 void setData(
const string& name,
const string& data );
246 void getName(
const string& name,
string& namefound )
const;
248 void getDef(
const string& name,
string& def );
250 void getWidth(
const string& name,
long& width )
const;
256 void getDesc(
const string& name,
string& desc )
const;
258 void getData(
const string& name,
double& data );
260 void getData(
const string& name,
long& data );
262 void getData(
const string& name,
string& data );
265 string getName(
const string& name )
const;
267 string getDef(
const string& name );
269 long getWidth(
const string& name )
const;
275 string getDesc(
const string& name )
const;
277 double getDataDouble(
const string& name );
279 long getDataLong(
const string& name );
281 string getDataString(
const string& name );
286 size_t nComments(
void )
const;
289 size_t nColumns(
void )
const;
291 size_t nRows(
void );
296 void parseHeader(
void );
298 vector<string> parseLine(
const string& line )
const;
300 size_t parseLine(
bool& newgroup );
size_t _ncols
Number of columns.
string _filename
Name of RDB file.
Just
Acceptable column justifications.
size_t _nrows
Number of rows.
bool _knowrows
Indicates if associated file must be scanned to determine number of rows.
bool _myosptr
Indicates if RDB object is responsible for deallocating the ostream.
bool _myisptr
Indicates if RDB object is responsible for deallocating the istream.
Status
Acceptable column justifications.
bool _firstread
Indicates if this is the first call to RDB::read.
bool _writehdr
Indicates if the header has been output.
RDBLongColumn _nrcol
Hidden column, containing row number.
RDBColumn ** _cols
Array of RDBColumns.
ostream * _osptr
Ostream attached to data file.
RDBComment * _comms
Array of RDBComments.
istream * _isptr
Istream attached to data file.
size_t _rewindto
Position of beginning of first row of data.
Provides interface for manipulating RDB tables.
size_t _ncomms
Number of comments.
Type
Acceptable column types.
string _line
Line from RDB table.
ios::openmode _mode
Open mode of the associated stream.
bool _autoidx
Indicates if RDBColumn data elements should be advanced.
bool _lastread
Indicates if this is the last call to RDB::read.
long _rownum
Current table row number.
long _frownum
Current file row number.
Provides interface for general column related methods.
bool * _mycols
Indicates if RDB object is responsible for deallocating given RDBColumn.