rdbxx  1.0.7_02
simpleRDBTable< Type > Class Template Reference

A simple interface to the RDB++ read a row of an rdb table to initialize a class Type. More...

#include <simpleRDBTable.h>

Inheritance diagram for simpleRDBTable< Type >:
Collaboration diagram for simpleRDBTable< Type >:

Public Member Functions

Type * readRow ()
 Read a row of the RDB table. More...
 
- Public Member Functions inherited from RDB
 RDB (const string &name="", ios::openmode mode=ios::in)
 Attaches RDB object to a file. More...
 
 RDB (istream *isptr)
 Attaches RDB object to an istream. More...
 
 RDB (ostream *osptr)
 Attaches RDB object to an ostream. More...
 
 RDB (const RDB &rdb)
 Copies RDB object. More...
 
 ~RDB (void)
 Deletes resources allocated by the RDB object. More...
 
void open (const string &name, ios::openmode mode=ios::in)
 Attaches RDB object to a file. More...
 
void open (istream *isptr)
 Attaches RDB object to an istream. More...
 
void open (ostream *osptr)
 Attaches RDB object to an ostream. More...
 
void open (const RDB &rdb)
 Copies RDB object. More...
 
void close (void)
 Closes the stream attached to RDB object. More...
 
int read (void)
 Read a line of data from the istream. More...
 
bool write (void)
 Write a line of data to the ostream. More...
 
bool rewind (void)
 Rewind the stream to the beginning of the first row of data. More...
 
bool autoIdx (void) const
 Indicates if auto-indexing is activated. More...
 
void autoIdx (const bool on)
 Activates/deactivates auto-indexing. More...
 
void advanceIdx (void)
 Increments the indices in the RDBColumn data elements. More...
 
void setGroup (const string &name, bool group=true)
 Turn on/off group status for the named column. More...
 
void setGroup (const int idx, bool group=true)
 Turn on/off group status for the indexed column. More...
 
bool getGroup (const string &name)
 Returns group status, true if its a new group, for the named column. More...
 
bool getGroup (const int idx)
 Returns group status, true if its a new group, for the indexed column. More...
 
bool newGroup (void)
 Checks if any column indicates a new group. More...
 
void setComment (const string &comm, const int idx=-1)
 Add RDBComment in header of RDB object. More...
 
void setComment (RDBComment &comm, const int idx=-1)
 Add or replace RDBComment in header of RDB object. More...
 
void setComment (RDBComment &comm, const string &name, const size_t idx=0)
 Add or replace RDBComment in header of RDB object. More...
 
void setComment (const RDB &rdb)
 Copy all comments from an existing RDB object. More...
 
RDBCommentgetComment (const size_t idx)
 Return RDBComment at given index. More...
 
RDBCommentgetComment (const string &name, const size_t idx=0)
 Return RDBComment with given keyword. More...
 
void setColumn (const string &name, const string &def, const int idx=-1)
 Add an RDBColumn in RDB object. More...
 
void setColumn (RDBColumn *col, const int idx=-1)
 Add or replace RDBColumn in RDB object. More...
 
void setColumn (RDBColumn *col, const string &name, const size_t idx=0)
 Add of replace RDBColumn in RDB object. More...
 
void setColumn (const RDB &rdb)
 Copy all columns from an existing RDB object. More...
 
RDBColumngetColumn (const size_t idx)
 Return pointer to RDBColumn at given index. More...
 
RDBColumngetColumn (const string &name, const size_t idx=0)
 Return pointer to RDBColumn with given name. More...
 
void setName (const size_t idx, const string &name)
 Modify the name of the RDBColumn at idx. More...
 
void setDef (const size_t idx, const string &def)
 Modify the definition of the RDBColumn at idx. More...
 
void setWidth (const size_t idx, const long width)
 Modify the width of the RDBColumn at idx. More...
 
void setType (const size_t idx, const RDBColumn::Type type)
 Modify the type of the RDBColumn at idx. More...
 
void setJust (const size_t idx, const RDBColumn::Just just)
 Modify the justification of the RDBColumn at idx. More...
 
void setDesc (const size_t idx, const string &desc)
 Modify the description of the RDBColumn at idx. More...
 
void mapData (const size_t idx, double data[], const size_t nelems=1)
 Map RDBColumn data to user-supplied memory. More...
 
void mapData (const size_t idx, long data[], const size_t nelems=1)
 Map RDBColumn data to user-supplied memory. More...
 
void mapData (const size_t idx, string data[], const size_t nelems=1)
 Map RDBColumn data to user-supplied memory. More...
 
void setData (const size_t idx, const double data)
 Sets the data value of RDBColumn, converting as necessary. More...
 
void setData (const size_t idx, const long data)
 Sets the data value of RDBColumn, converting as necessary. More...
 
void setData (const size_t idx, const string &data)
 Sets the data value of RDBColumn, converting as necessary. More...
 
void getName (const size_t idx, string &name) const
 Return the name of the RDBColumn at idx. More...
 
void getDef (const size_t idx, string &def)
 Return the definition of the RDBColumn at idx. More...
 
void getWidth (const size_t idx, long &width) const
 Return the width of the RDBColumn at idx. More...
 
void getType (const size_t idx, RDBColumn::Type &type) const
 Return the type of the RDBColumn at idx. More...
 
void getJust (const size_t idx, RDBColumn::Just &just) const
 Return the just of the RDBColumn at idx. More...
 
void getDesc (const size_t idx, string &desc) const
 Return the description of the RDBColumn at idx. More...
 
void getData (const size_t idx, double &data)
 Return the data of the RDBColumn at idx, converting if necessary. More...
 
void getData (const size_t idx, long &data)
 Return the data of the RDBColumn at idx, converting if necessary. More...
 
void getData (const size_t idx, string &data)
 Return the data of the RDBColumn at idx, converting if necessary. More...
 
string getName (const size_t idx) const
 Return the name of the RDBColumn at idx. More...
 
string getDef (const size_t idx)
 Return the definition of the RDBColumn at idx. More...
 
long getWidth (const size_t idx) const
 Return the width of the RDBColumn at idx. More...
 
RDBColumn::Type getType (const size_t idx) const
 Return the type of the RDBColumn at idx. More...
 
RDBColumn::Just getJust (const size_t idx) const
 Return the justification of the RDBColumn at idx. More...
 
string getDesc (const size_t idx) const
 Return the description of the RDBColumn at idx. More...
 
double getDataDouble (const size_t idx)
 Return the data of the RDBColumn at idx, converting if necessary. More...
 
long getDataLong (const size_t idx)
 Return the data of the RDBColumn at idx, converting if necessary. More...
 
string getDataString (const size_t idx)
 Return the data of the RDBColumn at idx, converting if necessary. More...
 
void setName (const string &name, const string &newname)
 Modify the RDBColumn name. More...
 
void setDef (const string &name, const string &def)
 Modify the RDBColumn definition. More...
 
void setWidth (const string &name, const long width)
 Modify the RDBColumn width. More...
 
void setType (const string &name, const RDBColumn::Type type)
 Modify the RDBColumn type. More...
 
void setJust (const string &name, const RDBColumn::Just just)
 Modify the RDBColumn justification. More...
 
void setDesc (const string &name, const string &desc)
 Modify the RDBColumn description. More...
 
void mapData (const string &name, double data[], const size_t nelems=1)
 Map RDBColum data to user-supplied memory. More...
 
void mapData (const string &name, long data[], const size_t nelems=1)
 Map RDBColum data to user-supplied memory. More...
 
void mapData (const string &name, string data[], const size_t nelems=1)
 Map RDBColum data to user-supplied memory. More...
 
void setData (const string &name, const double data)
 Modify the RDBColumn data, converting if necessary. More...
 
void setData (const string &name, const long data)
 Modify the RDBColumn data, converting if necessary. More...
 
void setData (const string &name, const string &data)
 Modify the RDBColumn data, converting if necessary. More...
 
void getName (const string &name, string &namefound) const
 Return the name of the RDBColumn. More...
 
void getDef (const string &name, string &def)
 Return the definition of the RDBColumn. More...
 
void getWidth (const string &name, long &width) const
 Return the width of the RDBColumn. More...
 
void getType (const string &name, RDBColumn::Type &type) const
 Return the type of the RDBColumn. More...
 
void getJust (const string &name, RDBColumn::Just &just) const
 Return the justification of the RDBColumn. More...
 
void getDesc (const string &name, string &desc) const
 Return the description of the RDBColumn. More...
 
void getData (const string &name, double &data)
 Return the data of the RDBColumn, converting if necessary. More...
 
void getData (const string &name, long &data)
 Return the data of the RDBColumn, converting if necessary. More...
 
void getData (const string &name, string &data)
 Return the data of the RDBColumn, converting if necessary. More...
 
string getName (const string &name) const
 Return the name of the RDBColumn. More...
 
string getDef (const string &name)
 Return the definition of the RDBColumn. More...
 
long getWidth (const string &name) const
 Return the width of the RDBColumn. More...
 
RDBColumn::Type getType (const string &name) const
 Return the type of the RDBColumn. More...
 
RDBColumn::Just getJust (const string &name) const
 Return the justification of the RDBColumn. More...
 
string getDesc (const string &name) const
 Return the description of the RDBColumn. More...
 
double getDataDouble (const string &name)
 Return the data of the RDBColumn, converting if necessary. More...
 
long getDataLong (const string &name)
 Return the data of the RDBColumn, converting if necessary. More...
 
string getDataString (const string &name)
 Return the data of the RDBColumn, converting if necessary. More...
 
size_t nComments (void) const
 Return number of comments in RDB object. More...
 
size_t nColumns (void) const
 Return number of columns in RDB object. More...
 
size_t nRows (void)
 Return number of rows in RDB object. More...
 

Static Public Member Functions

static void getData (RDBColumn *rdbcol, string &val)
 Given an RDBColumn, get a string value. More...
 
static void getData (RDBColumn *rdbcol, int &val)
 Given an RDBColumn, get an integer value. More...
 
static void getData (RDBColumn *rdbcol, long &val)
 Given an RDBColumn, get a long value. More...
 
static void getData (RDBColumn *rdbcol, double &val)
 Given an RDBColumn, get a double value. More...
 

Additional Inherited Members

- Public Types inherited from RDB
enum  Status
 Acceptable column justifications. More...
 
- Protected Member Functions inherited from RDB
void parseHeader (void)
 Parse header, i.e. comments and column names and definitions. More...
 
vector< string > parseLine (const string &line) const
 Parse fields in a row. More...
 
size_t parseLine (bool &newgroup)
 Parse fields in a row. More...
 
- Protected Attributes inherited from RDB
string _filename
 Name of RDB file. More...
 
ios::openmode _mode
 Open mode of the associated stream. More...
 
istream * _isptr
 Istream attached to data file. More...
 
ostream * _osptr
 Ostream attached to data file. More...
 
bool _myisptr
 Indicates if RDB object is responsible for deallocating the istream. More...
 
bool _myosptr
 Indicates if RDB object is responsible for deallocating the ostream. More...
 
size_t _rewindto
 Position of beginning of first row of data. More...
 
size_t _ncomms
 Number of comments. More...
 
size_t _ncols
 Number of columns. More...
 
size_t _nrows
 Number of rows. More...
 
bool _knowrows
 Indicates if associated file must be scanned to determine number of rows. More...
 
long _rownum
 Current table row number. More...
 
long _frownum
 Current file row number. More...
 
bool _autoidx
 Indicates if RDBColumn data elements should be advanced. More...
 
bool _firstread
 Indicates if this is the first call to RDB::read. More...
 
bool _lastread
 Indicates if this is the last call to RDB::read. More...
 
bool _writehdr
 Indicates if the header has been output. More...
 
RDBComment_comms
 Array of RDBComments. More...
 
RDBColumn ** _cols
 Array of RDBColumns. More...
 
RDBLongColumn _nrcol
 Hidden column, containing row number. More...
 
bool * _mycols
 Indicates if RDB object is responsible for deallocating given RDBColumn. More...
 
string _line
 Line from RDB table. More...
 

Detailed Description

template<class Type>
class simpleRDBTable< Type >

A simple interface to the RDB++ read a row of an rdb table to initialize a class Type.

The class Type must have a constructor with the following prototype:

Type( const char* header[], RDBColumn** rdb_column )

Definition at line 48 of file simpleRDBTable.h.

Member Function Documentation

◆ getData() [1/4]

template<class Type >
void simpleRDBTable< Type >::getData ( RDBColumn rdbcol,
string &  val 
)
static

Given an RDBColumn, get a string value.

Definition at line 86 of file simpleRDBTable.cc.

◆ getData() [2/4]

template<class Type >
void simpleRDBTable< Type >::getData ( RDBColumn rdbcol,
int &  val 
)
static

Given an RDBColumn, get an integer value.

Definition at line 98 of file simpleRDBTable.cc.

◆ getData() [3/4]

template<class Type >
void simpleRDBTable< Type >::getData ( RDBColumn rdbcol,
long &  val 
)
static

Given an RDBColumn, get a long value.

Definition at line 122 of file simpleRDBTable.cc.

◆ getData() [4/4]

template<class Type >
void simpleRDBTable< Type >::getData ( RDBColumn rdbcol,
double &  val 
)
static

Given an RDBColumn, get a double value.

Definition at line 145 of file simpleRDBTable.cc.

◆ readRow()

template<class Type >
Type * simpleRDBTable< Type >::readRow ( )

Read a row of the RDB table.

Definition at line 191 of file simpleRDBTable.cc.


The documentation for this class was generated from the following files: