00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00031 #ifndef __VDBL_ROW_H
00032 #define __VDBL_ROW_H
00033
00034 #include <algorithm>
00035 #include <map>
00036 #include <vdbl_config.h>
00037 #include <vdbl_types.h>
00038 #include <vdbl_col.h>
00039
00040 __VDBL_BEGIN_NAMESPACE
00041
00042 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00043 #pragma set woff 1209
00044 #endif
00045
00047 static _VDBL_col ___empty_col_return;
00048
00050
00054 class _VDBL_row
00055 {
00056 private:
00058 typedef std::map<_VDBL_colid, _VDBL_col> _R_map;
00059
00061 _R_map _R_i;
00062
00063 public:
00067 _VDBL_row() : _R_i() {}
00071 _VDBL_row(const _VDBL_row& __r) : _R_i(__r._R_i) {}
00075 virtual ~_VDBL_row() {}
00076
00082 const _VDBL_col& get_col(const _VDBL_colid& _id, bool& error) const
00083 {
00084 _R_map::const_iterator __i(_R_i.find(_id));
00085
00086 if(__i == _R_i.end())
00087 {
00088 error = true;
00089 return ___empty_col_return;
00090 }
00091 else
00092 {
00093 error = false;
00094 return (*__i).second;
00095 }
00096 }
00097
00103 _VDBL_col& get_col(const _VDBL_colid& _id, bool& error)
00104 {
00105 _R_map::iterator __i(_R_i.find(_id));
00106
00107 if(__i == _R_i.end())
00108 {
00109 error = true;
00110 return ___empty_col_return;
00111 }
00112 else
00113 {
00114 error = false;
00115 return (*__i).second;
00116 }
00117 }
00118
00122 bool has_col(const _VDBL_colid& _id) const
00123 {
00124 _R_map::const_iterator __i(_R_i.find(_id));
00125 return __i != _R_i.end();
00126 }
00127
00132 bool insert(const _VDBL_colid& _id, const _VDBL_col& _col)
00133 {
00134 _R_map::iterator __i(_R_i.find(_id));
00135 if(__i != _R_i.end())
00136 return false;
00137 else
00138 {
00139 _R_i.insert(std::make_pair(_id,_col));
00140 return true;
00141 }
00142 }
00143
00149 bool drop(const _VDBL_colid& _id)
00150 {
00151 _R_map::iterator __i(_R_i.find(_id));
00152 if(__i == _R_i.end())
00153 return false;
00154 else
00155 {
00156 _R_i.erase(__i);
00157 return true;
00158 }
00159 }
00160
00166 void update(const _VDBL_colid& _id, const _VDBL_col& _col)
00167 {
00168 _R_map::iterator __i(_R_i.find(_id));
00169 if(__i != _R_i.end())
00170 _R_i.erase(__i);
00171 _R_i.insert(std::make_pair(_id,_col));
00172 }
00173 };
00174
00176
00180 class row : public _VDBL_row
00181 {
00182 private:
00183 typedef _VDBL_row _Base;
00184 public:
00185 typedef _VDBL_colid id;
00186 typedef _VDBL_col col;
00187
00191 row() : _Base() {}
00195 row(const row& __r) : _Base(__r) {}
00199 row(const _Base& __r) : _Base(__r) {}
00200
00204 row& operator=(const row& _x)
00205 {
00206 return *(row*)&(this->_Base::operator=(_x));
00207 }
00208
00212 row& operator=(const _Base& _x)
00213 {
00214 return *(row*)&(this->_Base::operator=(_x));
00215 }
00216 };
00217
00218 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00219 #pragma reset woff 1209
00220 #endif
00221
00222 __VDBL_END_NAMESPACE
00223
00224 #endif
00225
00226
00227
00228