8 #include <boost/foreach.hpp> 34 result =
copy(context);
36 result = Element::createMap();
38 result->set(
"comment", comment);
49 BOOST_FOREACH(
ElementPtr item, list->listValue()) {
51 if (item->contains(name)) {
54 item->set(name, param);
63 BOOST_FOREACH(
ElementPtr item, list->listValue()) {
66 param = item->get(name);
67 }
else if ((!param && item->contains(name)) ||
68 (param && !item->contains(name)) ||
69 (param && item->contains(name) &&
70 !param->equals(*item->get(name)))) {
72 "inconsistent value of " << name
73 <<
" in " << list->str());
76 if (!first && param) {
77 BOOST_FOREACH(
ElementPtr item, list->listValue()) {
82 parent->set(name, param);
101 if (scope->getType() == Element::map) {
102 if (!key || !value || (key->getType() != Element::string)) {
105 string name = key->stringValue();
106 if (!name.empty() && !scope->contains(name)) {
107 scope->set(name,
copy(value));
109 }
else if (scope->getType() == Element::list) {
111 scope->add(
copy(value));
126 if ((scope->getType() != Element::map) ||
127 !key || !value || (key->getType() != Element::string)) {
130 string name = key->stringValue();
132 scope->set(name,
copy(value));
149 if (scope->getType() == Element::map) {
150 if (!key || (key->getType() != Element::string)) {
153 string name = key->stringValue();
157 }
else if (scope->getType() == Element::list) {
160 }
else if (key->getType() == Element::integer) {
161 int index = key->intValue();
162 if ((index >= 0) && (index < scope->size())) {
163 scope->remove(index);
165 }
else if (key->getType() == Element::map) {
168 if (!entry || !value || (entry->getType() != Element::string)) {
171 string name = entry->stringValue();
175 for (
int i = 0; i < scope->size(); ++i) {
177 if (!item || (item->getType() != Element::map)) {
181 if (compare && value->equals(*compare)) {
199 if (next == actions->size()) {
204 if (!action || (action->getType() != Element::map) ||
205 !action->contains(
"action")) {
206 applyAction(actions, scope, next);
209 string name = action->get(
"action")->stringValue();
210 if (name ==
"insert") {
211 applyInsert(action->get(
"key"), action->get(
"value"), scope);
212 }
else if (name ==
"replace") {
213 applyReplace(action->get(
"key"), action->get(
"value"), scope);
214 }
else if (name ==
"delete") {
215 applyDelete(action->get(
"key"), scope);
217 applyAction(actions, scope, next);
239 if (next == path->size()) {
240 applyAction(actions, scope, 0);
245 if (scope->getType() == Element::map) {
246 if (!step || (step->getType() != Element::string)) {
249 string name = step->stringValue();
250 if (name.empty() || !scope->contains(name)) {
253 ElementPtr down = boost::const_pointer_cast<Element>(scope->get(name));
255 applyDown(path, actions, down, next);
257 }
else if (scope->getType() == Element::list) {
261 auto downs = scope->listValue();
262 if (step->getType() == Element::map) {
265 if (!key || !value || (key->getType() != Element::string)) {
268 string name = key->stringValue();
273 if (!down || (down->getType() != Element::map)) {
277 if (compare && value->equals(*compare)) {
278 applyDown(path, actions, down, next);
282 }
else if (step->getType() != Element::integer) {
285 int index = step->intValue();
288 applyDown(path, actions, down, next);
290 }
else if ((index >= 0) && (index < scope->size())) {
291 applyDown(path, actions, scope->getNonConst(index), next);
302 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.