#include <RDB.h>
Public Types | |
Enumerations for read/write/group return status. | |
enum | Status { REOF = 0x00, REOL = 0x01, REOG = 0x02, RBOG = 0x04 } |
Acceptable column justifications. More... | |
Public Member Functions | |
Constructing and destructing and initializing RDB objects. | |
RDB (const string &name="", ios::openmode mode=ios::in) throw ( RDBErr ) | |
Attaches RDB object to a file. | |
RDB (istream *isptr) throw ( RDBErr ) | |
Attaches RDB object to an istream. | |
RDB (ostream *osptr) throw ( RDBErr ) | |
Attaches RDB object to an ostream. | |
RDB (const RDB &rdb) throw ( RDBErr ) | |
Copies RDB object. | |
~RDB (void) | |
Deletes resources allocated by the RDB object. | |
I/O related operations. | |
void | open (const string &name, ios::openmode mode=ios::in) throw ( RDBErr ) |
Attaches RDB object to a file. | |
void | open (istream *isptr) throw ( RDBErr ) |
Attaches RDB object to an istream. | |
void | open (ostream *osptr) throw ( RDBErr ) |
Attaches RDB object to an ostream. | |
void | open (const RDB &rdb) throw ( RDBErr ) |
Copies RDB object. | |
void | close (void) |
Closes the stream attached to RDB object. | |
int | read (void) throw ( RDBErr ) |
Read a line of data from the istream. | |
bool | write (void) throw ( RDBErr ) |
Write a line of data to the ostream. | |
bool | rewind (void) throw ( RDBErr ) |
Rewind the stream to the beginning of the first row of data. | |
Auto-indexing related methods. | |
bool | autoIdx (void) const |
Indicates if auto-indexing is activated. | |
void | autoIdx (const bool on) |
Activates/deactivates auto-indexing. | |
void | advanceIdx (void) |
Increments the indices in the RDBColumn data elements. | |
Column group manipulation (break columns) | |
void | setGroup (const string &name, bool group=true) throw ( RDBErr ) |
Turn on/off group status for the named column. | |
void | setGroup (const int idx, bool group=true) throw ( RDBErr ) |
Turn on/off group status for the indexed column. | |
bool | getGroup (const string &name) throw ( RDBErr ) |
Returns group status, true if its a new group, for the named column. | |
bool | getGroup (const int idx) throw ( RDBErr ) |
Returns group status, true if its a new group, for the indexed column. | |
bool | newGroup (void) |
Checks if any column indicates a new group. | |
Comment accessors. | |
void | setComment (const string &comm, const int idx=-1) |
Add RDBComment in header of RDB object. | |
void | setComment (RDBComment &comm, const int idx=-1) |
Add or replace RDBComment in header of RDB object. | |
void | setComment (RDBComment &comm, const string &name, const size_t idx=0) |
Add or replace RDBComment in header of RDB object. | |
void | setComment (const RDB &rdb) |
Copy all comments from an existing RDB object. | |
RDBComment & | getComment (const size_t idx) throw ( RDBErr ) |
Return RDBComment at given index. | |
RDBComment & | getComment (const string &name, const size_t idx=0) throw ( RDBErr ) |
Return RDBComment with given keyword. | |
Column accessors. | |
void | setColumn (const string &name, const string &def, const int idx=-1) |
Add an RDBColumn in RDB object. | |
void | setColumn (RDBColumn *col, const int idx=-1) |
Add or replace RDBColumn in RDB object. | |
void | setColumn (RDBColumn *col, const string &name, const size_t idx=0) |
Add of replace RDBColumn in RDB object. | |
void | setColumn (const RDB &rdb) |
Copy all columns from an existing RDB object. | |
RDBColumn * | getColumn (const size_t idx) throw ( RDBErr ) |
Return pointer to RDBColumn at given index. | |
RDBColumn * | getColumn (const string &name, const size_t idx=0) throw ( RDBErr ) |
Return pointer to RDBColumn with given name. | |
Column index based accessors. | |
void | setName (const size_t idx, const string &name) throw ( RDBErr ) |
Modify the name of the RDBColumn at idx. | |
void | setDef (const size_t idx, const string &def) throw ( RDBErr ) |
Modify the definition of the RDBColumn at idx. | |
void | setWidth (const size_t idx, const long width) throw ( RDBErr ) |
Modify the width of the RDBColumn at idx. | |
void | setType (const size_t idx, const RDBColumn::Type type) throw ( RDBErr ) |
Modify the type of the RDBColumn at idx. | |
void | setJust (const size_t idx, const RDBColumn::Just just) throw ( RDBErr ) |
Modify the justification of the RDBColumn at idx. | |
void | setDesc (const size_t idx, const string &desc) throw ( RDBErr ) |
Modify the description of the RDBColumn at idx. | |
void | mapData (const size_t idx, double data[], const size_t nelems=1) throw ( RDBErr ) |
Map RDBColumn data to user-supplied memory. | |
void | mapData (const size_t idx, long data[], const size_t nelems=1) throw ( RDBErr ) |
Map RDBColumn data to user-supplied memory. | |
void | mapData (const size_t idx, string data[], const size_t nelems=1) throw ( RDBErr ) |
Map RDBColumn data to user-supplied memory. | |
void | setData (const size_t idx, const double data) throw ( RDBErr ) |
Sets the data value of RDBColumn, converting as necessary. | |
void | setData (const size_t idx, const long data) throw ( RDBErr ) |
Sets the data value of RDBColumn, converting as necessary. | |
void | setData (const size_t idx, const string &data) throw ( RDBErr ) |
Sets the data value of RDBColumn, converting as necessary. | |
void | getName (const size_t idx, string &name) const throw ( RDBErr ) |
Return the name of the RDBColumn at idx. | |
void | getDef (const size_t idx, string &def) throw ( RDBErr ) |
Return the definition of the RDBColumn at idx. | |
void | getWidth (const size_t idx, long &width) const throw ( RDBErr ) |
Return the width of the RDBColumn at idx. | |
void | getType (const size_t idx, RDBColumn::Type &type) const throw ( RDBErr ) |
Return the type of the RDBColumn at idx. | |
void | getJust (const size_t idx, RDBColumn::Just &just) const throw ( RDBErr ) |
Return the just of the RDBColumn at idx. | |
void | getDesc (const size_t idx, string &desc) const throw ( RDBErr ) |
Return the description of the RDBColumn at idx. | |
void | getData (const size_t idx, double &data) throw ( RDBErr ) |
Return the data of the RDBColumn at idx, converting if necessary. | |
void | getData (const size_t idx, long &data) throw ( RDBErr ) |
Return the data of the RDBColumn at idx, converting if necessary. | |
void | getData (const size_t idx, string &data) throw ( RDBErr ) |
Return the data of the RDBColumn at idx, converting if necessary. | |
string | getName (const size_t idx) const throw ( RDBErr ) |
Return the name of the RDBColumn at idx. | |
string | getDef (const size_t idx) throw ( RDBErr ) |
Return the definition of the RDBColumn at idx. | |
long | getWidth (const size_t idx) const throw ( RDBErr ) |
Return the width of the RDBColumn at idx. | |
RDBColumn::Type | getType (const size_t idx) const throw ( RDBErr ) |
Return the type of the RDBColumn at idx. | |
RDBColumn::Just | getJust (const size_t idx) const throw ( RDBErr ) |
Return the justification of the RDBColumn at idx. | |
string | getDesc (const size_t idx) const throw ( RDBErr ) |
Return the description of the RDBColumn at idx. | |
double | getDataDouble (const size_t idx) throw ( RDBErr ) |
Return the data of the RDBColumn at idx, converting if necessary. | |
long | getDataLong (const size_t idx) throw ( RDBErr ) |
Return the data of the RDBColumn at idx, converting if necessary. | |
string | getDataString (const size_t idx) throw ( RDBErr ) |
Return the data of the RDBColumn at idx, converting if necessary. | |
Column name based accessors. | |
void | setName (const string &name, const string &newname) throw ( RDBErr ) |
Modify the RDBColumn name. | |
void | setDef (const string &name, const string &def) throw ( RDBErr ) |
Modify the RDBColumn definition. | |
void | setWidth (const string &name, const long width) throw ( RDBErr ) |
Modify the RDBColumn width. | |
void | setType (const string &name, const RDBColumn::Type type) throw ( RDBErr ) |
Modify the RDBColumn type. | |
void | setJust (const string &name, const RDBColumn::Just just) throw ( RDBErr ) |
Modify the RDBColumn justification. | |
void | setDesc (const string &name, const string &desc) throw ( RDBErr ) |
Modify the RDBColumn description. | |
void | mapData (const string &name, double data[], const size_t nelems=1) throw ( RDBErr ) |
Map RDBColum data to user-supplied memory. | |
void | mapData (const string &name, long data[], const size_t nelems=1) throw ( RDBErr ) |
Map RDBColum data to user-supplied memory. | |
void | mapData (const string &name, string data[], const size_t nelems=1) throw ( RDBErr ) |
Map RDBColum data to user-supplied memory. | |
void | setData (const string &name, const double data) throw ( RDBErr ) |
Modify the RDBColumn data, converting if necessary. | |
void | setData (const string &name, const long data) throw ( RDBErr ) |
Modify the RDBColumn data, converting if necessary. | |
void | setData (const string &name, const string &data) throw ( RDBErr ) |
Modify the RDBColumn data, converting if necessary. | |
void | getName (const string &name, string &namefound) const throw ( RDBErr ) |
Return the name of the RDBColumn. | |
void | getDef (const string &name, string &def) throw ( RDBErr ) |
Return the definition of the RDBColumn. | |
void | getWidth (const string &name, long &width) const throw ( RDBErr ) |
Return the width of the RDBColumn. | |
void | getType (const string &name, RDBColumn::Type &type) const throw ( RDBErr ) |
Return the type of the RDBColumn. | |
void | getJust (const string &name, RDBColumn::Just &just) const throw ( RDBErr ) |
Return the justification of the RDBColumn. | |
void | getDesc (const string &name, string &desc) const throw ( RDBErr ) |
Return the description of the RDBColumn. | |
void | getData (const string &name, double &data) throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary. | |
void | getData (const string &name, long &data) throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary. | |
void | getData (const string &name, string &data) throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary. | |
string | getName (const string &name) const throw ( RDBErr ) |
Return the name of the RDBColumn. | |
string | getDef (const string &name) throw ( RDBErr ) |
Return the definition of the RDBColumn. | |
long | getWidth (const string &name) const throw ( RDBErr ) |
Return the width of the RDBColumn. | |
RDBColumn::Type | getType (const string &name) const throw ( RDBErr ) |
Return the type of the RDBColumn. | |
RDBColumn::Just | getJust (const string &name) const throw ( RDBErr ) |
Return the justification of the RDBColumn. | |
string | getDesc (const string &name) const throw ( RDBErr ) |
Return the description of the RDBColumn. | |
double | getDataDouble (const string &name) throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary. | |
long | getDataLong (const string &name) throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary. | |
string | getDataString (const string &name) throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary. | |
Table and header statistics. | |
size_t | nComments (void) const |
Return number of comments in RDB object. | |
size_t | nColumns (void) const |
Return number of columns in RDB object. | |
size_t | nRows (void) |
Return number of rows in RDB object. | |
Protected Member Functions | |
void | parseHeader (void) throw ( RDBErr ) |
Parse header, i.e. comments and column names and definitions. | |
vector< string > | parseLine (const string &line) const |
Parse fields in a row. | |
size_t | parseLine (bool &newgroup) throw ( RDBErr ) |
Parse fields in a row. | |
Protected Attributes | |
string | _filename |
Name of RDB file. | |
ios::openmode | _mode |
Open mode of the associated stream. | |
istream * | _isptr |
Istream attached to data file. | |
ostream * | _osptr |
Ostream attached to data file. | |
bool | _myisptr |
Indicates if RDB object is responsible for deallocating the istream. | |
bool | _myosptr |
Indicates if RDB object is responsible for deallocating the ostream. | |
size_t | _rewindto |
Position of beginning of first row of data. | |
size_t | _ncomms |
Number of comments. | |
size_t | _ncols |
Number of columns. | |
size_t | _nrows |
Number of rows. | |
bool | _knowrows |
Indicates if associated file must be scanned to determine number of rows. | |
long | _rownum |
Current *table* row number. | |
long | _frownum |
Current *file* row number. | |
bool | _autoidx |
Indicates if RDBColumn data elements should be advanced. | |
bool | _firstread |
Indicates if this is the first call to RDB::read. | |
bool | _lastread |
Indicates if this is the last call to RDB::read. | |
bool | _writehdr |
Indicates if the header has been output. | |
RDBComment * | _comms |
Array of RDBComments. | |
RDBColumn ** | _cols |
Array of RDBColumns. | |
RDBLongColumn | _nrcol |
Hidden column, containing row number. | |
bool * | _mycols |
Indicates if RDB object is responsible for deallocating given RDBColumn. | |
string | _line |
Line from RDB table. | |
Friends | |
Stream insertion and extraction operators. | |
istream & | operator>> (istream &is, RDB &rdb) throw ( RDBErr ) |
Read table from input stream. | |
ostream & | operator<< (ostream &os, RDB &rdb) throw ( RDBErr ) |
Write table to output stream. |
Definition at line 43 of file RDB.h.
enum RDB::Status |
RDB::RDB | ( | const string & | name = "" , |
|
ios::openmode | mode = ios::in | |||
) | throw ( RDBErr ) |
Attaches RDB object to a file.
name | the name of the RDB file. | |
mode | the ios::openmode of the file. |
RDBErr | error opening RDB file. | |
RDBErr | error parsing RDB comment or column name and definition. | |
RDBErr | error parsing RDB column definition. |
If no filename is specified, then the RDB::open() method may be used later to attach a file to the object.
RDB::RDB | ( | istream * | isptr | ) | throw ( RDBErr ) |
Attaches RDB object to an istream.
isptr | input stream to attach to the RDB object. |
RDBErr | error parsing RDB comment or column name and definition. | |
RDBErr | error parsing RDB column definition. |
RDB::RDB | ( | ostream * | osptr | ) | throw ( RDBErr ) |
RDB::~RDB | ( | void | ) |
Deletes resources allocated by the RDB object.
Deletes RDBComments and RDBColumns. Closes only the streams the object opened. User is responsible for closing streams they supply to the object.
Definition at line 271 of file RDB.cc.
References _cols, _comms, _isptr, _mycols, _ncols, _osptr, and close().
void RDB::open | ( | const string & | name, | |
ios::openmode | mode = ios::in | |||
) | throw ( RDBErr ) |
Attaches RDB object to a file.
name | the name of the RDB file. | |
mode | the ios::openmode of the file. |
RDBErr | error opening RDB file. | |
RDBErr | error parsing RDB comment or column name and definition. | |
RDBErr | error parsing RDB column definition. |
Definition at line 316 of file RDB.cc.
References _filename, _isptr, _mode, _myisptr, _myosptr, _osptr, close(), and parseHeader().
void RDB::open | ( | istream * | isptr | ) | throw ( RDBErr ) |
Attaches RDB object to an istream.
isptr | input stream to attach to the RDB object. |
RDBErr | error parsing RDB comments or column names and definitions | |
RDBErr | error parsing RDB column definition. |
Definition at line 400 of file RDB.cc.
References _filename, _isptr, _mode, close(), and parseHeader().
void RDB::open | ( | ostream * | osptr | ) | throw ( RDBErr ) |
void RDB::close | ( | void | ) |
Closes the stream attached to RDB object.
Closes any streams that the RDB object created.
Definition at line 526 of file RDB.cc.
References _autoidx, _cols, _comms, _filename, _isptr, _knowrows, _myisptr, _myosptr, _ncols, _ncomms, _nrows, _osptr, _rewindto, _rownum, _writehdr, RDBColumn::getDef(), getDef(), RDBColumn::getName(), and getName().
int RDB::read | ( | void | ) | throw ( RDBErr ) |
Read a line of data from the istream.
RDBErr | error if the number of tokens found does not match the number of tokens expected. | |
RDBErr | error if non-numeric data is found in a numeric column. | |
RDBErr | error if a floating point number is being assigned to an integer column. |
Definition at line 589 of file RDB.cc.
References _autoidx, _cols, _filename, _firstread, _isptr, _lastread, _line, _mode, _ncols, _rownum, advanceIdx(), RDBColumn::advanceIdx(), RDBColumn::newGroup(), and RDBColumn::setData().
Referenced by simpleRDBTable< Type >::readRow().
bool RDB::write | ( | void | ) | throw ( RDBErr ) |
Write a line of data to the ostream.
After a successful write, the RDB::_autoidx flag is set to true.
Definition at line 712 of file RDB.cc.
References _autoidx, _cols, _comms, _mode, _ncols, _ncomms, _osptr, _rewindto, _rownum, _writehdr, advanceIdx(), RDBColumn::getDef(), getDef(), RDBColumn::getName(), and getName().
bool RDB::rewind | ( | void | ) | throw ( RDBErr ) |
Rewind the stream to the beginning of the first row of data.
Definition at line 772 of file RDB.cc.
References _cols, _isptr, _mode, _ncols, _osptr, _rewindto, _rownum, and RDBColumn::rewind().
bool RDB::autoIdx | ( | void | ) | const |
void RDB::autoIdx | ( | const bool | on | ) |
Activates/deactivates auto-indexing.
on | sets the auto-indexing behavior for the RDB object and its columns. |
Definition at line 830 of file RDB.cc.
References _autoidx.
void RDB::advanceIdx | ( | void | ) |
Increments the indices in the RDBColumn data elements.
This method advances the auto-indices for all RDBColumns associated with this object.
Definition at line 857 of file RDB.cc.
References _cols, _ncols, _nrcol, RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::advanceIdx(), and RDBColumn::advanceIdx().
void RDB::setGroup | ( | const string & | name, | |
bool | group = true | |||
) | throw ( RDBErr ) |
Turn on/off group status for the named column.
group | a bool indicating whether group is on or off. | |
name | the name of the column in this RDB object. |
RDBEr | error if there is no column with matching name. |
Definition at line 878 of file RDB.cc.
References _autoidx, _cols, _filename, _ncols, _nrcol, getName(), RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::setGroup(), and RDBColumn::setGroup().
void RDB::setGroup | ( | const int | idx, | |
bool | group = true | |||
) | throw ( RDBErr ) |
Turn on/off group status for the indexed column.
group | a bool indicating whether group is on or off. | |
idx | the position of the column on which to operate. |
RDBErr | error if there is no column with matching name. |
Definition at line 911 of file RDB.cc.
References _autoidx, _cols, _filename, _ncols, and RDBColumn::setGroup().
bool RDB::getGroup | ( | const string & | name | ) | throw ( RDBErr ) |
Returns group status, true if its a new group, for the named column.
name | the name of the column. |
RDBErrNotFnd | error if there is no column with matching name. |
Definition at line 938 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, RDBColumn::getGroup(), and getName().
bool RDB::getGroup | ( | const int | idx | ) | throw ( RDBErr ) |
Returns group status, true if its a new group, for the indexed column.
idx | the column index. |
RDBErr | error if the index is out of range. |
Definition at line 967 of file RDB.cc.
References _cols, _filename, _ncols, and RDBColumn::getGroup().
bool RDB::newGroup | ( | void | ) |
Checks if any column indicates a new group.
Definition at line 989 of file RDB.cc.
Referenced by parseLine().
void RDB::setComment | ( | const string & | comm, | |
const int | idx = -1 | |||
) |
Add RDBComment in header of RDB object.
comm | a comment string. | |
idx | the position of the comment on which to operate. |
Definition at line 1015 of file RDB.cc.
References _comms, and _ncomms.
Referenced by parseHeader(), and setComment().
void RDB::setComment | ( | RDBComment & | comm, | |
const int | idx = -1 | |||
) |
Add or replace RDBComment in header of RDB object.
comm | a reference to the RDBComment object | |
idx | the position of the comment on which to operate. |
void RDB::setComment | ( | RDBComment & | comm, | |
const string & | name, | |||
const size_t | idx = 0 | |||
) |
Add or replace RDBComment in header of RDB object.
comm | a reference to the RDBComment object | |
name | the name of the comment keyword. | |
idx | currently not defined. |
Definition at line 1090 of file RDB.cc.
References _comms, _ncomms, and setComment().
void RDB::setComment | ( | const RDB & | rdb | ) |
RDBComment & RDB::getComment | ( | const size_t | idx | ) | throw ( RDBErr ) |
Return RDBComment at given index.
idx | the index of the RDBComment. |
RDBErrNot | error if the index is out of range. |
RDBComment & RDB::getComment | ( | const string & | name, | |
const size_t | idx = 0 | |||
) | throw ( RDBErr ) |
Return RDBComment with given keyword.
name | the name of the comment keyword. | |
idx | currently not defined. |
RDBErr | error if there is no comment with matching keyword. |
void RDB::setColumn | ( | const string & | name, | |
const string & | def, | |||
const int | idx = -1 | |||
) |
Add an RDBColumn in RDB object.
name | of the RDBColumn object | |
def | definition of the RDBColumn object | |
idx | the position of the column on which to operate. |
Upon completion, the RDB object contains a pointer to the RDBColumn created. Any modifications to the RDBColumn outside of the RDB object will be reflected within the RDB object and vice versa.
Definition at line 1208 of file RDB.cc.
References _cols, _mycols, _ncols, RDBColumn::setDef(), and RDBColumn::setName().
Referenced by setColumn().
void RDB::setColumn | ( | RDBColumn * | col, | |
const int | idx = -1 | |||
) |
Add or replace RDBColumn in RDB object.
col | a reference to the RDBColumn object | |
idx | the position of the column on which to operate. |
Upon completion, the RDB object contains a pointer to the RDBColumn provided. Any modifications to the RDBColumn outside of the RDB object will be reflected within the RDB object and vice versa.
void RDB::setColumn | ( | RDBColumn * | col, | |
const string & | name, | |||
const size_t | idx = 0 | |||
) |
Add of replace RDBColumn in RDB object.
col | a reference to the RDBColumn object | |
name | the name of the column in this RDB object. | |
idx | currently not defined. |
Upon completion, the RDB object contains a pointer to the RDBColumn provided. Any modifications to the RDBColumn outside of the RDB object will be reflected within the RDB object and vice versa.
Definition at line 1331 of file RDB.cc.
References _cols, _mycols, _ncols, getName(), setColumn(), and RDBColumn::setName().
void RDB::setColumn | ( | const RDB & | rdb | ) |
Copy all columns from an existing RDB object.
rdb | a reference to an RDB object |
Return pointer to RDBColumn at given index.
idx | the index of the RDBColumn. |
RDBErr | error if the index is out of range. |
void RDB::setName | ( | const size_t | idx, | |
const string & | name | |||
) | throw ( RDBErr ) |
void RDB::setDef | ( | const size_t | idx, | |
const string & | def | |||
) | throw ( RDBErr ) |
void RDB::setWidth | ( | const size_t | idx, | |
const long | width | |||
) | throw ( RDBErr ) |
void RDB::setType | ( | const size_t | idx, | |
const RDBColumn::Type | type | |||
) | throw ( RDBErr ) |
void RDB::setJust | ( | const size_t | idx, | |
const RDBColumn::Just | just | |||
) | throw ( RDBErr ) |
void RDB::setDesc | ( | const size_t | idx, | |
const string & | desc | |||
) | throw ( RDBErr ) |
void RDB::mapData | ( | const size_t | idx, | |
double | data[], | |||
const size_t | nelems = 1 | |||
) | throw ( RDBErr ) |
void RDB::mapData | ( | const size_t | idx, | |
long | data[], | |||
const size_t | nelems = 1 | |||
) | throw ( RDBErr ) |
void RDB::mapData | ( | const size_t | idx, | |
string | data[], | |||
const size_t | nelems = 1 | |||
) | throw ( RDBErr ) |
void RDB::setData | ( | const size_t | idx, | |
const double | data | |||
) | throw ( RDBErr ) |
void RDB::setData | ( | const size_t | idx, | |
const long | data | |||
) | throw ( RDBErr ) |
void RDB::setData | ( | const size_t | idx, | |
const string & | data | |||
) | throw ( RDBErr ) |
void RDB::getName | ( | const size_t | idx, | |
string & | name | |||
) | const throw ( RDBErr ) |
Return the name of the RDBColumn at idx.
RDBErr | if index is out of range. |
Definition at line 1818 of file RDB.cc.
References _cols, _filename, _ncols, and RDBColumn::getName().
Referenced by close(), getColumn(), getData(), getDataDouble(), getDataLong(), getDataString(), getDef(), getDesc(), getGroup(), getJust(), getName(), getType(), getWidth(), mapData(), setColumn(), setData(), setDef(), setDesc(), setGroup(), setJust(), setName(), setType(), setWidth(), and write().
void RDB::getDef | ( | const size_t | idx, | |
string & | def | |||
) | throw ( RDBErr ) |
void RDB::getWidth | ( | const size_t | idx, | |
long & | width | |||
) | const throw ( RDBErr ) |
void RDB::getType | ( | const size_t | idx, | |
RDBColumn::Type & | type | |||
) | const throw ( RDBErr ) |
void RDB::getJust | ( | const size_t | idx, | |
RDBColumn::Just & | just | |||
) | const throw ( RDBErr ) |
void RDB::getDesc | ( | const size_t | idx, | |
string & | desc | |||
) | const throw ( RDBErr ) |
void RDB::getData | ( | const size_t | idx, | |
double & | data | |||
) | throw ( RDBErr ) |
void RDB::getData | ( | const size_t | idx, | |
long & | data | |||
) | throw ( RDBErr ) |
void RDB::getData | ( | const size_t | idx, | |
string & | data | |||
) | throw ( RDBErr ) |
string RDB::getName | ( | const size_t | idx | ) | const throw ( RDBErr ) |
string RDB::getDef | ( | const size_t | idx | ) | throw ( RDBErr ) |
long RDB::getWidth | ( | const size_t | idx | ) | const throw ( RDBErr ) |
RDBColumn::Type RDB::getType | ( | const size_t | idx | ) | const throw ( RDBErr ) |
RDBColumn::Just RDB::getJust | ( | const size_t | idx | ) | const throw ( RDBErr ) |
string RDB::getDesc | ( | const size_t | idx | ) | const throw ( RDBErr ) |
double RDB::getDataDouble | ( | const size_t | idx | ) | throw ( RDBErr ) |
long RDB::getDataLong | ( | const size_t | idx | ) | throw ( RDBErr ) |
string RDB::getDataString | ( | const size_t | idx | ) | throw ( RDBErr ) |
void RDB::setName | ( | const string & | name, | |
const string & | newname | |||
) | throw ( RDBErr ) |
void RDB::setDef | ( | const string & | name, | |
const string & | def | |||
) | throw ( RDBErr ) |
void RDB::setWidth | ( | const string & | name, | |
const long | width | |||
) | throw ( RDBErr ) |
void RDB::setType | ( | const string & | name, | |
const RDBColumn::Type | type | |||
) | throw ( RDBErr ) |
void RDB::setJust | ( | const string & | name, | |
const RDBColumn::Just | just | |||
) | throw ( RDBErr ) |
void RDB::setDesc | ( | const string & | name, | |
const string & | desc | |||
) | throw ( RDBErr ) |
void RDB::mapData | ( | const string & | name, | |
double | data[], | |||
const size_t | nelems = 1 | |||
) | throw ( RDBErr ) |
Map RDBColum data to user-supplied memory.
name | of RDBColumn | |
data | user-supplied memory to store RDBColumn data. | |
nelems | number of elems in user-supplied memory. |
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2426 of file RDB.cc.
References _cols, _filename, _ncols, getName(), and RDBColumn::mapData().
void RDB::mapData | ( | const string & | name, | |
long | data[], | |||
const size_t | nelems = 1 | |||
) | throw ( RDBErr ) |
Map RDBColum data to user-supplied memory.
name | of RDBColumn | |
data | user-supplied memory to store RDBColumn data. | |
nelems | number of elems in user-supplied memory. |
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2462 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, getName(), RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::mapData(), and RDBColumn::mapData().
void RDB::mapData | ( | const string & | name, | |
string | data[], | |||
const size_t | nelems = 1 | |||
) | throw ( RDBErr ) |
Map RDBColum data to user-supplied memory.
name | of RDBColumn | |
data | user-supplied memory to store RDBColumn data. | |
nelems | number of elems in user-supplied memory. |
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2499 of file RDB.cc.
References _cols, _filename, _ncols, getName(), and RDBColumn::mapData().
void RDB::setData | ( | const string & | name, | |
const double | data | |||
) | throw ( RDBErr ) |
Modify the RDBColumn data, converting if necessary.
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2534 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, getName(), RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::setData(), and RDBColumn::setData().
void RDB::setData | ( | const string & | name, | |
const long | data | |||
) | throw ( RDBErr ) |
Modify the RDBColumn data, converting if necessary.
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2567 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, getName(), RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::setData(), and RDBColumn::setData().
void RDB::setData | ( | const string & | name, | |
const string & | data | |||
) | throw ( RDBErr ) |
Modify the RDBColumn data, converting if necessary.
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2600 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, getName(), RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::setData(), and RDBColumn::setData().
void RDB::getName | ( | const string & | name, | |
string & | namefound | |||
) | const throw ( RDBErr ) |
void RDB::getDef | ( | const string & | name, | |
string & | def | |||
) | throw ( RDBErr ) |
void RDB::getWidth | ( | const string & | name, | |
long & | width | |||
) | const throw ( RDBErr ) |
void RDB::getType | ( | const string & | name, | |
RDBColumn::Type & | type | |||
) | const throw ( RDBErr ) |
void RDB::getJust | ( | const string & | name, | |
RDBColumn::Just & | just | |||
) | const throw ( RDBErr ) |
void RDB::getDesc | ( | const string & | name, | |
string & | desc | |||
) | const throw ( RDBErr ) |
void RDB::getData | ( | const string & | name, | |
double & | data | |||
) | throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary.
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2778 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::getDataDouble(), RDBColumn::getDataDouble(), and getName().
void RDB::getData | ( | const string & | name, | |
long & | data | |||
) | throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary.
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 2812 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::getDataLong(), RDBColumn::getDataLong(), and getName().
void RDB::getData | ( | const string & | name, | |
string & | data | |||
) | throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary.
RDBErr | if data is invalid datatype for RDBColumn. | |
RDBErr | if no matching column name is found. |
Definition at line 2846 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::getDataString(), RDBColumn::getDataString(), and getName().
string RDB::getName | ( | const string & | name | ) | const throw ( RDBErr ) |
string RDB::getDef | ( | const string & | name | ) | throw ( RDBErr ) |
long RDB::getWidth | ( | const string & | name | ) | const throw ( RDBErr ) |
RDBColumn::Type RDB::getType | ( | const string & | name | ) | const throw ( RDBErr ) |
RDBColumn::Just RDB::getJust | ( | const string & | name | ) | const throw ( RDBErr ) |
string RDB::getDesc | ( | const string & | name | ) | const throw ( RDBErr ) |
double RDB::getDataDouble | ( | const string & | name | ) | throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary.
name | of RDBColumn |
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 3025 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::getDataDouble(), RDBColumn::getDataDouble(), and getName().
long RDB::getDataLong | ( | const string & | name | ) | throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary.
name | of RDBColumn |
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 3058 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::getDataLong(), RDBColumn::getDataLong(), and getName().
string RDB::getDataString | ( | const string & | name | ) | throw ( RDBErr ) |
Return the data of the RDBColumn, converting if necessary.
name | of RDBColumn |
RDBErr | if no matching column name is found. | |
RDBErr | if data is invalid datatype for RDBColumn. |
Definition at line 3091 of file RDB.cc.
References _cols, _filename, _ncols, _nrcol, RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 >::getDataString(), RDBColumn::getDataString(), and getName().
size_t RDB::nComments | ( | void | ) | const |
size_t RDB::nColumns | ( | void | ) | const |
size_t RDB::nRows | ( | void | ) |
Return number of rows in RDB object.
Definition at line 3151 of file RDB.cc.
References _isptr, _knowrows, _line, _mode, _nrows, and _rewindto.
void RDB::parseHeader | ( | void | ) | throw ( RDBErr ) [protected] |
Parse header, i.e. comments and column names and definitions.
Parses out comments and column names and defintions from the RDB file header. This is used by RDB::open().
Definition at line 3185 of file RDB.cc.
References _cols, _isptr, _mycols, _ncols, _ncomms, _nrows, _rewindto, _rownum, and setComment().
Referenced by open().
vector< string > RDB::parseLine | ( | const string & | line | ) | const [protected] |
size_t RDB::parseLine | ( | bool & | newgroup | ) | throw ( RDBErr ) [protected] |
Parse fields in a row.
Definition at line 3316 of file RDB.cc.
References _cols, _line, _rownum, newGroup(), and RDBColumn::setData().
string RDB::_filename [protected] |
Name of RDB file.
Definition at line 303 of file RDB.h.
Referenced by close(), getColumn(), getComment(), getData(), getDataDouble(), getDataLong(), getDataString(), getDef(), getDesc(), getGroup(), getJust(), getName(), getType(), getWidth(), mapData(), open(), read(), setData(), setDef(), setDesc(), setGroup(), setJust(), setName(), setType(), and setWidth().
ios::openmode RDB::_mode [protected] |
istream* RDB::_isptr [protected] |
Istream attached to data file.
Definition at line 308 of file RDB.h.
Referenced by close(), nRows(), open(), parseHeader(), read(), simpleRDBTable< Type >::readRow(), rewind(), and ~RDB().
ostream* RDB::_osptr [protected] |
bool RDB::_myisptr [protected] |
bool RDB::_myosptr [protected] |
size_t RDB::_rewindto [protected] |
size_t RDB::_ncomms [protected] |
Number of comments.
Definition at line 319 of file RDB.h.
Referenced by close(), getComment(), nComments(), parseHeader(), setComment(), and write().
size_t RDB::_ncols [protected] |
Number of columns.
Definition at line 321 of file RDB.h.
Referenced by advanceIdx(), close(), getColumn(), getData(), getDataDouble(), getDataLong(), getDataString(), getDef(), getDesc(), getGroup(), getJust(), getName(), getType(), getWidth(), mapData(), nColumns(), newGroup(), parseHeader(), read(), rewind(), setColumn(), setData(), setDef(), setDesc(), setGroup(), setJust(), setName(), setType(), setWidth(), write(), and ~RDB().
size_t RDB::_nrows [protected] |
Number of rows.
Definition at line 323 of file RDB.h.
Referenced by close(), nRows(), and parseHeader().
bool RDB::_knowrows [protected] |
long RDB::_rownum [protected] |
Current *table* row number.
Definition at line 327 of file RDB.h.
Referenced by close(), parseHeader(), parseLine(), read(), rewind(), and write().
long RDB::_frownum [protected] |
bool RDB::_autoidx [protected] |
bool RDB::_firstread [protected] |
bool RDB::_lastread [protected] |
bool RDB::_writehdr [protected] |
RDBComment* RDB::_comms [protected] |
Array of RDBComments.
Definition at line 341 of file RDB.h.
Referenced by close(), getComment(), setComment(), write(), and ~RDB().
RDBColumn** RDB::_cols [protected] |
Array of RDBColumns.
Definition at line 343 of file RDB.h.
Referenced by advanceIdx(), close(), getColumn(), getData(), getDataDouble(), getDataLong(), getDataString(), getDef(), getDesc(), getGroup(), getJust(), getName(), getType(), getWidth(), mapData(), newGroup(), parseHeader(), parseLine(), read(), rewind(), setColumn(), setData(), setDef(), setDesc(), setGroup(), setJust(), setName(), setType(), setWidth(), write(), and ~RDB().
RDBLongColumn RDB::_nrcol [protected] |
Hidden column, containing row number.
Definition at line 345 of file RDB.h.
Referenced by advanceIdx(), getColumn(), getData(), getDataDouble(), getDataLong(), getDataString(), getDef(), getDesc(), getGroup(), getJust(), getName(), getType(), getWidth(), mapData(), setData(), setDef(), setDesc(), setGroup(), setJust(), setName(), setType(), and setWidth().
bool* RDB::_mycols [protected] |
Indicates if RDB object is responsible for deallocating given RDBColumn.
Definition at line 347 of file RDB.h.
Referenced by parseHeader(), setColumn(), and ~RDB().
string RDB::_line [protected] |