/// the type in question.
///
class Element {
-
+
private:
// technically the type could be omitted; is it useful?
// should we remove it or replace it with a pure virtual
/// \returns true if the other ElementPtr has the same type and
/// value
virtual bool equals(const Element& other) const = 0;
-
+
/// Converts the Element to JSON format and appends it to
/// the given stringstream.
virtual void toJSON(std::ostream& ss) const = 0;
virtual size_t size() const;
//@}
-
+
/// \name MapElement functions
///
/// \brief If the Element on which these functions are called are not
/// \name Factory functions
-
+
// TODO: should we move all factory functions to a different class
// so as not to burden the Element base with too many functions?
// and/or perhaps even to a separate header?
/// These function pparse the wireformat at the given stringstream
/// (of the given length). If there is a parse error an exception
/// of the type isc::cc::DecodeError is raised.
-
+
//@{
/// Creates an Element from the wire format in the given
/// stringstream of the given length.
return (m.find(s) != m.end());
}
void toJSON(std::ostream& ss) const;
-
+
// we should name the two finds better...
// find the element at id; raises TypeError if one of the
// elements at path except the one we're looking for is not a
} }
#endif // _ISC_DATA_H
-// Local Variables:
+// Local Variables:
// mode: c++
-// End:
+// End:
std::string s = std::string(pe.what());
EXPECT_EQ("String expected in <string>:1:3", s);
}
-
+
sv.clear();
sv.push_back("{1}");
//ElementPtr ep = Element::fromJSON("\"aaa\nbbb\"err");
EXPECT_THROW(el->contains("foo"), TypeError);
ConstElementPtr tmp;
EXPECT_FALSE(el->find("foo", tmp));
-
+
el = Element::create(1.1);
EXPECT_THROW(el->intValue(), TypeError);
// this function checks the specific functions for ListElements
ElementPtr el = Element::fromJSON("{ \"name\": \"foo\", \"value1\": \"bar\", \"value2\": { \"number\": 42 } }");
ConstElementPtr el2;
-
+
EXPECT_EQ(el->get("name")->stringValue(), "foo");
EXPECT_EQ(el->get("value2")->getType(), Element::map);
EXPECT_EQ(el->find("value2/number")->intValue(), 42);
EXPECT_TRUE(isNull(el->find("value2/nothing/")));
-
+
EXPECT_EQ(el->find("value1")->stringValue(), "bar");
EXPECT_EQ(el->find("value1/")->stringValue(), "bar");
-
+
EXPECT_TRUE(el->find("value1", el2));
EXPECT_EQ("bar", el2->stringValue());
EXPECT_FALSE(el->find("name/error", el2));
"9123456789abcdefa123456789abcdefb123456789abcdef"
"c123456789abcdefd123456789abcdefe123456789abcdef"
"f123456789abcde");
-
+
EXPECT_EQ(255, long_maptag.length()); // check prerequisite
el = Element::fromJSON("{ \"" + long_maptag + "\": \"bar\"}");
EXPECT_EQ("bar", el->find(long_maptag)->stringValue());
c = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
merge(b, a);
EXPECT_EQ(*b, *c);
-
+
// And some tests with multiple values
a = Element::fromJSON("{ \"a\": 1, \"b\": true, \"c\": null }");
b = Element::fromJSON("{ \"a\": 1, \"b\": null, \"c\": \"a string\" }");