15 #include "../internal/helpers.h"
16 #include "../visitors/serialization.h"
23 template <
class t_Visitor,
typename t_Key,
typename t_Value,
class t_Compare,
class t_Allocator>
26 std::map<t_Key, t_Value, t_Compare, t_Allocator> &entry,
27 const typename t_Visitor::Parameters ¶m)
29 ARILES2_TRACE_FUNCTION;
30 std::size_t size = visitor.startArray();
32 for (std::size_t i = 0; i < size; ++i)
34 std::pair<t_Key, t_Value> map_entry;
36 visitor.startArrayElement();
38 entry.insert(map_entry);
39 visitor.endArrayElement();
45 template <
class t_Visitor,
typename t_Value,
class t_Compare,
class t_Allocator>
48 std::map<std::string, t_Value, t_Compare, t_Allocator> &entry,
49 const typename t_Visitor::Parameters ¶meters)
51 ARILES2_TRACE_FUNCTION;
52 if (
true == parameters.sloppy_maps_ and
true == visitor.startIteratedMap(t_Visitor::SIZE_LIMIT_MIN, 1))
55 std::string entry_name;
56 while (
true == visitor.startIteratedMapElement(entry_name))
58 apply_read(visitor, entry[entry_name], parameters);
59 visitor.endIteratedMapElement();
61 visitor.endIteratedMap();
65 apply_read<t_Visitor, std::string, t_Value, t_Compare, t_Allocator>(visitor, entry, parameters);
76 template <
class t_Visitor,
typename t_Key,
typename t_Value,
class t_Compare,
class t_Allocator>
79 const std::map<t_Key, t_Value, t_Compare, t_Allocator> &entry,
80 const typename t_Visitor::Parameters ¶m)
82 ARILES2_TRACE_FUNCTION;
83 writer.startArray(entry.size(), param.compact_arrays_);
84 for (
typename std::map<t_Key, t_Value, t_Compare, t_Allocator>::const_iterator it = entry.begin();
88 writer.visitArrayElement(*it, param);
94 template <
class t_Visitor,
typename t_Value,
class t_Compare,
class t_Allocator>
97 const std::map<std::string, t_Value, t_Compare, t_Allocator> &entry,
98 const typename t_Visitor::Parameters ¶m)
100 ARILES2_TRACE_FUNCTION;
101 if (
true == param.sloppy_maps_)
103 if (
true == writer.startIteratedMap(entry.size(), param))
105 for (
typename std::map<std::string, t_Value, t_Compare, t_Allocator>::const_iterator it =
110 writer.startIteratedMapElement(it->first);
112 writer.endIteratedMapElement();
114 writer.endIteratedMap();
118 apply_write<t_Visitor, std::string, t_Value, t_Compare, t_Allocator>(writer, entry, param);
128 template <
class t_Visitor,
typename t_Key,
typename t_Value,
class t_Compare,
class t_Allocator>
131 const std::map<t_Key, t_Value, t_Compare, t_Allocator> &left,
132 const std::map<t_Key, t_Value, t_Compare, t_Allocator> &right,
133 const typename t_Visitor::Parameters ¶m)
135 ARILES2_TRACE_FUNCTION;
137 visitor.equal_ &= (left.size() == right.size());
139 typename std::map<t_Key, t_Value, t_Compare, t_Allocator>::const_iterator left_it = left.begin();
140 typename std::map<t_Key, t_Value, t_Compare, t_Allocator>::const_iterator right_it = right.begin();
142 for (; (left_it != left.end()) and (right_it != right.end()) and (
true == visitor.equal_);
143 ++left_it, ++right_it)
145 apply_compare(visitor, left_it->first, right_it->first, param);
146 apply_compare(visitor, left_it->second, right_it->second, param);
158 template <
class t_Visitor,
typename t_Key,
typename t_Value,
class t_Compare,
class t_Allocator>
161 std::map<t_Key, t_Value, t_Compare, t_Allocator> &entry,
162 const typename t_Visitor::Parameters & )
164 ARILES2_TRACE_FUNCTION;
175 template <
class t_Visitor,
typename t_Key,
typename t_Value,
class t_Compare,
class t_Allocator>
178 std::map<t_Key, t_Value, t_Compare, t_Allocator> &entry,
179 const typename t_Visitor::Parameters ¶m)
181 ARILES2_TRACE_FUNCTION;
182 for (
typename std::map<t_Key, t_Value, t_Compare, t_Allocator>::iterator it = entry.begin();
201 typename t_ValueLeft,
203 class t_AllocatorLeft,
205 typename t_ValueRight,
206 class t_CompareRight,
207 class t_AllocatorRight>
210 std::map<t_KeyLeft, t_ValueLeft, t_CompareLeft, t_AllocatorLeft> &left,
211 const std::map<t_KeyRight, t_ValueRight, t_CompareRight, t_AllocatorRight> &right,
212 const typename t_Visitor::Parameters ¶m)
214 ARILES2_TRACE_FUNCTION;
216 typename std::map<t_KeyRight, t_ValueRight, t_CompareRight, t_AllocatorRight>::const_iterator right_it =
221 for (; right_it != right.end(); ++right_it)
237 typename t_ValueLeft,
239 class t_AllocatorLeft,
241 typename t_ValueRight,
242 class t_CompareRight,
243 class t_AllocatorRight>
246 const std::map<t_KeyLeft, t_ValueLeft, t_CompareLeft, t_AllocatorLeft> &left,
247 std::map<t_KeyRight, t_ValueRight, t_CompareRight, t_AllocatorRight> &right,
248 const typename t_Visitor::Parameters ¶m)
250 ARILES2_TRACE_FUNCTION;
252 typename std::map<t_KeyLeft, t_ValueLeft, t_CompareLeft, t_AllocatorLeft>::const_iterator left_it =
257 for (; left_it != left.end(); ++left_it)
259 t_KeyRight right_key;
261 apply_copyto(visitor, left_it->first, right_key, param);
262 apply_copyto(visitor, left_it->second, right[right_key], param);