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
00028 #ifndef _DATAMAP_H
00029 #define _DATAMAP_H
00030
00031 #include <coconut_config.h>
00032 #include <coconut_types.h>
00033 #include <basic_alltype.h>
00034 #include <map>
00035
00036 namespace coco {
00037
00039
00044 class datamap : std::map<std::string, basic_alltype>
00045 {
00046 private:
00048 typedef std::map<std::string, basic_alltype> _Base;
00051 private:
00054 std::string encode(const std::string& __s, int i) const;
00060 bool update_index(const std::string& __s, int i, bool __insert);
00062 bool check_index(const std::string& __s, int i) const;
00063
00064 public:
00066 datamap() : _Base() {}
00068 datamap(const std::string& __n, const basic_alltype& __v)
00069 : _Base()
00070 { insert(std::make_pair(__n,__v)); }
00072 datamap(const char* __n, const basic_alltype& __v)
00073 : _Base()
00074 { insert(std::make_pair(std::string(__n),__v)); }
00076 datamap(const datamap& __c) : _Base(__c) {}
00078 virtual ~datamap() {}
00079
00080 public:
00082
00087 bool sinsert(const std::string& __s, const basic_alltype& __h,
00088 bool replace);
00089 bool sinsert(const char* __s, const basic_alltype& __h, bool replace);
00091
00093
00098 bool sinsert(const std::string& __s, int i, const basic_alltype& __h,
00099 bool replace);
00100 bool sinsert(const char* __s, int i, const basic_alltype& __h,
00101 bool replace);
00103
00105
00108 const basic_alltype& sfind(const std::string& __s) const;
00109 const basic_alltype& sfind(const char* __s) const;
00111
00113
00116 const basic_alltype& sfind(const std::string& __s, int i) const;
00117 const basic_alltype& sfind(const char* __s, int i) const;
00119
00121
00123 void remove(const std::string& __s);
00124 void remove(const char* __s);
00126
00128
00130 void remove(const std::string& __s, int i);
00131 void remove(const char* __s, int i);
00133
00135
00136 bool defd(const std::string& __s) const;
00137 bool defd(const char* __s) const;
00139
00141
00143 bool defd(const std::string& __s, int i) const;
00144 bool defd(const char* __s, int i) const;
00146
00148
00151 bool which(const std::string& __s, std::vector<int>& __idx) const;
00152 bool which(const char* __s, std::vector<int>& __idx) const;
00154
00156
00159 void list(std::vector<std::string>& __v) const;
00160
00162
00167 bool retrieve(const std::string& __s, bool& __v) const;
00168 bool retrieve(const std::string& __s, int& __v) const;
00169 bool retrieve(const std::string& __s, unsigned int& __v) const;
00170 bool retrieve(const std::string& __s, double& __v) const;
00171 bool retrieve(const std::string& __s, interval& __v) const;
00172 bool retrieve(const std::string& __s, std::string& __is) const;
00173 bool retrieve(const std::string& __s, const std::vector<bool>*& __v) const;
00174 bool retrieve(const std::string& __s, const std::vector<int>*& __v) const;
00175 bool retrieve(const std::string& __s,
00176 const std::vector<unsigned int>*& __v) const;
00177 bool retrieve(const std::string& __s, const std::vector<double>*& __v) const;
00178 bool retrieve(const std::string& __s, const std::vector<interval>*& __v)
00179 const;
00180 bool retrieve(const std::string& __s, const std::vector<std::string>*& __v)
00181 const;
00182 bool retrieve(const std::string& __s, const linalg::matrix<double>*& __v) const;
00183 bool retrieve(const std::string& __s, const linalg::matrix<int>*& __v) const;
00184 bool retrieve(const std::string& __s, const linalg::matrix<interval>*& __v) const;
00185 bool retrieve(const std::string& __s, const linalg::matrix<std::string>*& __v) const;
00186
00187 bool retrieve(const char* __s, bool& __v) const;
00188 bool retrieve(const char* __s, int& __v) const;
00189 bool retrieve(const char* __s, unsigned int& __v) const;
00190 bool retrieve(const char* __s, double& __v) const;
00191 bool retrieve(const char* __s, interval& __v) const;
00192 bool retrieve(const char* __s, std::string& __is) const;
00193 bool retrieve(const char* __s, const std::vector<bool>*& __v) const;
00194 bool retrieve(const char* __s, const std::vector<unsigned int>*& __v) const;
00195 bool retrieve(const char* __s, const std::vector<int>*& __v) const;
00196 bool retrieve(const char* __s, const std::vector<double>*& __v) const;
00197 bool retrieve(const char* __s, const std::vector<interval>*& __v) const;
00198 bool retrieve(const char* __s, const std::vector<std::string>*& __v) const;
00199 bool retrieve(const char* __s, const linalg::matrix<double>*& __v) const;
00200 bool retrieve(const char* __s, const linalg::matrix<int>*& __v) const;
00201 bool retrieve(const char* __s, const linalg::matrix<interval>*& __v) const;
00202 bool retrieve(const char* __s, const linalg::matrix<std::string>*& __v) const;
00204
00206
00212 bool retrieve(const std::string& __s, bool& __v, bool __def) const;
00213 bool retrieve(const std::string& __s, int& __v, int __def) const;
00214 bool retrieve(const std::string& __s, unsigned int& __v,
00215 unsigned int __def) const;
00216 bool retrieve(const std::string& __s, double& __v, double __def) const;
00217 bool retrieve(const std::string& __s, interval& __v,
00218 const interval& __def) const;
00219 bool retrieve(const std::string& __s, std::string& __is,
00220 const std::string& __def) const;
00221 bool retrieve(const std::string& __s, const std::vector<bool>*& __v,
00222 const std::vector<bool>* __def) const;
00223 bool retrieve(const std::string& __s, const std::vector<int>*& __v,
00224 const std::vector<int>* __def) const;
00225 bool retrieve(const std::string& __s, const std::vector<unsigned int>*& __v,
00226 const std::vector<unsigned int>* __def) const;
00227 bool retrieve(const std::string& __s, const std::vector<double>*& __v,
00228 const std::vector<double>* __def) const;
00229 bool retrieve(const std::string& __s, const std::vector<interval>*& __v,
00230 const std::vector<interval>* __def) const;
00231 bool retrieve(const std::string& __s, const std::vector<std::string>*& __v,
00232 const std::vector<std::string>* __def) const;
00233 bool retrieve(const std::string& __s, const linalg::matrix<double>*& __v,
00234 const linalg::matrix<double>* __def) const;
00235 bool retrieve(const std::string& __s, const linalg::matrix<int>*& __v,
00236 const linalg::matrix<int>* __def) const;
00237 bool retrieve(const std::string& __s, const linalg::matrix<interval>*& __v,
00238 const linalg::matrix<interval>* __def) const;
00239 bool retrieve(const std::string& __s, const linalg::matrix<std::string>*& __v,
00240 const linalg::matrix<std::string>* __def) const;
00241
00242 bool retrieve(const char* __s, bool& __v, bool __def) const;
00243 bool retrieve(const char* __s, int& __v, int __def) const;
00244 bool retrieve(const char* __s, unsigned int& __v, unsigned int __def) const;
00245 bool retrieve(const char* __s, double& __v, double __def) const;
00246 bool retrieve(const char* __s, interval& __v,
00247 const interval& __def) const;
00248 bool retrieve(const char* __s, std::string& __v,
00249 const std::string& __def) const;
00250 bool retrieve(const char* __s, const std::vector<bool>*& __v,
00251 const std::vector<bool>* __def) const;
00252 bool retrieve(const char* __s, const std::vector<unsigned int>*& __v,
00253 const std::vector<unsigned int>* __def) const;
00254 bool retrieve(const char* __s, const std::vector<int>*& __v,
00255 const std::vector<int>* __def) const;
00256 bool retrieve(const char* __s, const std::vector<double>*& __v,
00257 const std::vector<double>* __def) const;
00258 bool retrieve(const char* __s, const std::vector<interval>*& __v,
00259 const std::vector<interval>* __def) const;
00260 bool retrieve(const char* __s, const std::vector<std::string>*& __v,
00261 const std::vector<std::string>* __def) const;
00262 bool retrieve(const char* __s, const linalg::matrix<double>*& __v,
00263 const linalg::matrix<double>* __def) const;
00264 bool retrieve(const char* __s, const linalg::matrix<int>*& __v,
00265 const linalg::matrix<int>* __def) const;
00266 bool retrieve(const char* __s, const linalg::matrix<interval>*& __v,
00267 const linalg::matrix<interval>* __def) const;
00268 bool retrieve(const char* __s, const linalg::matrix<std::string>*& __v,
00269 const linalg::matrix<std::string>* __def) const;
00271
00273
00279 bool retrieve_i(const std::string& __s, int i, bool& __v) const;
00280 bool retrieve_i(const std::string& __s, int i, int& __v) const;
00281 bool retrieve_i(const std::string& __s, int i, unsigned int& __v) const;
00282 bool retrieve_i(const std::string& __s, int i, double& __v) const;
00283 bool retrieve_i(const std::string& __s, int i, interval& __v) const;
00284 bool retrieve_i(const std::string& __s, int i, std::string& __is) const;
00285 bool retrieve_i(const std::string& __s, int i,
00286 const std::vector<bool>*& __v) const;
00287 bool retrieve_i(const std::string& __s, int i,
00288 const std::vector<int>*& __v) const;
00289 bool retrieve_i(const std::string& __s, int i,
00290 const std::vector<unsigned int>*& __v) const;
00291 bool retrieve_i(const std::string& __s, int i,
00292 const std::vector<double>*& __v) const;
00293 bool retrieve_i(const std::string& __s, int i,
00294 const std::vector<interval>*& __v) const;
00295 bool retrieve_i(const std::string& __s, int i,
00296 const std::vector<std::string>*& __v) const;
00297 bool retrieve_i(const std::string& __s, int i,
00298 const linalg::matrix<double>*& __v) const;
00299 bool retrieve_i(const std::string& __s, int i, const linalg::matrix<int>*& __v) const;
00300 bool retrieve_i(const std::string& __s, int i,
00301 const linalg::matrix<interval>*& __v) const;
00302 bool retrieve_i(const std::string& __s, int i,
00303 const linalg::matrix<std::string>*& __v) const;
00304
00305 bool retrieve_i(const char* __s, int i, bool& __v) const;
00306 bool retrieve_i(const char* __s, int i, int& __v) const;
00307 bool retrieve_i(const char* __s, int i, unsigned int& __v) const;
00308 bool retrieve_i(const char* __s, int i, double& __v) const;
00309 bool retrieve_i(const char* __s, int i, interval& __v) const;
00310 bool retrieve_i(const char* __s, int i, std::string& __is) const;
00311 bool retrieve_i(const char* __s, int i, const std::vector<bool>*& __v) const;
00312 bool retrieve_i(const char* __s, int i, const std::vector<int>*& __v) const;
00313 bool retrieve_i(const char* __s, int i,
00314 const std::vector<unsigned int>*& __v) const;
00315 bool retrieve_i(const char* __s, int i, const std::vector<double>*& __v) const;
00316 bool retrieve_i(const char* __s, int i,
00317 const std::vector<interval>*& __v) const;
00318 bool retrieve_i(const char* __s, int i,
00319 const std::vector<std::string>*& __v) const;
00320 bool retrieve_i(const char* __s, int i, const linalg::matrix<double>*& __v) const;
00321 bool retrieve_i(const char* __s, int i, const linalg::matrix<int>*& __v) const;
00322 bool retrieve_i(const char* __s, int i, const linalg::matrix<interval>*& __v) const;
00323 bool retrieve_i(const char* __s, int i, const linalg::matrix<std::string>*& __v)
00324 const;
00326
00328
00334 bool retrieve_i(const std::string& __s, int i, bool& __v, bool __def) const;
00335 bool retrieve_i(const std::string& __s, int i, int& __v, int __def) const;
00336 bool retrieve_i(const std::string& __s, int i, unsigned int& __v,
00337 unsigned int __def) const;
00338 bool retrieve_i(const std::string& __s, int i, double& __v, double __def) const;
00339 bool retrieve_i(const std::string& __s, int i, interval& __v,
00340 const interval& __def) const;
00341 bool retrieve_i(const std::string& __s, int i, std::string& __is,
00342 const std::string& __def) const;
00343 bool retrieve_i(const std::string& __s, int i, const std::vector<bool>*& __v,
00344 const std::vector<bool>* __def) const;
00345 bool retrieve_i(const std::string& __s, int i, const std::vector<int>*& __v,
00346 const std::vector<int>* __def) const;
00347 bool retrieve_i(const std::string& __s, int i,
00348 const std::vector<unsigned int>*& __v,
00349 const std::vector<unsigned int>* __def) const;
00350 bool retrieve_i(const std::string& __s, int i, const std::vector<double>*& __v,
00351 const std::vector<double>* __def) const;
00352 bool retrieve_i(const std::string& __s, int i,
00353 const std::vector<interval>*& __v,
00354 const std::vector<interval>* __def) const;
00355 bool retrieve_i(const std::string& __s, int i,
00356 const std::vector<std::string>*& __v,
00357 const std::vector<std::string>* __def) const;
00358 bool retrieve_i(const std::string& __s, int i, const linalg::matrix<double>*& __v,
00359 const linalg::matrix<double>* __def) const;
00360 bool retrieve_i(const std::string& __s, int i, const linalg::matrix<int>*& __v,
00361 const linalg::matrix<int>* __def) const;
00362 bool retrieve_i(const std::string& __s, int i, const linalg::matrix<interval>*& __v,
00363 const linalg::matrix<interval>* __def) const;
00364 bool retrieve_i(const std::string& __s, int i,
00365 const linalg::matrix<std::string>*& __v, const linalg::matrix<std::string>* __def) const;
00366
00367 bool retrieve_i(const char* __s, int i, bool& __v, bool __def) const;
00368 bool retrieve_i(const char* __s, int i, int& __v, int __def) const;
00369 bool retrieve_i(const char* __s, int i, unsigned int& __v,
00370 unsigned int __def) const;
00371 bool retrieve_i(const char* __s, int i, double& __v, double __def) const;
00372 bool retrieve_i(const char* __s, int i, interval& __v,
00373 const interval& __def) const;
00374 bool retrieve_i(const char* __s, int i, std::string& __v,
00375 const std::string& __def) const;
00376 bool retrieve_i(const char* __s, int i, const std::vector<bool>*& __v,
00377 const std::vector<bool>* __def) const;
00378 bool retrieve_i(const char* __s, int i, const std::vector<int>*& __v,
00379 const std::vector<int>* __def) const;
00380 bool retrieve_i(const char* __s, int i, const std::vector<unsigned int>*& __v,
00381 const std::vector<unsigned int>* __def) const;
00382 bool retrieve_i(const char* __s, int i, const std::vector<double>*& __v,
00383 const std::vector<double>* __def) const;
00384 bool retrieve_i(const char* __s, int i, const std::vector<interval>*& __v,
00385 const std::vector<interval>* __def) const;
00386 bool retrieve_i(const char* __s, int i, const std::vector<std::string>*& __v,
00387 const std::vector<std::string>* __def) const;
00388 bool retrieve_i(const char* __s, int i, const linalg::matrix<double>*& __v,
00389 const linalg::matrix<double>* __def) const;
00390 bool retrieve_i(const char* __s, int i, const linalg::matrix<int>*& __v,
00391 const linalg::matrix<int>* __def) const;
00392 bool retrieve_i(const char* __s, int i, const linalg::matrix<interval>*& __v,
00393 const linalg::matrix<interval>* __def) const;
00394 bool retrieve_i(const char* __s, int i, const linalg::matrix<std::string>*& __v,
00395 const linalg::matrix<std::string>* __def) const;
00397 };
00398
00399 }
00400
00401 #include <datamap.hpp>
00402
00403 #endif