Commit f3a880b0 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[5019] SimpleParser methods are now public (used in global parsers)

parent 80257db8
......@@ -19,10 +19,12 @@ std::string
SimpleParser::getString(isc::data::ConstElementPtr scope, const std::string& name) {
ConstElementPtr x = scope->get(name);
if (!x) {
isc_throw(BadValue, "Element " << name << " not found");
isc_throw(BadValue, "String parameter " << name << " not found"
<< "(" << scope->getPosition() << ")");
}
if (x->getType() != Element::string) {
isc_throw(BadValue, "Element " << name << " found, but is not a string");
isc_throw(BadValue, "Element " << name << " found, but is not a string"
<< "(" << x->getPosition() << ")");
}
return (x->stringValue());
......@@ -32,10 +34,12 @@ int64_t
SimpleParser::getInteger(isc::data::ConstElementPtr scope, const std::string& name) {
ConstElementPtr x = scope->get(name);
if (!x) {
isc_throw(BadValue, "Element " << name << " not found");
isc_throw(BadValue, "Integer parameter " << name << " not found "
<< "(" << scope->getPosition() << ")");
}
if (x->getType() != Element::integer) {
isc_throw(BadValue, "Element " << name << " found, but is not an integer");
isc_throw(BadValue, "Element " << name << " found, but is not an integer"
<< "(" << x->getPosition() << ")");
}
return (x->intValue());
......@@ -45,10 +49,13 @@ bool
SimpleParser::getBoolean(isc::data::ConstElementPtr scope, const std::string& name) {
ConstElementPtr x = scope->get(name);
if (!x) {
isc_throw(BadValue, "Element " << name << " not found");
isc_throw(BadValue, "Boolean element " << name << " not found "
<< "(" << scope->getPosition() << ")");
}
if (x->getType() != Element::boolean) {
isc_throw(BadValue, "Element " << name << " found, but is not a boolean");
isc_throw(BadValue, "Element " << name << " found, but is not a boolean"
<< "(" << x->getPosition() << ")");
}
return (x->boolValue());
......
......@@ -113,8 +113,6 @@ class SimpleParser {
static const data::Element::Position&
getPosition(const std::string& name, const data::ConstElementPtr parent);
protected:
/// @brief Returns a string parameter from a scope
///
/// Unconditionally returns a parameter. If the parameter is not there or
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment