11#include <boost/lexical_cast.hpp> 
   26    for (
auto const& name : required) {
 
   27        if (scope->contains(name)) {
 
 
   38    for (
auto const& entry : scope->mapValue()) {
 
   39        if (keywords.count(entry.first) == 0) {
 
   40            if (spurious.empty()) {
 
   41                spurious = entry.first;
 
   47            (entry.second->getType() == expected)) {
 
   54    if (!spurious.empty()) {
 
 
   64                  "missing parameter '" << name << 
"' (" 
   65                  << scope->getPosition() << 
")");
 
   69                  "invalid type specified for parameter '" << name
 
   70                  << 
"' (" << x->getPosition() << 
")");
 
   73    return (x->stringValue());
 
 
   81                  "missing parameter '" << name << 
"' (" 
   82                  << scope->getPosition() << 
")");
 
   86                  "invalid type specified for parameter '" << name
 
   87                  << 
"' (" << x->getPosition() << 
")");
 
   90    return (x->intValue());
 
 
   95                         int64_t min, int64_t max) {
 
   97    if (tmp < min || tmp > max) {
 
   99                  "The '" << name << 
"' value (" << tmp
 
  100                  << 
") is not within expected range: (" << min << 
" - " << max
 
 
  112                  "missing parameter '" << name << 
"' (" 
  113                  << scope->getPosition() << 
")");
 
  117                  "invalid type specified for parameter '" << name
 
  118                  << 
"' (" << x->getPosition() << 
")");
 
  121    return (x->boolValue());
 
 
  126                         const std::string& name) {
 
  130    } 
catch (
const std::exception& e) {
 
  132                  << 
"' to address: " << e.what() << 
"(" 
 
  139                        const std::string& name) {
 
  143                  "missing parameter '" << name << 
"' (" 
  144                  << scope->getPosition() << 
")");
 
  149                  "invalid type specified for parameter '" << name
 
  150                  << 
"' (" << x->getPosition() << 
")");
 
  153    return (x->doubleValue());
 
 
  164        return (parent->getPosition());
 
  167    return (elem->getPosition());
 
 
  180    for (
auto const& def_value : default_values) {
 
  192        switch (def_value.type_) {
 
  199                int int_value = boost::lexical_cast<int>(def_value.value_);
 
  202            catch (
const std::exception& ex) {
 
  204                                    << def_value.name_ << 
", value is: " 
  205                                    << def_value.value_ );
 
  212            if (def_value.value_ == 
string(
"true")) {
 
  214            } 
else if (def_value.value_ == 
string(
"false")) {
 
  218                          "Internal error. Boolean value specified as " 
  219                          << def_value.value_ << 
", expected true or false");
 
  225            double dbl_value = boost::lexical_cast<double>(def_value.value_);
 
  232                      "Internal error. Incorrect default value type.");
 
  236        scope->set(def_value.name_, x);
 
 
  247    for (
auto const& entry : list->listValue()) {
 
 
  263    for (
auto const& param : params) {
 
  271        if (child->get(param)) {
 
  278        child->set(param, x);
 
 
  287                              const std::string& name) {
 
  290    bool has_value = 
false;
 
  291    uint32_t min_value = 0;
 
  292    bool has_min = 
false;
 
  293    uint32_t max_value = 0;
 
  294    bool has_max = 
false;
 
  295    if (scope->contains(name)) {
 
  299    if (scope->contains(
"min-" + name)) {
 
  303    if (scope->contains(
"max-" + name)) {
 
  307    if (!has_value && !has_min && !has_max) {
 
  311        if (!has_min && !has_max) {
 
  315        } 
else if (!has_min) {
 
  318        } 
else if (!has_max) {
 
  322    } 
else if (has_min) {
 
  326            max_value = min_value;
 
  330                      << name << 
" but no " << name << 
" (default) in " 
  331                      << scope->getPosition());
 
  335        min_value = max_value;
 
  339    if (min_value > max_value) {
 
  340        if (has_min && has_max) {
 
  342                      << min_value << 
") is not less than max-" << name << 
" (" 
  343                      << max_value << 
")");
 
  344        } 
else if (has_min) {
 
  347                      << min_value << 
") is not less than (default) " << name
 
  348                      << 
" (" << value << 
")");
 
  352                      << 
" (" << value << 
") is not less than max-" << name
 
  353                      << 
" (" << max_value << 
")");
 
  357    if ((value < min_value) || (value > max_value)) {
 
  359                  << value << 
") is not between min-" << name << 
" (" 
  360                  << min_value << 
") and max-" << name << 
" (" 
  361                  << max_value << 
")");
 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
The IOAddress class represents an IP addresses (version agnostic)
static std::string typeToName(Element::types type)
Returns the name of the given type as a string.
static const Position & ZERO_POSITION()
Returns Position object with line_ and pos_ set to 0, and with an empty file name.
types
The types that an Element can hold.
Notes: IntElement type is changed to int64_t.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
static size_t setListDefaults(isc::data::ConstElementPtr list, const SimpleDefaults &default_values)
Sets the default values for all entries in a list.
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
static double getDouble(const ConstElementPtr &scope, const std::string &name)
Returns a floating point parameter from a scope.
static void checkRequired(const SimpleRequiredKeywords &required, isc::data::ConstElementPtr scope)
Checks that all required keywords are present.
static isc::asiolink::IOAddress getAddress(const ConstElementPtr &scope, const std::string &name)
Returns a IOAddress parameter from a scope.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
const isc::util::Triplet< uint32_t > parseIntTriplet(const data::ConstElementPtr &scope, const std::string &name)
Parses an integer triplet.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
static size_t deriveParams(isc::data::ConstElementPtr parent, isc::data::ElementPtr child, const ParamsList ¶ms)
Derives (inherits) parameters from parent scope to a child.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
static size_t setDefaults(isc::data::ElementPtr scope, const SimpleDefaults &default_values)
Sets the default values.
To be removed. Please use ConfigError instead.
This template specifies a parameter value.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::vector< std::string > SimpleRequiredKeywords
This specifies all required keywords.
std::vector< std::string > ParamsList
This defines a list of all parameters that are derived (or inherited) between contexts.
boost::shared_ptr< const Element > ConstElementPtr
std::vector< SimpleDefault > SimpleDefaults
This specifies all default values in a given scope (e.g. a subnet).
boost::shared_ptr< Element > ElementPtr
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
Defines the logger used by the top-level component of kea-lfc.
Represents the position of the data element within a configuration string.