25 #ifndef simpleRDBTable_cc 26 #define simpleRDBTable_cc 28 #include <rdbxx/simpleRDBTable.h> 30 template<
class Type >
40 template<
class Type >
44 for ( num = 0; NULL != str[ num ]; num++ )
50 template<
class Type >
53 const char* header[] )
55 RDB( fname, static_cast<ios_base::openmode>(mode) ){
64 size_t num_cols = count_num_args( header );
66 rdb_column =
new RDBColumn*[ num_cols + 1 ];
67 for(
size_t ii = 0; ii < num_cols; ii++ ) {
68 rdb_column[ ii ]= getColumn( header[ ii ] );
70 rdb_column[ num_cols ] = NULL;
74 }
catch( Exception& e ) {
80 throw( Exception(
"simpleRDBTable: unexpected exception caught" ) );
85 template<
class Type >
90 throw Exception(
"simpleRDBTable<T>::getData( RDBColumn*, string& ) :" 91 " The first argument must not be NULL\n" );
97 template<
class Type >
101 if ( NULL == rdbcol )
102 throw Exception(
"simpleRDBTable<T>::getData( RDBColumn*, string& ) :" 103 " The first argument must not be NULL\n" );
110 long result = suplib::str2l( tmp.c_str( ), 10 );
121 template<
class Type >
125 if ( NULL == rdbcol )
126 throw Exception(
"simpleRDBTable<T>::getData( RDBColumn*, string& ) : " 127 "The first argument must not be NULL\n" );
134 val = suplib::str2l( tmp.c_str( ), 10 );
144 template<
class Type >
148 if ( NULL == rdbcol )
149 throw Exception(
"simpleRDBTable<T>::getData( RDBColumn*, string& ) : " 150 "The first argument must not be NULL\n" );
157 val = suplib::str2d( tmp.c_str( ) );
167 template<
class Type >
172 for(
size_t num = 0; NULL != rdb_header[ num ]; num++ ) {
173 os << rdb_header[ num ];
174 if ( NULL != rdb_header[ num + 1 ] )
180 for(
size_t num = 0; NULL != rdb_column[ num ]; num++ ) {
181 os << rdb_column[ num ]->
getDef( );
182 if ( NULL != rdb_column[ num + 1 ] )
190 template<
class Type >
195 throw Exception(
"The rdb table is not yet open for reading\n" );
200 return new Type( rdb_header, rdb_column );
Type * readRow()
Read a row of the RDB table.
virtual void * getData(void)=0
Returns a pointer to the current data element.
void getDef(const size_t idx, string &def)
Return the definition of the RDBColumn at idx.
Provides interface for manipulating RDB tables.
static void getData(RDBColumn *rdbcol, string &val)
Given an RDBColumn, get a string value.
A simple interface to the RDB++ read a row of an rdb table to initialize a class Type.
Provides interface for general column related methods.