}
void
-Element::removeEmptyContainersRecursively0(unsigned level) {
+Element::removeEmptyContainersRecursively(unsigned level) {
if (level <= 0) {
// Cycles are by definition not empty so no need to throw.
return;
// Recurse if not empty.
if (!child->empty()){
- child->removeEmptyContainersRecursively0(level - 1);
+ child->removeEmptyContainersRecursively(level - 1);
}
// When returning from recursion, remove if empty.
while (c != EOF && c != ']') {
if (in.peek() != ']') {
cur_list_element =
- Element::fromJSON0(in, file, line, pos, level - 1);
+ Element::fromJSON(in, file, line, pos, level - 1);
list->add(cur_list_element);
c = skipTo(in, file, line, pos, ",]", WHITESPACE);
} else {
// skip the :
ConstElementPtr value =
- Element::fromJSON0(in, file, line, pos, level - 1);
+ Element::fromJSON(in, file, line, pos, level - 1);
map->set(key, value);
c = skipTo(in, file, line, pos, ",}", WHITESPACE);
ElementPtr
Element::fromJSON(std::istream& in, const std::string& file, int& line,
- int& pos) {
- return (Element::fromJSON0(in, file, line, pos, Element::MAX_NESTING_LEVEL));
-}
-
-ElementPtr
-Element::fromJSON0(std::istream& in, const std::string& file, int& line,
- int& pos, unsigned level) {
+ int& pos, unsigned level) {
if (level == 0) {
isc_throw(JSONError, "fromJSON elements nested too deeply");
}
// to JSON format
void
-IntElement::toJSON(std::ostream& ss) const {
- IntElement::toJSON0(ss, 1);
-}
-
-void
-IntElement::toJSON0(std::ostream& ss, unsigned) const {
+IntElement::toJSON(std::ostream& ss, unsigned) const {
ss << intValue();
}
void
-BigIntElement::toJSON(std::ostream& ss) const {
- BigIntElement::toJSON0(ss, 1);
-}
-
-void
-BigIntElement::toJSON0(std::ostream& ss, unsigned) const {
+BigIntElement::toJSON(std::ostream& ss, unsigned) const {
ss << bigIntValue();
}
void
-DoubleElement::toJSON(std::ostream& ss) const {
- DoubleElement::toJSON0(ss, 1);
-}
-
-void
-DoubleElement::toJSON0(std::ostream& ss, unsigned) const {
+DoubleElement::toJSON(std::ostream& ss, unsigned) const {
// The default output for doubles nicely drops off trailing
// zeros, however this produces strings without decimal points
// for whole number values. When reparsed this will create
}
void
-BoolElement::toJSON(std::ostream& ss) const {
- BoolElement::toJSON0(ss, 1);
-}
-
-void
-BoolElement::toJSON0(std::ostream& ss, unsigned) const {
+BoolElement::toJSON(std::ostream& ss, unsigned) const {
if (boolValue()) {
ss << "true";
} else {
}
void
-NullElement::toJSON(std::ostream& ss) const {
- NullElement::toJSON0(ss, 1);
-}
-
-void
- NullElement::toJSON0(std::ostream& ss, unsigned) const {
+NullElement::toJSON(std::ostream& ss, unsigned) const {
ss << "null";
}
void
-StringElement::toJSON(std::ostream& ss) const {
- StringElement::toJSON0(ss, 1);
-}
-
-void
-StringElement::toJSON0(std::ostream& ss, unsigned) const {
+StringElement::toJSON(std::ostream& ss, unsigned) const {
ss << "\"";
const std::string& str = stringValue();
for (size_t i = 0; i < str.size(); ++i) {
}
void
-ListElement::toJSON(std::ostream& ss) const {
- ListElement::toJSON0(ss, Element::MAX_NESTING_LEVEL);
-}
-
-void
-ListElement::toJSON0(std::ostream& ss, unsigned level) const {
+ListElement::toJSON(std::ostream& ss, unsigned level) const {
if (level == 0) {
isc_throw(BadValue, "toJSON got infinite recursion: "
"arguments include cycles");
} else {
first = false;
}
- it->toJSON0(ss, level - 1);
+ it->toJSON(ss, level - 1);
}
ss << " ]";
}
void
-MapElement::toJSON(std::ostream& ss) const {
- MapElement::toJSON0(ss, Element::MAX_NESTING_LEVEL);
-}
-
-void
-MapElement::toJSON0(std::ostream& ss, unsigned level) const {
+MapElement::toJSON(std::ostream& ss, unsigned level) const {
if (level == 0) {
isc_throw(BadValue, "toJSON got infinite recursion: "
"arguments include cycles");
}
ss << "\"" << it.first << "\": ";
if (it.second) {
- it.second->toJSON0(ss, level - 1);
+ it.second->toJSON(ss, level - 1);
} else {
ss << "None";
}
}
bool
-IntElement::equals(const Element& other) const {
+IntElement::equals(const Element& other, unsigned) const {
// Let's not be very picky with constraining the integer types to be the
// same. Equality is sometimes checked from high-up in the Element hierarchy.
// That is a context which, most of the time, does not have information on
}
bool
-IntElement::equals0(const Element& other, unsigned) const {
- return (IntElement::equals(other));
-}
-
-bool
-BigIntElement::equals(const Element& other) const {
+BigIntElement::equals(const Element& other, unsigned) const {
// Let's not be very picky with constraining the integer types to be the
// same. Equality is sometimes checked from high-up in the Element hierarchy.
// That is a context which, most of the time, does not have information on
}
bool
-BigIntElement::equals0(const Element& other, unsigned) const {
- return (BigIntElement::equals(other));
-}
-
-bool
-DoubleElement::equals(const Element& other) const {
+DoubleElement::equals(const Element& other, unsigned) const {
return (other.getType() == Element::real) &&
(fabs(d - other.doubleValue()) < 1e-14);
}
bool
-DoubleElement::equals0(const Element& other, unsigned) const {
- return (DoubleElement::equals(other));
-}
-
-bool
-BoolElement::equals(const Element& other) const {
+BoolElement::equals(const Element& other, unsigned) const {
return (other.getType() == Element::boolean) &&
(b == other.boolValue());
}
bool
-BoolElement::equals0(const Element& other, unsigned) const {
- return (BoolElement::equals(other));
-}
-
-bool
-NullElement::equals(const Element& other) const {
+NullElement::equals(const Element& other, unsigned) const {
return (other.getType() == Element::null);
}
bool
-NullElement::equals0(const Element& other, unsigned) const {
- return (NullElement::equals(other));
-}
-
-bool
-StringElement::equals(const Element& other) const {
+StringElement::equals(const Element& other, unsigned) const {
return (other.getType() == Element::string) &&
(s == other.stringValue());
}
bool
-StringElement::equals0(const Element& other, unsigned) const {
- return (StringElement::equals(other));
-}
-
-bool
-ListElement::equals(const Element& other) const {
- return (ListElement::equals0(other, Element::MAX_NESTING_LEVEL));
-}
-
-bool
-ListElement::equals0(const Element& other, unsigned level) const {
+ListElement::equals(const Element& other, unsigned level) const {
if (level == 0) {
isc_throw(BadValue, "equals got infinite recursion: "
"arguments include cycles");
return (false);
}
for (size_t i = 0; i < s; ++i) {
- if (!get(i)->equals0(*other.get(i), level - 1)) {
+ if (!get(i)->equals(*other.get(i), level - 1)) {
return (false);
}
}
}
bool
-MapElement::equals(const Element& other) const {
- return (MapElement::equals0(other, Element::MAX_NESTING_LEVEL));
-}
-
-bool
-MapElement::equals0(const Element& other, unsigned level) const {
+MapElement::equals(const Element& other, unsigned level) const {
if (level == 0) {
isc_throw(BadValue, "equals got infinite recursion: "
"arguments include cycles");
for (auto const& kv : mapValue()) {
auto key = kv.first;
if (other.contains(key)) {
- if (!get(key)->equals0(*other.get(key), level - 1)) {
+ if (!get(key)->equals(*other.get(key), level - 1)) {
return (false);
}
} else {
void
mergeDiffAdd(ElementPtr& element, ElementPtr& other,
- HierarchyDescriptor& hierarchy, std::string key, size_t idx) {
- mergeDiffAdd0(element, other, hierarchy, key, idx,
- Element::MAX_NESTING_LEVEL);
-}
-
-void
-mergeDiffAdd0(ElementPtr& element, ElementPtr& other,
- HierarchyDescriptor& hierarchy, std::string key, size_t idx,
- unsigned level) {
+ HierarchyDescriptor& hierarchy, std::string key, size_t idx,
+ unsigned level) {
if (level == 0) {
isc_throw(BadValue, "mergeDiffAdd got infinite recursion: "
"arguments include cycles");
// entity.
if (f->second.match_(mutable_left, mutable_right)) {
found = true;
- mergeDiffAdd0(mutable_left, mutable_right, hierarchy,
- key, idx, level - 1);
+ mergeDiffAdd(mutable_left, mutable_right, hierarchy,
+ key, idx, level - 1);
}
}
if (!found) {
(value->getType() == Element::map ||
value->getType() == Element::list)) {
ElementPtr mutable_element = boost::const_pointer_cast<Element>(element->get(current_key));
- mergeDiffAdd0(mutable_element, value, hierarchy,
- current_key, idx + 1, level - 1);
+ mergeDiffAdd(mutable_element, value, hierarchy,
+ current_key, idx + 1, level - 1);
} else {
element->set(current_key, value);
}
void
mergeDiffDel(ElementPtr& element, ElementPtr& other,
- HierarchyDescriptor& hierarchy, std::string key, size_t idx) {
- mergeDiffDel0(element, other, hierarchy, key, idx,
- Element::MAX_NESTING_LEVEL);
-}
-
-void
-mergeDiffDel0(ElementPtr& element, ElementPtr& other,
- HierarchyDescriptor& hierarchy, std::string key, size_t idx,
- unsigned level) {
+ HierarchyDescriptor& hierarchy, std::string key, size_t idx,
+ unsigned level) {
if (level == 0) {
isc_throw(BadValue, "mergeDiffDel got infinite recursion: "
"arguments include cycles");
element->remove(iter);
removed = true;
} else {
- mergeDiffDel0(mutable_left, mutable_right,
- hierarchy, key, idx, level - 1);
+ mergeDiffDel(mutable_left, mutable_right,
+ hierarchy, key, idx, level - 1);
if (mutable_left->empty()) {
element->remove(iter);
removed = true;
ElementPtr mutable_element = boost::const_pointer_cast<Element>(element->get(current_key));
if (mutable_element->getType() == Element::map ||
mutable_element->getType() == Element::list) {
- mergeDiffDel0(mutable_element, value, hierarchy,
- current_key, idx + 1, level - 1);
+ mergeDiffDel(mutable_element, value, hierarchy,
+ current_key, idx + 1, level - 1);
if (mutable_element->empty()) {
element->remove(current_key);
}
void
extend(const std::string& container, const std::string& extension,
ElementPtr& element, ElementPtr& other, HierarchyDescriptor& hierarchy,
- std::string key, size_t idx, bool alter) {
- extend0(container, extension, element, other, hierarchy, key, idx, alter,
- Element::MAX_NESTING_LEVEL);
-}
-
-void
-extend0(const std::string& container, const std::string& extension,
- ElementPtr& element, ElementPtr& other, HierarchyDescriptor& hierarchy,
- std::string key, size_t idx, bool alter, unsigned level) {
+ std::string key, size_t idx, bool alter, unsigned level) {
if (level == 0) {
isc_throw(BadValue, "extend got infinite recursion: "
alter = true;
}
if (f->second.match_(mutable_left, mutable_right)) {
- extend0(container, extension, mutable_left, mutable_right,
- hierarchy, key, idx, alter, level - 1);
+ extend(container, extension, mutable_left, mutable_right,
+ hierarchy, key, idx, alter, level - 1);
}
}
}
if (container == key) {
alter = true;
}
- extend0(container, extension, mutable_element, value,
- hierarchy, current_key, idx + 1, alter, level - 1);
+ extend(container, extension, mutable_element, value,
+ hierarchy, current_key, idx + 1, alter, level - 1);
} else if (alter && current_key == extension) {
element->set(current_key, value);
}
/// @brief Test equality.
///
/// @param other The other element to compare with.
- /// @return true if the other ElementPtr has the same value and the same
- /// type (or a different and compatible type), false otherwise.
- /// @throw BadValue when there are more than MAX_NESTING_LEVEL nesting
- /// levels, e.g. when arguments contain a cycle.
- virtual bool equals(const Element& other) const = 0;
-
- /// @brief Test equality.
- ///
- /// @note: Variant with nesting depth: to be used only in tests.
- ///
- /// @param other The other element to compare with.
/// @param level The maximum level of recursion.
/// @return true if the other ElementPtr has the same value and the same
/// type (or a different and compatible type), false otherwise.
/// @throw BadValue when nesting depth is more than level.
- virtual bool equals0(const Element& other, unsigned level) const = 0;
-
- /// @brief Converts the Element to JSON format and appends it to
- /// the given output stream.
- ///
- /// @param ss The output stream where to append the JSON format.
- /// @throw BadValue when there are more than MAX_NESTING_LEVEL nesting
- /// levels, e.g. when arguments contain a cycle.
- virtual void toJSON(std::ostream& ss) const = 0;
+ virtual bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const = 0;
/// @brief Converts the Element to JSON format and appends it to
/// the given output stream.
///
- /// @note: Variant with nesting depth: to be used only in tests.
- ///
/// @param ss The output stream where to append the JSON format.
/// @param level The maximum level of recursion.
/// @throw BadValue when nesting depth is more than level.
- virtual void toJSON0(std::ostream& ss, unsigned level) const = 0;
+ virtual void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const = 0;
/// @name Type-specific getters
///
/// track of the current line.
/// @param pos A reference to the int where the function keeps
/// track of the current position within the current line.
+ /// @param level The maximum level of recursion.
/// @return An ElementPtr that contains the element(s) specified
/// in the given input stream.
// make this one private?
/// @throw JSONError
static ElementPtr fromJSON(std::istream& in, const std::string& file,
- int& line, int &pos);
+ int& line, int &pos,
+ unsigned level = MAX_NESTING_LEVEL);
/// @brief Creates an Element from the given input stream.
///
/// track of the current line.
/// @param pos A reference to the int where the function keeps
/// track of the current position within the current line.
- /// @param level The maximum level of recursion.
+
/// @return An ElementPtr that contains the element(s) specified
/// in the given input stream.
/// @throw JSONError
- static ElementPtr fromJSON0(std::istream& in, const std::string& file,
- int& line, int &pos, unsigned level);
/// Reads contents of specified file and interprets it as JSON.
///
/// @brief Remove all empty maps and lists from this Element and its
/// descendants.
- void removeEmptyContainersRecursively() {
- removeEmptyContainersRecursively0(MAX_NESTING_LEVEL);
- }
-
-protected:
- /// Converts the Element to JSON format and appends it to
- /// the given stringstream.
-
- /// @brief Remove all empty maps and lists from this Element and its
- /// descendants.
+ ///
/// @param level nesting level.
- void removeEmptyContainersRecursively0(unsigned level);
+ void removeEmptyContainersRecursively(unsigned level = MAX_NESTING_LEVEL);
};
/// Notes: IntElement type is changed to int64_t.
bool getValue(int64_t& t) const { t = i; return (true); }
using Element::setValue;
bool setValue(long long int v) { i = v; return (true); }
- void toJSON(std::ostream& ss) const;
- bool equals(const Element& other) const;
- void toJSON0(std::ostream& ss, unsigned) const;
- bool equals0(const Element& other, unsigned) const;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const;
};
/// @brief Wrapper over int128_t
/// stringstream.
///
/// @param ss The output stream where to append the JSON format.
- void toJSON(std::ostream& ss) const override;
-
- /// @brief Converts the Element to JSON format and appends it to the given
- /// stringstream.
- ///
- /// @note: Variant with nesting depth: to be used only in tests.
- /// @param ss The output stream where to append the JSON format.
/// @param level The maximum level of recursion. Ignored.
- void toJSON0(std::ostream& ss, unsigned level) const override;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const override;
/// @brief Checks whether the other Element is equal.
///
/// @param other The other element to compare with.
- /// @return true if the other ElementPtr has the same value and the same
- /// type (or a different and compatible type), false otherwise.
- bool equals(const Element& other) const override;
-
- /// @brief Checks whether the other Element is equal.
- ///
- /// @note: Variant with nesting depth: to be used only in tests.
- ///
- /// @param other The other element to compare with.
/// @param level The maximum level of recursion. Ignored.
/// @return true if the other ElementPtr has the same value and the same
/// type (or a different and compatible type), false otherwise.
- bool equals0(const Element& other, unsigned level) const override;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const override;
private:
/// @brief the underlying stored value
bool getValue(double& t) const { t = d; return (true); }
using Element::setValue;
bool setValue(const double v) { d = v; return (true); }
- void toJSON(std::ostream& ss) const;
- bool equals(const Element& other) const;
- void toJSON0(std::ostream& ss, unsigned) const;
- bool equals0(const Element& other, unsigned) const;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const;
};
class BoolElement : public Element {
bool getValue(bool& t) const { t = b; return (true); }
using Element::setValue;
bool setValue(const bool v) { b = v; return (true); }
- void toJSON(std::ostream& ss) const;
- bool equals(const Element& other) const;
- void toJSON0(std::ostream& ss, unsigned) const;
- bool equals0(const Element& other, unsigned) const;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const;
};
class NullElement : public Element {
public:
NullElement(const Position& pos = ZERO_POSITION())
: Element(null, pos) {}
- void toJSON(std::ostream& ss) const;
- bool equals(const Element& other) const;
- void toJSON0(std::ostream& ss, unsigned) const;
- bool equals0(const Element& other, unsigned) const;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const;
};
class StringElement : public Element {
bool getValue(std::string& t) const { t = s; return (true); }
using Element::setValue;
bool setValue(const std::string& v) { s = v; return (true); }
- void toJSON(std::ostream& ss) const;
- bool equals(const Element& other) const;
- void toJSON0(std::ostream& ss, unsigned) const;
- bool equals0(const Element& other, unsigned) const;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const;
};
class ListElement : public Element {
void add(ElementPtr e) { l.push_back(e); }
using Element::remove;
void remove(int i) { l.erase(l.begin() + i); }
- void toJSON(std::ostream& ss) const;
- void toJSON0(std::ostream& ss, unsigned level) const;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const;
size_t size() const { return (l.size()); }
bool empty() const { return (l.empty()); }
- bool equals(const Element& other) const;
- bool equals0(const Element& other, unsigned level) const;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const;
/// @brief Sorts the elements inside the list.
///
bool contains(const std::string& s) const override {
return (m.find(s) != m.end());
}
- void toJSON(std::ostream& ss) const override;
- void toJSON0(std::ostream& ss, unsigned level) const override;
+ void toJSON(std::ostream& ss,
+ unsigned level = MAX_NESTING_LEVEL) const override;
// we should name the two finds better...
// find the element at id; raises TypeError if one of the
return (m.size());
}
- bool equals(const Element& other) const override;
- bool equals0(const Element& other, unsigned level) const override;
+ bool equals(const Element& other,
+ unsigned level = MAX_NESTING_LEVEL) const override;
bool empty() const override { return (m.empty()); }
};
/// identification keys.
/// @param key The container holding the current element.
/// @param idx The level inside the hierarchy the current element is located.
+/// @param level The maximum level of recursion.
/// @throw TypeError if elements are not the same Element type.
void mergeDiffAdd(ElementPtr& element, ElementPtr& other,
HierarchyDescriptor& hierarchy, std::string key,
- size_t idx = 0);
-
-/// @brief Merges the diff data by adding the missing elements from 'other'
-/// to 'element' (recursively). Both elements must be the same Element type.
-///
-/// @note: Variant with nesting depth: to be used only in tests.
-///
-/// @param element The element to which new data is added.
-/// @param other The element containing the data which needs to be added.
-/// @param hierarchy The hierarchy describing the elements relations and
-/// identification keys.
-/// @param key The container holding the current element.
-/// @param idx The level inside the hierarchy the current element is located.
-/// @param level The maximum level of recursion.
-/// @throw TypeError if elements are not the same Element type.
-void mergeDiffAdd0(ElementPtr& element, ElementPtr& other,
- HierarchyDescriptor& hierarchy, std::string key,
- size_t idx, unsigned level);
+ size_t idx = 0, unsigned level = Element::MAX_NESTING_LEVEL);
/// @brief Merges the diff data by removing the data present in 'other' from
/// 'element' (recursively). Both elements must be the same Element type.
/// identification keys.
/// @param key The container holding the current element.
/// @param idx The level inside the hierarchy the current element is located.
+/// @param level The maximum level of recursion.
/// @throw TypeError if elements are not the same Element type.
void mergeDiffDel(ElementPtr& element, ElementPtr& other,
HierarchyDescriptor& hierarchy, std::string key,
- size_t idx = 0);
-/// @brief Merges the diff data by removing the data present in 'other' from
-/// 'element' (recursively). Both elements must be the same Element type.
-///
-/// @note: Variant with nesting depth: to be used only in tests.
-///
-/// @param element The element from which new data is removed.
-/// @param other The element containing the data which needs to be removed.
-/// @param hierarchy The hierarchy describing the elements relations and
-/// identification keys.
-/// @param key The container holding the current element.
-/// @param idx The level inside the hierarchy the current element is located.
-/// @param level The maximum level of recursion.
-/// @throw TypeError if elements are not the same Element type.
-void mergeDiffDel0(ElementPtr& element, ElementPtr& other,
- HierarchyDescriptor& hierarchy, std::string key,
- size_t idx, unsigned level);
+ size_t idx = 0, unsigned level = Element::MAX_NESTING_LEVEL);
/// @brief Extends data by adding the specified 'extension' elements from
/// 'other' inside the 'container' element (recursively). Both elements must be
/// @param idx The level inside the hierarchy the current element is located.
/// @param alter The flag which indicates if the current element should be
/// updated.
+/// @param level The maximum level of recursion.
/// @throw TypeError if elements are not the same Element type.
void extend(const std::string& container, const std::string& extension,
ElementPtr& element, ElementPtr& other,
HierarchyDescriptor& hierarchy, std::string key, size_t idx = 0,
- bool alter = false);
-
-/// @brief Extends data by adding the specified 'extension' elements from
-/// 'other' inside the 'container' element (recursively). Both elements must be
-/// the same Element type.
-///
-/// @note: Variant with nesting depth: to be used only in tests.
-///
-/// @param container The container holding the data that must be extended.
-/// @param extension The name of the element that contains the data that must be
-/// added (if not already present) in order to extend the initial data.
-/// @param element The element from which new data is added.
-/// @param other The element containing the data which needs to be added.
-/// @param hierarchy The hierarchy describing the elements relations and
-/// identification keys.
-/// @param key The container holding the current element.
-/// @param idx The level inside the hierarchy the current element is located.
-/// @param alter The flag which indicates if the current element should be
-/// updated.
-/// @param level The maximum level of recursion.
-/// @throw TypeError if elements are not the same Element type.
-void extend0(const std::string& container, const std::string& extension,
- ElementPtr& element, ElementPtr& other,
- HierarchyDescriptor& hierarchy, std::string key, size_t idx,
- bool alter, unsigned level);
+ bool alter = false, unsigned level = Element::MAX_NESTING_LEVEL);
/// @brief Copy the data up to a nesting level.
///
right->set("other", right_other_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
// Uses 2 levels of nesting so throw with 1 (and pass with 2 or more).
- EXPECT_THROW(mergeDiffAdd0(left, right, hierarchy, "root", 0, 1),
+ EXPECT_THROW(mergeDiffAdd(left, right, hierarchy, "root", 0, 1),
isc::BadValue);
}
{
right_right->set("other", right_other_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
// Uses 3 levels of nesting so throw with 2 (and pass with 3 or more).
- EXPECT_THROW(mergeDiffAdd0(left, right, hierarchy, "root", 0, 2),
+ EXPECT_THROW(mergeDiffAdd(left, right, hierarchy, "root", 0, 2),
isc::BadValue);
}
}
// list element which is updated
right->set("other", right_other_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
- ASSERT_NO_THROW(mergeDiffAdd0(left, right, hierarchy, "root", 0, 2));
+ ASSERT_NO_THROW(mergeDiffAdd(left, right, hierarchy, "root", 0, 2));
std::string expected_str("{ \"elements\": { \"elements\": \"right\", \"id\": 0, \"new-elements\": \"new\", \"other-elements\": \"other\" }, "
"\"left-other-elements\": { \"elements\": \"other-left\", \"id\": 1 }, "
"\"other\": [ \"left-other-left\", \"left-other-left-other\", \"other-other\", \"right-other-right\", \"right-other-right-other\", \"other-other\" ], "
// list element which is updated
right_right->set("other", right_other_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
- ASSERT_NO_THROW(mergeDiffAdd0(left, right, hierarchy, "root", 0, 3));
+ ASSERT_NO_THROW(mergeDiffAdd(left, right, hierarchy, "root", 0, 3));
std::string expected_str("[ { \"elements\": \"right\", \"id\": 0, \"new-elements\": \"new\", "
"\"other\": [ \"left-other-left\", \"left-other-left-other\", \"other-other\", \"right-other-right\", \"right-other-right-other\", \"other-other\" ], "
"\"other-elements\": \"other\" }, "
right->set("elements-other", right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
// Uses 2 levels of nesting so throw with 1 (and pass with 2 or more).
- EXPECT_THROW(mergeDiffDel0(left, right, hierarchy, "root", 0, 1),
+ EXPECT_THROW(mergeDiffDel(left, right, hierarchy, "root", 0, 1),
isc::BadValue);
}
{
right->add(right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
// Uses 3 levels of nesting so throw with 2 (and pass with 3 or more).
- EXPECT_THROW(mergeDiffDel0(left, right, hierarchy, "root", 0, 2),
+ EXPECT_THROW(mergeDiffDel(left, right, hierarchy, "root", 0, 2),
isc::BadValue);
}
}
// the key can not be removed
right->set("elements-other", right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
- ASSERT_NO_THROW(mergeDiffDel0(left, right, hierarchy, "root", 0, 2));
+ ASSERT_NO_THROW(mergeDiffDel(left, right, hierarchy, "root", 0, 2));
std::string expected_str("{ \"elements\": { \"id\": 0, \"other-elements\": \"other\" }, "
"\"elements-other\": { \"elements\": \"new-left\", \"id\": 3, \"other-elements\": \"new-other\" }, "
"\"left-other-elements\": { \"elements\": \"other-left\", \"id\": 1 }, "
// the key can not be removed
right->add(right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
- ASSERT_NO_THROW(mergeDiffDel0(left, right, hierarchy, "root", 0, 3));
+ ASSERT_NO_THROW(mergeDiffDel(left, right, hierarchy, "root", 0, 3));
std::string expected_str("[ { \"id\": 0, \"other\": [ \"left-other-left\", \"left-other-left-other\" ], \"other-elements\": \"other\" }, "
"{ \"elements\": \"other-left\", \"id\": 1 } ]");
ElementPtr expected = Element::fromJSON(expected_str);
right->set("elements", right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
// Uses 2 levels of nesting so throw with 1 (and pass with 2 or more).
- EXPECT_THROW(extend0("root", "new-elements", left, right, hierarchy,
- "root", 0, false, 1), isc::BadValue);
+ EXPECT_THROW(extend("root", "new-elements", left, right, hierarchy,
+ "root", 0, false, 1), isc::BadValue);
}
{
SCOPED_TRACE("nested list");
right->add(right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
// Uses 2 levels of nesting so throw with 1 (and pass with 2 or more).
- EXPECT_THROW(extend0("root", "new-elements", left, right, hierarchy,
- "root", 0, false, 1), isc::BadValue);
+ EXPECT_THROW(extend("root", "new-elements", left, right, hierarchy,
+ "root", 0, false, 1), isc::BadValue);
}
}
// map element which is used for extension
right->set("elements", right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
- ASSERT_NO_THROW(extend0("root", "new-elements", left, right, hierarchy,
- "root", 0, false, 2));
+ ASSERT_NO_THROW(extend("root", "new-elements", left, right, hierarchy,
+ "root", 0, false, 2));
std::string expected_str("{ \"elements\": { \"elements\": \"left\", \"id\": 0, \"new-elements\": \"new\", \"other-elements\": \"other\" } }");
ElementPtr expected = Element::fromJSON(expected_str);
EXPECT_TRUE(isc::data::isEquivalent(left, expected))
// map element which is used for extension
right->add(right_right);
ASSERT_FALSE(isc::data::isEquivalent(left, right));
- ASSERT_NO_THROW(extend0("root", "new-elements", left, right, hierarchy,
- "root", 0, false, 2));
+ ASSERT_NO_THROW(extend("root", "new-elements", left, right, hierarchy,
+ "root", 0, false, 2));
std::string expected_str("[ { \"elements\": \"left\", \"id\": 0, \"new-elements\": \"new\", \"other-elements\": \"other\" } ]");
ElementPtr expected = Element::fromJSON(expected_str);
EXPECT_TRUE(isc::data::isEquivalent(left, expected))
try {
int l = 1;
int p = 1;
- ElementPtr list = Element::fromJSON0(ss, "sss", l, p, max_level);
+ ElementPtr list = Element::fromJSON(ss, "sss", l, p, max_level);
EXPECT_TRUE(isEquivalent(list, expected));
} catch (const JSONError&) {
EXPECT_EQ(max_level, level);
try {
int l = 1;
int p = 1;
- ElementPtr map = Element::fromJSON0(ss, "sss", l, p, max_level);
+ ElementPtr map = Element::fromJSON(ss, "sss", l, p, max_level);
EXPECT_TRUE(isEquivalent(map, expected));
} catch (const JSONError&) {
EXPECT_EQ(max_level, level);