10 #include <boost/foreach.hpp>
36 result =
copy(context);
38 result = Element::createMap();
40 result->set(
"comment", comment);
51 BOOST_FOREACH(
ElementPtr item, list->listValue()) {
53 if (item->contains(name)) {
56 item->set(name, param);
65 BOOST_FOREACH(
ElementPtr item, list->listValue()) {
68 param = item->get(name);
69 }
else if ((!param && item->contains(name)) ||
70 (param && !item->contains(name)) ||
71 (param && item->contains(name) &&
72 !param->equals(*item->get(name)))) {
74 "inconsistent value of " << name
75 <<
" in " << list->str());
78 if (!first && param) {
79 BOOST_FOREACH(
ElementPtr item, list->listValue()) {
84 parent->set(name, param);
103 if (scope->getType() == Element::map) {
104 if (!key || !value || (key->getType() != Element::string)) {
107 string name = key->stringValue();
108 if (!name.empty() && !scope->contains(name)) {
109 scope->set(name,
copy(value));
111 }
else if (scope->getType() == Element::list) {
113 scope->add(
copy(value));
128 if ((scope->getType() != Element::map) ||
129 !key || !value || (key->getType() != Element::string)) {
132 string name = key->stringValue();
134 scope->set(name,
copy(value));
151 if (scope->getType() == Element::map) {
152 if (!key || (key->getType() != Element::string)) {
155 string name = key->stringValue();
159 }
else if (scope->getType() == Element::list) {
162 }
else if (key->getType() == Element::integer) {
163 int index = key->intValue();
164 if ((index >= 0) && (index < scope->size())) {
165 scope->remove(index);
167 }
else if (key->getType() == Element::map) {
170 if (!entry || !value || (entry->getType() != Element::string)) {
173 string name = entry->stringValue();
177 for (
int i = 0; i < scope->size(); ++i) {
179 if (!item || (item->getType() != Element::map)) {
183 if (compare && value->equals(*compare)) {
201 if (next == actions->size()) {
206 if (!action || (action->getType() != Element::map) ||
207 !action->contains(
"action")) {
208 applyAction(actions, scope, next);
211 string name = action->get(
"action")->stringValue();
212 if (name ==
"insert") {
213 applyInsert(action->get(
"key"), action->get(
"value"), scope);
214 }
else if (name ==
"replace") {
215 applyReplace(action->get(
"key"), action->get(
"value"), scope);
216 }
else if (name ==
"delete") {
217 applyDelete(action->get(
"key"), scope);
219 applyAction(actions, scope, next);
241 if (next == path->size()) {
242 applyAction(actions, scope, 0);
247 if (scope->getType() == Element::map) {
248 if (!step || (step->getType() != Element::string)) {
251 string name = step->stringValue();
252 if (name.empty() || !scope->contains(name)) {
257 applyDown(path, actions, down, next);
259 }
else if (scope->getType() == Element::list) {
263 auto downs = scope->listValue();
264 if (step->getType() == Element::map) {
267 if (!key || !value || (key->getType() != Element::string)) {
270 string name = key->stringValue();
275 if (!down || (down->getType() != Element::map)) {
279 if (compare && value->equals(*compare)) {
280 applyDown(path, actions, down, next);
284 }
else if (step->getType() != Element::integer) {
287 int index = step->intValue();
290 applyDown(path, actions, down, next);
292 }
else if ((index >= 0) && (index < scope->size())) {
293 applyDown(path, actions, scope->getNonConst(index), next);
304 applyDown(path, actions, config, 0);
boost::shared_ptr< Element > ElementPtr
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
Defines the logger used by the top-level component of kea-dhcp-ddns.
The Element class represents a piece of data, used by the command channel and configuration parts...