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
00026 #ifndef STORAGE_H_
00027 #define STORAGE_H_
00028
00029 #include <string.h>
00030 #include <map>
00031 #include <vector>
00032
00033 #include "types.h"
00034 #include "str_hash.h"
00035
00036 #ifndef SWIG
00037 using namespace std;
00038 #endif
00039
00040
00041
00042
00043
00044
00045
00046
00047 class storage
00048 {
00049 public:
00050
00051
00052
00053
00054 storage () { changed = 1; }
00055
00056
00057
00058
00059
00060 ~storage ();
00061
00062
00063
00064
00065
00066
00067
00068 void set_val (string key, s_int32 value);
00069
00070
00071
00072
00073
00074
00075
00076
00077 s_int32 get_val (string key);
00078
00079
00080
00081
00082
00083
00084
00085 pair<string, s_int32> next ();
00086
00087 #ifndef SWIG
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 s_int32& operator[] (string key);
00099 #endif
00100
00101 private:
00102 #ifndef SWIG
00103 hash_map<string, s_int32> data;
00104 hash_map<string, s_int32>::iterator i;
00105 u_int8 changed;
00106 #endif
00107
00108 public:
00109 #ifndef SWIG
00110
00111
00112
00113
00114 typedef hash_map<string, s_int32>::iterator iterator;
00115
00116
00117
00118
00119
00120
00121
00122 iterator begin ()
00123 {
00124 return data.begin ();
00125 }
00126
00127
00128
00129
00130
00131
00132
00133 iterator end ()
00134 {
00135 return data.end ();
00136 }
00137
00138
00139
00140
00141
00142
00143
00144 u_int32 size () const
00145 {
00146 return data.size ();
00147 }
00148 #endif
00149 };
00150
00151
00152
00153
00154
00155
00156 class objects
00157 {
00158 public:
00159
00160
00161
00162
00163 objects () { changed = 1; }
00164
00165
00166
00167
00168
00169
00170
00171 void set_val (const char * key, storage* val);
00172
00173
00174
00175
00176
00177
00178
00179
00180 storage* get_val (const char * key);
00181
00182
00183
00184
00185
00186
00187 void erase (const char * key);
00188
00189
00190
00191
00192
00193
00194
00195 storage* next ();
00196
00197 private:
00198 #ifndef SWIG
00199
00200
00201
00202
00203 struct ltstr
00204 {
00205 bool operator()(const char* s1, const char* s2) const
00206 {
00207 return strcmp (s1, s2) < 0;
00208 }
00209 };
00210
00211 map<const char*, storage*, ltstr> data;
00212 map<const char*, storage*, ltstr>::iterator i;
00213 u_int8 changed;
00214 #endif
00215 };
00216
00217 #ifndef SWIG
00218
00219
00220
00221
00222
00223
00224
00225
00226 template <class mytype>
00227 class dictionary : public hash_map<string, mytype>
00228 {
00229 };
00230
00231 #endif
00232
00233 #endif // STORAGE_H_