28 result =
copy(context);
30 result = Element::createMap();
32 result->set(
"comment", comment);
43 for (
ElementPtr const& item : list->listValue()) {
45 if (item->contains(name)) {
48 item->set(name, param);
57 for (
ElementPtr const& item : list->listValue()) {
60 param = item->get(name);
61 }
else if ((!param && item->contains(name)) ||
62 (param && !item->contains(name)) ||
63 (param && item->contains(name) &&
64 !param->equals(*item->get(name)))) {
66 "inconsistent value of " << name
67 <<
" in " << list->str());
70 if (!first && param) {
71 for (
ElementPtr const& item : list->listValue()) {
76 parent->set(name, param);
95 if (scope->getType() == Element::map) {
96 if (!key || !value || (key->getType() != Element::string)) {
99 string name = key->stringValue();
100 if (!name.empty() && !scope->contains(name)) {
101 scope->set(name,
copy(value));
103 }
else if (scope->getType() == Element::list) {
105 scope->add(
copy(value));
120 if ((scope->getType() != Element::map) ||
121 !key || !value || (key->getType() != Element::string)) {
124 string name = key->stringValue();
126 scope->set(name,
copy(value));
143 if (scope->getType() == Element::map) {
144 if (!key || (key->getType() != Element::string)) {
147 string name = key->stringValue();
151 }
else if (scope->getType() == Element::list) {
154 }
else if (key->getType() == Element::integer) {
155 int index = key->intValue();
156 if ((index >= 0) && (index < scope->size())) {
157 scope->remove(index);
159 }
else if (key->getType() == Element::map) {
162 if (!entry || !value || (entry->getType() != Element::string)) {
165 string name = entry->stringValue();
169 for (
int i = 0; i < scope->size(); ++i) {
171 if (!item || (item->getType() != Element::map)) {
175 if (compare && value->equals(*compare)) {
193 if (next == actions->size()) {
198 if (!action || (action->getType() != Element::map) ||
199 !action->contains(
"action")) {
200 applyAction(actions, scope, next);
203 string name = action->get(
"action")->stringValue();
204 if (name ==
"insert") {
205 applyInsert(action->get(
"key"), action->get(
"value"), scope);
206 }
else if (name ==
"replace") {
207 applyReplace(action->get(
"key"), action->get(
"value"), scope);
208 }
else if (name ==
"delete") {
209 applyDelete(action->get(
"key"), scope);
211 applyAction(actions, scope, next);
233 if (next == path->size()) {
234 applyAction(actions, scope, 0);
239 if (scope->getType() == Element::map) {
240 if (!step || (step->getType() != Element::string)) {
243 string name = step->stringValue();
244 if (name.empty() || !scope->contains(name)) {
250 applyDown(path, actions, mutable_down, next);
251 scope->set(name, mutable_down);
253 }
else if (scope->getType() == Element::list) {
257 auto downs = scope->listValue();
258 if (step->getType() == Element::map) {
261 if (!key || !value || (key->getType() != Element::string)) {
264 string name = key->stringValue();
269 if (!down || (down->getType() != Element::map)) {
273 if (compare && value->equals(*compare)) {
274 applyDown(path, actions, down, next);
278 }
else if (step->getType() != Element::integer) {
281 int index = step->intValue();
284 applyDown(path, actions, down, next);
286 }
else if ((index >= 0) && (index < scope->size())) {
287 applyDown(path, actions, scope->getNonConst(index), next);
298 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 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.
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-lfc.