21 static Value mkCopy(EP value) {
return (Value(value,
false)); }
24 static Value mkShare(EP value) {
return (Value(value,
true)); }
28 EP get()
const {
return (value_); }
32 bool isShared()
const {
return (shared_); }
38 Value(EP value,
bool shared) : value_(value), shared_(shared) { }
54Value<EP> moveComments1(EP element) {
55 bool modified =
false;
60 typedef std::vector<ElementPtr> ListType;
61 const ListType& list = element->listValue();
62 for (
auto const& it : list) {
63 Value<ElementPtr> item = moveComments1(it);
64 result->add(item.get());
65 if (!item.isShared()) {
70 return (Value<EP>::mkShare(element));
72 return (Value<EP>::mkCopy(result));
75 return (Value<EP>::mkShare(element));
80 bool has_comment =
false;
81 typedef std::map<std::string, ConstElementPtr> map_type;
82 const map_type& map = element->mapValue();
83 for (
auto const& it : map) {
84 if (it.first ==
"comment") {
87 }
else if (it.first ==
"user-context") {
89 result->set(
"user-context", it.second);
92 Value<ConstElementPtr> item = moveComments1(it.second);
93 result->set(it.first, item.get());
94 if (!item.isShared()) {
100 if (!has_comment && !modified) {
101 return (Value<EP>::mkShare(element));
108 moved->set(
"comment", comment);
112 merge(moved, previous);
114 result->set(
"user-context", moved);
117 return (Value<EP>::mkCopy(result));
126 Value<ElementPtr> result = moveComments1(element);
127 return (result.get());
131 Value<ConstElementPtr> result = moveComments1(element);
132 return (result.get());
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
void merge(ElementPtr element, ConstElementPtr other)
Merges the data from other into element.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
ElementPtr moveComments(ElementPtr element)
Move comment entries to user-context.
Defines the logger used by the top-level component of kea-lfc.