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