-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathcheckpoint_map.hh
More file actions
597 lines (493 loc) · 24.3 KB
/
Copy pathcheckpoint_map.hh
File metadata and controls
597 lines (493 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/*
PURPOSE: (Illustrate how to checkpoint STLs)
LIBRARY_DEPENDENCIES: (
(checkpoint_map.o)
)
*/
#ifndef CHECKPOINT_MAP_HH
#define CHECKPOINT_MAP_HH
#include <map>
#include <string>
#include <algorithm>
#include <sstream>
#include <typeinfo>
#include <type_traits>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
/* =================================================================================================*/
/* For all of the checkpoint_map_stl variations. Declare 2 memory manager arrays to hold
the contents of the map. No simulation variable actually points to these arrays. Only the
user knows they are there and how they are stored. The restart function knows how to
"retrieve" and restore the data. The name of the declaration is important. Each instance of
the STL requires a unique name to be saved correctly. The incoming "object_name" and "var_name"
gives that unique name.
*/
// intrinsic key, intrinsic data
template <class STL>
int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
int status ;
// used for keeping c_str components of std::strings allocated and accessable
// while they are being used.
std::string temp_str;
typename STL::key_type * keys = nullptr ;
typename STL::mapped_type * items = nullptr ;
cont_size = in_map.size();
if ( cont_size > 0 ) {
std::string type_string ;
try {
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status )) ;
} catch (const std::bad_typeid& e) {
message_publish(1, "Error, having difficulty checkpointing %s.%s\n", object_name.c_str(), var_name.c_str()) ;
return 0 ;
}
var_declare << type_string << " "
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
temp_str = var_declare.str();
keys = (typename STL::key_type *)TMM_declare_var_s(temp_str.c_str()) ;
if ( keys ) {
temp_str = std::string(object_name + "_" + var_name + "_keys");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
var_declare.str("") ;
var_declare.clear() ;
try {
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
} catch (const std::bad_typeid& e) {
message_publish(1, "Error, having difficulty checkpointing %s.%s\n", object_name.c_str(), var_name.c_str()) ;
return 0 ;
}
var_declare << type_string << " "
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
temp_str = var_declare.str();
items = (typename STL::mapped_type *)TMM_declare_var_s(temp_str.c_str()) ;
if ( items ) {
temp_str = std::string(object_name + "_" + var_name + "_data");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = iter->first ;
items[ii] = iter->second ;
}
}
}
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_id( in_map , object_name , var_name ) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_id( in_map , object_name , var_name ) ;
}
// intrinsic key, STL data
template <class STL>
int checkpoint_map_ik_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
int status ;
// used for keeping c_str components of std::strings allocated and accessable
// while they are being used.
std::string temp_str;
typename STL::key_type * keys = nullptr ;
std::string * items = nullptr ;
cont_size = in_map.size();
if ( cont_size > 0 ) {
std::string type_string ;
try {
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status )) ;
} catch (const std::bad_typeid& e) {
message_publish(1, "Error, having difficulty checkpointing %s.%s\n", object_name.c_str(), var_name.c_str()) ;
return 0 ;
}
var_declare << type_string << " "
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
temp_str = var_declare.str();
keys = (typename STL::key_type *)TMM_declare_var_s(temp_str.c_str()) ;
if ( keys ) {
temp_str = std::string(object_name + "_" + var_name + "_keys");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
var_declare.str("") ;
var_declare.clear() ;
var_declare << "std::string "
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
temp_str = var_declare.str();
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
if ( items ) {
temp_str = std::string(object_name + "_" + var_name + "_data");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = iter->first ;
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_data_" << ii ;
items[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
//message_publish(1, "recursive call to checkpoint_stl %s\n", __PRETTY_FUNCTION__) ;
checkpoint_stl( iter->second , object_name + "_" + var_name + "_data" , index_string.str() ) ;
}
}
}
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_sd( in_map , object_name , var_name ) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_sd( in_map , object_name , var_name ) ;
}
// STL key, intrinsic data
template <class STL>
int checkpoint_map_sk_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
int status ;
// used for keeping c_str components of std::strings allocated and accessable
// while they are being used.
std::string temp_str;
std::string * keys = nullptr ;
typename STL::mapped_type * items = nullptr ;
cont_size = in_map.size();
if ( cont_size > 0 ) {
var_declare << "std::string "
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
temp_str = var_declare.str();
keys = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
if ( keys ) {
temp_str = std::string(object_name + "_" + var_name + "_keys");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
var_declare.str("") ;
var_declare.clear() ;
std::string type_string ;
try {
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
} catch (const std::bad_typeid& e) {
message_publish(1, "Error, having difficulty checkpointing %s.%s\n", object_name.c_str(), var_name.c_str()) ;
return 0 ;
}
var_declare << type_string << " "
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
temp_str = var_declare.str() ;
items = (typename STL::mapped_type *)TMM_declare_var_s(temp_str.c_str()) ;
if ( items ) {
temp_str = std::string(object_name + "_" + var_name + "_data");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_keys_" << ii ;
keys[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
checkpoint_stl( const_cast<typename STL::key_type &>(iter->first) ,
object_name + "_" + var_name + "_keys", index_string.str() ) ;
items[ii] = iter->second ;
}
}
}
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_sk_id( in_map , object_name , var_name ) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_sk_id( in_map , object_name , var_name ) ;
}
// STL key, STL data
template <class STL>
int checkpoint_map_stl_sk_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
// used for keeping c_str components of std::strings allocated and accessable
// while they are being used.
std::string temp_str;
std::string * keys = nullptr ;
std::string * items = nullptr ;
cont_size = in_map.size();
if ( cont_size > 0 ) {
var_declare << "std::string "
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
temp_str = var_declare.str();
keys = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
if ( keys ) {
temp_str = std::string(object_name + "_" + var_name + "_keys");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
var_declare.str("") ;
var_declare.clear() ;
var_declare << "std::string "
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
temp_str = var_declare.str();
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
if ( items ) {
temp_str = std::string(object_name + "_" + var_name + "_data");
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
std::stringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_keys_" << ii ;
keys[ii] = sub_elements.str() ;
std::stringstream index_string ;
index_string << ii ;
checkpoint_stl( const_cast<typename STL::key_type &>(iter->first) ,
object_name + "_" + var_name + "_keys", index_string.str() ) ;
std::stringstream sub_elements_data;
sub_elements_data << object_name << "_" << var_name << "_data_" << ii ;
items[ii] = sub_elements_data.str() ;
checkpoint_stl( iter->second ,
object_name + "_" + var_name + "_data", index_string.str() ) ;
}
}
}
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_sk_sd( in_map , object_name , var_name ) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_sk_sd( in_map , object_name , var_name ) ;
}
/* =================================================================================================*/
template <class STL>
int delete_map_allocs(STL& in_map __attribute__((unused)), std::string object_name, std::string var_name)
{
REF2 * items_ref ;
std::string temp_str;
temp_str = object_name + std::string("_") + var_name + std::string("_keys");
items_ref = ref_attributes((char *)temp_str.c_str()) ;
if ( items_ref != NULL ) {
temp_str = object_name + std::string("_") + var_name + std::string("_keys");
TMM_delete_var_n(temp_str.c_str() ) ;
temp_str = object_name + std::string("_") + var_name + std::string("_data");
TMM_delete_var_n(temp_str.c_str() ) ;
free(items_ref) ;
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc>
int delete_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return delete_map_allocs(in_map , object_name , var_name) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc>
int delete_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return delete_map_allocs(in_map , object_name , var_name) ;
}
/* =================================================================================================*/
/* For all restore_map_stl varieties.
Find the arrays the map data was stored in the checkpoint using ref_attributes
From the address of the resulting ref_attributes, we can figure out the number
of items that were stored in the checkpoint. Knowing the size, we can restore
the map from the 2 arrays.
*/
template <class STL>
int restore_map_ik_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * keys_ref , * items_ref ;
std::string temp_str;
typename STL::key_type * keys ;
typename STL::mapped_type * items ;
//message_publish(1, "in regular map template restore\n") ;
temp_str = object_name + "_" + var_name + "_keys";
keys_ref = ref_attributes(temp_str.c_str()) ;
temp_str = object_name + "_" + var_name + "_data";
items_ref = ref_attributes(temp_str.c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
in_map.clear() ;
keys = (typename STL::key_type *)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(keys[ii], items[ii])) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_id(in_map , object_name , var_name) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_id(in_map , object_name , var_name) ;
}
template <class STL>
int restore_map_ik_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::string temp_str;
REF2 * keys_ref , * items_ref ;
typename STL::key_type * keys ;
std::string * items ;
//message_publish(1, "in regular map template restore\n") ;
temp_str = object_name + "_" + var_name + "_keys";
keys_ref = ref_attributes(temp_str.c_str()) ;
temp_str = object_name + "_" + var_name + "_data";
items_ref = ref_attributes(temp_str.c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
in_map.clear() ;
keys = (typename STL::key_type *)keys_ref->address ;
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
std::ostringstream index_string ;
index_string << ii ;
typename STL::mapped_type mt ;
restore_stl(mt, object_name + "_" + var_name + "_data", index_string.str()) ;
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(keys[ii], mt)) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_sd(in_map , object_name , var_name) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_sd(in_map , object_name , var_name) ;
}
template <class STL>
int restore_map_sk_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::string temp_str;
REF2 * keys_ref , * items_ref ;
std::string * keys ;
typename STL::mapped_type * items ;
//message_publish(1, "in regular map template restore\n") ;
temp_str = object_name + "_" + var_name + "_keys";
keys_ref = ref_attributes(temp_str.c_str()) ;
temp_str = object_name + "_" + var_name + "_data";
items_ref = ref_attributes(temp_str.c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
in_map.clear() ;
keys = (std::string *)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
std::ostringstream index_string ;
index_string << ii ;
typename STL::key_type kt ;
restore_stl(kt, object_name + "_" + var_name + "_keys", index_string.str()) ;
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(kt, items[ii])) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_id(in_map , object_name , var_name) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_id(in_map , object_name , var_name) ;
}
template <class STL>
int restore_map_sk_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::string temp_str;
REF2 * keys_ref , * items_ref ;
std::string * keys ;
std::string * items ;
//message_publish(1, "in regular map template restore\n") ;
temp_str = object_name + "_" + var_name + "_keys";
keys_ref = ref_attributes((char *)temp_str.c_str()) ;
temp_str = object_name + "_" + var_name + "_data";
items_ref = ref_attributes((char *)temp_str.c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
in_map.clear() ;
keys = (std::string *)keys_ref->address ;
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
std::ostringstream index_string ;
index_string << ii ;
typename STL::key_type kt ;
restore_stl(kt, object_name + "_" + var_name + "_keys", index_string.str()) ;
typename STL::mapped_type mt ;
restore_stl(mt, object_name + "_" + var_name + "_data", index_string.str()) ;
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(kt, mt)) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_sd(in_map , object_name , var_name) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_sd(in_map , object_name , var_name) ;
}
#endif