rdbxx  1.0.10
simpleRDBTable.h
1 #ifndef simpleRDBTable_H
2 #define simpleRDBTable_H
3 
4 /* --8<--8<--8<--8<--
5  *
6  * Copyright (C) 2006 Smithsonian Astrophysical Observatory
7  *
8  * This file is part of RDB
9  *
10  * RDB is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * RDB is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the
22  * Free Software Foundation, Inc.
23  * 51 Franklin Street, Fifth Floor
24  * Boston, MA 02110-1301, USA
25  *
26  * -->8-->8-->8-->8-- */
27 
28 #include <iostream>
29 
30 #include <suplibxx/str.h>
31 #include <Exception/Exception.h>
32 
33 #include <rdbxx/RDBColumn.h>
34 #include <rdbxx/RDB.h>
35 
45 template< class Type >
46 class simpleRDBTable : public RDB {
47 
48  friend std::ostream& operator << ( std::ostream& os, simpleRDBTable< Type >& a ) {
49  a.print( os );
50  return os;
51  }
52 
53  friend std::ostream& operator << ( std::ostream& os, simpleRDBTable< Type >* a ) {
54  a->print( os );
55  return os;
56  }
57 
58 public:
59 
60  ~simpleRDBTable( );
61 
62  simpleRDBTable( const std::string& fname, const int mode,
63  const char* header[] )
64  ;
65 
67  static void getData( RDBColumn* rdbcol, std::string& val );
68 
70  static void getData( RDBColumn* rdbcol, int& val );
71 
73  static void getData( RDBColumn* rdbcol, long& val );
74 
76  static void getData( RDBColumn* rdbcol, double& val );
77 
78  void print( std::ostream& os ) const;
79 
81  Type* readRow( );
82 
83 protected:
84 
85  const char** rdb_header;
86 
87  RDBColumn** rdb_column;
88 
89 private:
90 
92  simpleRDBTable( ) : rdb_header( NULL ), rdb_column( NULL ) { }
93 
94  // Declare but (purposedly) not define
96 
97  // Declare but (purposedly) not define
98  simpleRDBTable< Type >& operator = ( const simpleRDBTable< Type >& rhs );
99 
100  size_t count_num_args( const char* str[] );
101 
102 };
103 
104 #ifndef simpleRDBTable_cc
105 #include <rdbxx/simpleRDBTable.cc>
106 #endif
107 
108 #endif
Type * readRow()
Read a row of the RDB table.
Provides interface for manipulating RDB tables.
Definition: RDB.h:42
static void getData(RDBColumn *rdbcol, std::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.
Definition: RDBColumn.h:41