8#include <boost/foreach.hpp>
34 result =
copy(context);
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);
105 string name = key->stringValue();
106 if (!name.empty() && !scope->contains(name)) {
107 scope->set(name,
copy(value));
111 scope->add(
copy(value));
130 string name = key->stringValue();
132 scope->set(name,
copy(value));
153 string name = key->stringValue();
161 int index = key->intValue();
162 if ((index >= 0) && (index < scope->size())) {
163 scope->remove(index);
171 string name = entry->stringValue();
175 for (
int i = 0; i < scope->size(); ++i) {
181 if (compare && value->equals(*compare)) {
199 if (next == actions->size()) {
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);
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);
261 auto downs = scope->listValue();
268 string name = key->stringValue();
277 if (compare && value->equals(*compare)) {
278 applyDown(path, actions, down, next);
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);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static void fromParent(const std::string &name, isc::data::ConstElementPtr parent, isc::data::ConstElementPtr list)
Moves a parameter from parent to a list of children.
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
static void toParent(const std::string &name, isc::data::ElementPtr parent, isc::data::ConstElementPtr list)
Moves a parameter to a parent.
virtual ~Adaptor()
Destructor.
static void modify(isc::data::ConstElementPtr path, isc::data::ConstElementPtr actions, isc::data::ElementPtr config)
Modify a configuration in its JSON element format.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
Defines the logger used by the top-level component of kea-dhcp-ddns.