7 #include <boost/make_shared.hpp>
21 if (n1->type() != n2->type())
23 error +=
"Trying to merge two nodes of different types.\n";
27 if (n1->type() ==
ARRAY)
30 c1.
nodes[me_idx] = n2->deepCopy(c2, me_idx, c1);
33 Map* map1 =
static_cast<Map*
>(n1.get());
34 const Map* map2 =
static_cast<const Map*
>(n2.get());
36 boost::shared_ptr<Map> new_map = boost::make_shared<Map>(*map1);
42 const Label& label2 = it2->first;
44 if (it1 == map1->
map_.end())
48 c1.
nodes[child_idx] = c2.
nodes[it2->second]->deepCopy(c2, child_idx, c1);
49 new_map->map_[label2] = child_idx;
54 data_merge(c1, it1->second, c2, it2->second, error);
62 new_map->values[it2->first] = it2->second;
65 c1.
nodes[me_idx] = new_map;
75 data = boost::make_shared<Data>(*ptr.
data);
112 return (
data->nodes.empty() || (
data->nodes.size() == 1 &&
data->nodes[0]->empty()));
123 return (
data->nodes.empty() || (
data->nodes.size() == 1 &&
data->nodes[0]->empty()));
131 emitter.
emit(d, out);
140 emitter.
emit(d, out);