diff options
author | Mike Buland <eichlan@xagasoft.com> | 2022-04-07 22:52:09 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2022-04-07 22:52:09 -0700 |
commit | cef3d22297265304e81abf442fe218a6cba7fc10 (patch) | |
tree | ac8a6f673f6da2682b814f7ddc57d3b8552239a7 | |
parent | 3cbd1038e20dcb2b25db4e74666ec21766642729 (diff) | |
download | libgats-cef3d22297265304e81abf442fe218a6cba7fc10.tar.gz libgats-cef3d22297265304e81abf442fe218a6cba7fc10.tar.bz2 libgats-cef3d22297265304e81abf442fe218a6cba7fc10.tar.xz libgats-cef3d22297265304e81abf442fe218a6cba7fc10.zip |
Dictionaries delete old objects to replace new.
There may be a better way to manage this.
Diffstat (limited to '')
-rw-r--r-- | c++-qt/gats-qt/dictionary.h | 3 | ||||
-rw-r--r-- | c++-qt/src/dictionary.cpp | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/c++-qt/gats-qt/dictionary.h b/c++-qt/gats-qt/dictionary.h index 6f9e82a..6b13868 100644 --- a/c++-qt/gats-qt/dictionary.h +++ b/c++-qt/gats-qt/dictionary.h | |||
@@ -49,7 +49,8 @@ namespace Gats | |||
49 | //void insert( const QByteArray &sKey, bool b ); | 49 | //void insert( const QByteArray &sKey, bool b ); |
50 | void insert( const QByteArray &sKey, float d ); | 50 | void insert( const QByteArray &sKey, float d ); |
51 | void insert( const QByteArray &sKey, double d ); | 51 | void insert( const QByteArray &sKey, double d ); |
52 | using QHash<QByteArray, Gats::Object *>::insert; | 52 | void insert( const QByteArray &sKey, Gats::Object *pObj ); |
53 | //using QHash<QByteArray, Gats::Object *>::insert; | ||
53 | void insertBool( const QByteArray &sKey, bool b ); | 54 | void insertBool( const QByteArray &sKey, bool b ); |
54 | void insertInt( const QByteArray &sKey, int64_t i ); | 55 | void insertInt( const QByteArray &sKey, int64_t i ); |
55 | void insertFloat( const QByteArray &sKey, double d ); | 56 | void insertFloat( const QByteArray &sKey, double d ); |
diff --git a/c++-qt/src/dictionary.cpp b/c++-qt/src/dictionary.cpp index 1d666ac..6793268 100644 --- a/c++-qt/src/dictionary.cpp +++ b/c++-qt/src/dictionary.cpp | |||
@@ -121,6 +121,7 @@ QString Gats::Dictionary::toString( int iIndent ) const | |||
121 | 121 | ||
122 | void Gats::Dictionary::insert( const QByteArray &sKey, char i ) | 122 | void Gats::Dictionary::insert( const QByteArray &sKey, char i ) |
123 | { | 123 | { |
124 | delete value( sKey ); | ||
124 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 125 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
125 | sKey, new Gats::Integer( i ) | 126 | sKey, new Gats::Integer( i ) |
126 | ); | 127 | ); |
@@ -128,6 +129,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, char i ) | |||
128 | 129 | ||
129 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned char i ) | 130 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned char i ) |
130 | { | 131 | { |
132 | delete value( sKey ); | ||
131 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 133 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
132 | sKey, new Gats::Integer( i ) | 134 | sKey, new Gats::Integer( i ) |
133 | ); | 135 | ); |
@@ -135,6 +137,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, unsigned char i ) | |||
135 | 137 | ||
136 | void Gats::Dictionary::insert( const QByteArray &sKey, signed char i ) | 138 | void Gats::Dictionary::insert( const QByteArray &sKey, signed char i ) |
137 | { | 139 | { |
140 | delete value( sKey ); | ||
138 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 141 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
139 | sKey, new Gats::Integer( i ) | 142 | sKey, new Gats::Integer( i ) |
140 | ); | 143 | ); |
@@ -142,6 +145,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, signed char i ) | |||
142 | 145 | ||
143 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned short i ) | 146 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned short i ) |
144 | { | 147 | { |
148 | delete value( sKey ); | ||
145 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 149 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
146 | sKey, new Gats::Integer( i ) | 150 | sKey, new Gats::Integer( i ) |
147 | ); | 151 | ); |
@@ -149,6 +153,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, unsigned short i ) | |||
149 | 153 | ||
150 | void Gats::Dictionary::insert( const QByteArray &sKey, signed short i ) | 154 | void Gats::Dictionary::insert( const QByteArray &sKey, signed short i ) |
151 | { | 155 | { |
156 | delete value( sKey ); | ||
152 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 157 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
153 | sKey, new Gats::Integer( i ) | 158 | sKey, new Gats::Integer( i ) |
154 | ); | 159 | ); |
@@ -156,6 +161,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, signed short i ) | |||
156 | 161 | ||
157 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned int i ) | 162 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned int i ) |
158 | { | 163 | { |
164 | delete value( sKey ); | ||
159 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 165 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
160 | sKey, new Gats::Integer( i ) | 166 | sKey, new Gats::Integer( i ) |
161 | ); | 167 | ); |
@@ -163,6 +169,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, unsigned int i ) | |||
163 | 169 | ||
164 | void Gats::Dictionary::insert( const QByteArray &sKey, signed int i ) | 170 | void Gats::Dictionary::insert( const QByteArray &sKey, signed int i ) |
165 | { | 171 | { |
172 | delete value( sKey ); | ||
166 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 173 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
167 | sKey, new Gats::Integer( i ) | 174 | sKey, new Gats::Integer( i ) |
168 | ); | 175 | ); |
@@ -170,6 +177,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, signed int i ) | |||
170 | 177 | ||
171 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long i ) | 178 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long i ) |
172 | { | 179 | { |
180 | delete value( sKey ); | ||
173 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 181 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
174 | sKey, new Gats::Integer( i ) | 182 | sKey, new Gats::Integer( i ) |
175 | ); | 183 | ); |
@@ -177,6 +185,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long i ) | |||
177 | 185 | ||
178 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long i ) | 186 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long i ) |
179 | { | 187 | { |
188 | delete value( sKey ); | ||
180 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 189 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
181 | sKey, new Gats::Integer( i ) | 190 | sKey, new Gats::Integer( i ) |
182 | ); | 191 | ); |
@@ -184,6 +193,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, signed long i ) | |||
184 | 193 | ||
185 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long long i ) | 194 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long long i ) |
186 | { | 195 | { |
196 | delete value( sKey ); | ||
187 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 197 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
188 | sKey, new Gats::Integer( i ) | 198 | sKey, new Gats::Integer( i ) |
189 | ); | 199 | ); |
@@ -191,6 +201,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long long i ) | |||
191 | 201 | ||
192 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long long i ) | 202 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long long i ) |
193 | { | 203 | { |
204 | delete value( sKey ); | ||
194 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 205 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
195 | sKey, new Gats::Integer( i ) | 206 | sKey, new Gats::Integer( i ) |
196 | ); | 207 | ); |
@@ -198,6 +209,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, signed long long i ) | |||
198 | /* | 209 | /* |
199 | void Gats::Dictionary::insert( const QByteArray &sKey, bool b ) | 210 | void Gats::Dictionary::insert( const QByteArray &sKey, bool b ) |
200 | { | 211 | { |
212 | delete value( sKey ); | ||
201 | QHash<QByteArray, Gats::Object *>::insert( | 213 | QHash<QByteArray, Gats::Object *>::insert( |
202 | sKey, new Gats::Boolean( b ) | 214 | sKey, new Gats::Boolean( b ) |
203 | ); | 215 | ); |
@@ -205,6 +217,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, bool b ) | |||
205 | 217 | ||
206 | void Gats::Dictionary::insert( const QByteArray &sKey, float d ) | 218 | void Gats::Dictionary::insert( const QByteArray &sKey, float d ) |
207 | { | 219 | { |
220 | delete value( sKey ); | ||
208 | QHash<QByteArray, Gats::Object *>::insert( | 221 | QHash<QByteArray, Gats::Object *>::insert( |
209 | sKey, new Gats::Float( d ) | 222 | sKey, new Gats::Float( d ) |
210 | ); | 223 | ); |
@@ -212,6 +225,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, float d ) | |||
212 | 225 | ||
213 | void Gats::Dictionary::insert( const QByteArray &sKey, double d ) | 226 | void Gats::Dictionary::insert( const QByteArray &sKey, double d ) |
214 | { | 227 | { |
228 | delete value( sKey ); | ||
215 | QHash<QByteArray, Gats::Object *>::insert( | 229 | QHash<QByteArray, Gats::Object *>::insert( |
216 | sKey, new Gats::Float( d ) | 230 | sKey, new Gats::Float( d ) |
217 | ); | 231 | ); |
@@ -219,6 +233,7 @@ void Gats::Dictionary::insert( const QByteArray &sKey, double d ) | |||
219 | 233 | ||
220 | void Gats::Dictionary::insert( const QByteArray &sKey, const char *s ) | 234 | void Gats::Dictionary::insert( const QByteArray &sKey, const char *s ) |
221 | { | 235 | { |
236 | delete value( sKey ); | ||
222 | QHash<QByteArray, Gats::Object *>::insert( | 237 | QHash<QByteArray, Gats::Object *>::insert( |
223 | sKey, new Gats::String( s ) | 238 | sKey, new Gats::String( s ) |
224 | ); | 239 | ); |
@@ -226,13 +241,23 @@ void Gats::Dictionary::insert( const QByteArray &sKey, const char *s ) | |||
226 | 241 | ||
227 | void Gats::Dictionary::insert( const QByteArray &sKey, const QByteArray &s ) | 242 | void Gats::Dictionary::insert( const QByteArray &sKey, const QByteArray &s ) |
228 | { | 243 | { |
244 | delete value( sKey ); | ||
229 | QHash<QByteArray, Gats::Object *>::insert( | 245 | QHash<QByteArray, Gats::Object *>::insert( |
230 | sKey, new Gats::String( s ) | 246 | sKey, new Gats::String( s ) |
231 | ); | 247 | ); |
232 | } | 248 | } |
233 | 249 | ||
250 | void Gats::Dictionary::insert( const QByteArray &sKey, Gats::Object *pObj ) | ||
251 | { | ||
252 | delete value( sKey ); | ||
253 | QHash<QByteArray, Gats::Object *>::insert( | ||
254 | sKey, pObj | ||
255 | ); | ||
256 | } | ||
257 | |||
234 | void Gats::Dictionary::insertBool( const QByteArray &sKey, bool b ) | 258 | void Gats::Dictionary::insertBool( const QByteArray &sKey, bool b ) |
235 | { | 259 | { |
260 | delete value( sKey ); | ||
236 | QHash<QByteArray, Gats::Object *>::insert( | 261 | QHash<QByteArray, Gats::Object *>::insert( |
237 | sKey, new Gats::Boolean( b ) | 262 | sKey, new Gats::Boolean( b ) |
238 | ); | 263 | ); |
@@ -240,6 +265,7 @@ void Gats::Dictionary::insertBool( const QByteArray &sKey, bool b ) | |||
240 | 265 | ||
241 | void Gats::Dictionary::insertInt( const QByteArray &sKey, int64_t i ) | 266 | void Gats::Dictionary::insertInt( const QByteArray &sKey, int64_t i ) |
242 | { | 267 | { |
268 | delete value( sKey ); | ||
243 | QHash<QByteArray, Gats::Object *>::insert( | 269 | QHash<QByteArray, Gats::Object *>::insert( |
244 | sKey, new Gats::Integer( i ) | 270 | sKey, new Gats::Integer( i ) |
245 | ); | 271 | ); |
@@ -247,6 +273,7 @@ void Gats::Dictionary::insertInt( const QByteArray &sKey, int64_t i ) | |||
247 | 273 | ||
248 | void Gats::Dictionary::insertFloat( const QByteArray &sKey, double d ) | 274 | void Gats::Dictionary::insertFloat( const QByteArray &sKey, double d ) |
249 | { | 275 | { |
276 | delete value( sKey ); | ||
250 | QHash<QByteArray, Gats::Object *>::insert( | 277 | QHash<QByteArray, Gats::Object *>::insert( |
251 | sKey, new Gats::Float( d ) | 278 | sKey, new Gats::Float( d ) |
252 | ); | 279 | ); |
@@ -254,6 +281,7 @@ void Gats::Dictionary::insertFloat( const QByteArray &sKey, double d ) | |||
254 | 281 | ||
255 | void Gats::Dictionary::insertStr( const QByteArray &sKey, const QByteArray &s ) | 282 | void Gats::Dictionary::insertStr( const QByteArray &sKey, const QByteArray &s ) |
256 | { | 283 | { |
284 | delete value( sKey ); | ||
257 | QHash<QByteArray, Gats::Object *>::insert( | 285 | QHash<QByteArray, Gats::Object *>::insert( |
258 | sKey, new Gats::String( s ) | 286 | sKey, new Gats::String( s ) |
259 | ); | 287 | ); |
@@ -261,6 +289,7 @@ void Gats::Dictionary::insertStr( const QByteArray &sKey, const QByteArray &s ) | |||
261 | 289 | ||
262 | void Gats::Dictionary::insertList( const QByteArray &sKey, Gats::List *pL ) | 290 | void Gats::Dictionary::insertList( const QByteArray &sKey, Gats::List *pL ) |
263 | { | 291 | { |
292 | delete value( sKey ); | ||
264 | QHash<QByteArray, Gats::Object *>::insert( | 293 | QHash<QByteArray, Gats::Object *>::insert( |
265 | sKey, pL | 294 | sKey, pL |
266 | ); | 295 | ); |
@@ -269,6 +298,7 @@ void Gats::Dictionary::insertList( const QByteArray &sKey, Gats::List *pL ) | |||
269 | void Gats::Dictionary::insertDict( const QByteArray &sKey, | 298 | void Gats::Dictionary::insertDict( const QByteArray &sKey, |
270 | Gats::Dictionary *pD ) | 299 | Gats::Dictionary *pD ) |
271 | { | 300 | { |
301 | delete value( sKey ); | ||
272 | QHash<QByteArray, Gats::Object *>::insert( | 302 | QHash<QByteArray, Gats::Object *>::insert( |
273 | sKey, pD | 303 | sKey, pD |
274 | ); | 304 | ); |