![]() |
Kea 3.1.5
|
The Element class represents a piece of data, used by the command channel and configuration parts.
More...
#include <data.h>
Inheritance diagram for isc::data::Element:Classes | |
| struct | Position |
| Represents the position of the data element within a configuration string. More... | |
Public Types | |
| enum | types : uint16_t { integer = 0 , real = 1 , boolean = 2 , null = 3 , string = 4 , bigint = 5 , list = 6 , map = 7 , any = 8 } |
| The types that an Element can hold. More... | |
Public Member Functions | |
| virtual | ~Element () |
| const Position & | getPosition () const |
| Returns position where the data element's value starts in a configuration string. | |
| types | getType () const |
| std::string | str () const |
| Returns a string representing the Element and all its child elements. | |
| std::string | toWire () const |
| Returns the wireformat for the Element and all its child elements. | |
| void | toWire (std::ostream &out) const |
| Appends the wireformat for the Element to the stream. | |
pure virtuals, every derived class must implement these. | |
| virtual bool | equals (const Element &other, unsigned level=MAX_NESTING_LEVEL) const =0 |
| Test equality. | |
| virtual void | toJSON (std::ostream &ss, unsigned level=MAX_NESTING_LEVEL) const =0 |
| Converts the Element to JSON format and appends it to the given output stream. | |
Type-specific getters | |
These functions only work on their corresponding Element type. For all other types, a TypeError is thrown. If you want an exception-safe getter method, use getValue() below | |
| virtual int64_t | intValue () const |
| Return the integer value. | |
| virtual isc::util::int128_t | bigIntValue () const |
| Return the big integer value. | |
| virtual double | doubleValue () const |
| Return the double value. | |
| virtual bool | boolValue () const |
| Return the boolean value. | |
| virtual std::string | stringValue () const |
| Return the string value. | |
| virtual const std::vector< ElementPtr > & | listValue () const |
| Return the list value. | |
| virtual const std::map< std::string, ConstElementPtr > & | mapValue () const |
| Return the map value. | |
Exception-safe getters | |
The getValue() functions return false if the given reference is of another type than the element contains By default it always returns false; the derived classes override the function for their type, copying their data to the given reference and returning true | |
| virtual bool | getValue (int64_t &t) const |
| Get the integer value. | |
| virtual bool | getValue (double &t) const |
| Get the double value. | |
| virtual bool | getValue (bool &t) const |
| Get the boolean value. | |
| virtual bool | getValue (std::string &t) const |
| Get the string value. | |
| virtual bool | getValue (std::vector< ElementPtr > &t) const |
| Get the list value. | |
| virtual bool | getValue (std::map< std::string, ConstElementPtr > &t) const |
| Get the map value. | |
Exception-safe setters. | |
Return false if the Element is not the right type. Set the value and return true if the Elements is of the correct type Notes: Read notes of IntElement definition about the use of long long int, long int and int. | |
| virtual bool | setValue (const long long int v) |
| Set the integer value. | |
| virtual bool | setValue (const isc::util::int128_t &v) |
| Set the big integer value. | |
| virtual bool | setValue (const double v) |
| Set the double value. | |
| virtual bool | setValue (const bool t) |
| Set the boolean value. | |
| virtual bool | setValue (const std::string &v) |
| Set the string value. | |
| virtual bool | setValue (const std::vector< ElementPtr > &v) |
| Set the list value. | |
| virtual bool | setValue (const std::map< std::string, ConstElementPtr > &v) |
| Set the map value. | |
| bool | setValue (const long int i) |
| Set the integer value (long int overload). | |
| bool | setValue (const int i) |
| Set the integer value (int overload). | |
ListElement functions. | |
If the Element on which these functions are called are not an instance of ListElement, a TypeError exception is thrown. | |
| virtual ConstElementPtr | get (const int i) const |
| Returns the ElementPtr at the given index. | |
| virtual ElementPtr | getNonConst (const int i) const |
| returns element as non-const pointer. | |
| virtual void | set (const size_t i, ElementPtr element) |
| Sets the ElementPtr at the given index. | |
| virtual void | add (ElementPtr element) |
| Adds an ElementPtr to the list. | |
| virtual void | remove (const int i) |
| Removes the element at the given position. | |
| virtual size_t | size () const |
| Returns the number of elements in the list. | |
| virtual bool | empty () const |
| Return true if there are no elements in the list. | |
MapElement functions | |
If the Element on which these functions are called are not an instance of MapElement, a TypeError exception is thrown. | |
| virtual ConstElementPtr | get (const std::string &name) const |
| Returns the ElementPtr at the given key. | |
| virtual void | set (const std::string &name, ConstElementPtr element) |
| Sets the ElementPtr at the given key. | |
| virtual void | remove (const std::string &name) |
| Remove the ElementPtr at the given key. | |
| virtual bool | contains (const std::string &name) const |
| Checks if there is data at the given key. | |
| virtual ConstElementPtr | find (const std::string &identifier) const |
| Recursively finds any data at the given identifier. | |
| virtual bool | find (const std::string &identifier, ConstElementPtr &t) const |
See Element::find() | |
Static Public Member Functions | |
| static const Position & | ZERO_POSITION () |
Returns Position object with line_ and pos_ set to 0, and with an empty file name. | |
Direct factory functions | |
These functions simply wrap the given data directly in an Element object, and return a reference to it, in the form of an These factory functions are exception-free (unless there is no memory available, in which case bad_alloc is raised by the underlying system). (Note that that is different from an NullElement, which represents an empty value, and is created with Element::create()) Notes: Read notes of IntElement definition about the use of long long int, long int and int. | |
| static ElementPtr | create (const Position &pos=ZERO_POSITION()) |
| Create a NullElement. | |
| static ElementPtr | create (const long long int i, const Position &pos=ZERO_POSITION()) |
| Create an IntElement. | |
| static ElementPtr | create (const int i, const Position &pos=ZERO_POSITION()) |
| Create an IntElement (int overload). | |
| static ElementPtr | create (const long int i, const Position &pos=ZERO_POSITION()) |
| Create an IntElement (long int overload). | |
| static ElementPtr | create (const uint32_t i, const Position &pos=ZERO_POSITION()) |
| Create an IntElement (int32_t overload). | |
| static ElementPtr | create (const isc::util::int128_t &i, const Position &pos=ZERO_POSITION()) |
| Create a BigIntElement. | |
| static ElementPtr | create (const double d, const Position &pos=ZERO_POSITION()) |
| Create a DoubleElement. | |
| static ElementPtr | create (const bool b, const Position &pos=ZERO_POSITION()) |
| Create a BoolElement. | |
| static ElementPtr | create (const std::string &s, const Position &pos=ZERO_POSITION()) |
| Create a StringElement. | |
| static ElementPtr | create (const char *s, const Position &pos=ZERO_POSITION()) |
| Create a StringElement (char* overload). | |
| static ElementPtr | createList (const Position &pos=ZERO_POSITION()) |
| Creates an empty ListElement type ElementPtr. | |
| static ElementPtr | createMap (const Position &pos=ZERO_POSITION()) |
| Creates an empty MapElement type ElementPtr. | |
Compound factory functions | |
| static ElementPtr | fromJSON (const std::string &in, bool preproc=false) |
| These functions will parse the given string (JSON) representation of a compound element. | |
| static ElementPtr | fromJSON (std::istream &in, bool preproc=false) |
| Creates an Element from the given input stream containing JSON formatted data. | |
| static ElementPtr | fromJSON (std::istream &in, const std::string &file_name, bool preproc=false) |
| Creates an Element from the given input stream containing JSON formatted data. | |
| static ElementPtr | fromJSON (std::istream &in, const std::string &file, int &line, int &pos, unsigned level=MAX_NESTING_LEVEL) |
| Creates an Element from the given input stream, where we keep track of the location in the stream for error reporting. | |
| static ElementPtr | fromJSONFile (const std::string &file_name, bool preproc=false) |
| Reads contents of specified file and interprets it as JSON. | |
Type name conversion functions. | |
| static std::string | typeToName (Element::types type) |
| Returns the name of the given type as a string. | |
| static Element::types | nameToType (const std::string &type_name) |
| Converts the string to the corresponding type Throws a TypeError if the name is unknown. | |
| static void | preprocess (std::istream &in, std::stringstream &out) |
| input text preprocessor. | |
Static Public Attributes | |
| static constexpr unsigned | MAX_NESTING_LEVEL = 100U |
| Maximum nesting level of Element objects. | |
Protected Member Functions | |
| Element (types t, const Position &pos=ZERO_POSITION()) | |
| Constructor. | |
Wire format factory functions | |
| static ElementPtr | fromWire (std::stringstream &in, int length) |
| These function parse the wireformat at the given stringstream (of the given length). | |
| static ElementPtr | fromWire (const std::string &s) |
| Creates an Element from the wire format in the given string. | |
| void | removeEmptyContainersRecursively (unsigned level=MAX_NESTING_LEVEL) |
| Remove all empty maps and lists from this Element and its descendants. | |
The Element class represents a piece of data, used by the command channel and configuration parts.
An Element can contain simple types (int, real, string, bool and None), and composite types (list and string->element maps)
Elements should in calling functions usually be referenced through an ElementPtr, which can be created using the factory functions Element::create() and Element::fromJSON()
Notes to developers: Element is a base class, implemented by a specific subclass for each type (IntElement, BoolElement, etc). Element does define all functions for all types, and defaults to raising a TypeError for functions that are not supported for the type in question.
| enum isc::data::Element::types : uint16_t |
The types that an Element can hold.
Some of these types need to match their associated integer from the parameter_data_type database table, so let the enums be explicitly mapped to integers, to reduce the chance of messing up.
any is a special type used in list specifications, specifying that the elements can be of any type.
| Enumerator | |
|---|---|
| integer | |
| real | |
| boolean | |
| null | |
| string | |
| bigint | |
| list | |
| map | |
| any | |
|
inlineprotected |
Constructor.
| t | Element type. |
| pos | Structure holding position of the value of the data element. It comprises the line number and the position within this line. The values held in this structure are used for error logging purposes. |
Definition at line 181 of file data.h.
Referenced by isc::data::BigIntElement::BigIntElement(), isc::data::BoolElement::BoolElement(), isc::data::DoubleElement::DoubleElement(), isc::data::IntElement::IntElement(), isc::data::ListElement::ListElement(), isc::data::MapElement::MapElement(), isc::data::NullElement::NullElement(), isc::data::StringElement::StringElement(), isc::data::BigIntElement::equals(), isc::data::BoolElement::equals(), isc::data::DoubleElement::equals(), equals(), isc::data::IntElement::equals(), isc::data::ListElement::equals(), isc::data::MapElement::equals(), isc::data::NullElement::equals(), and isc::data::StringElement::equals().
|
virtual |
Adds an ElementPtr to the list.
| element | The ElementPtr to add |
Reimplemented in isc::data::ListElement.
Definition at line 203 of file data.cc.
References throwTypeError.
|
inlinevirtual |
Return the big integer value.
Reimplemented in isc::data::BigIntElement.
Definition at line 280 of file data.h.
References throwTypeError.
Referenced by isc::data::BigIntElement::equals(), isc::data::IntElement::equals(), and isc::data::BigIntElement::toJSON().
|
inlinevirtual |
Return the boolean value.
Reimplemented in isc::data::BoolElement.
Definition at line 290 of file data.h.
References throwTypeError.
Referenced by isc::data::BoolElement::equals(), isc::data::operator<(), and isc::data::BoolElement::toJSON().
|
virtual |
Checks if there is data at the given key.
| name | The key of the Element checked for existence |
Reimplemented in isc::data::MapElement.
Definition at line 238 of file data.cc.
References throwTypeError.
Referenced by isc::data::MapElement::equals().
|
static |
Create a BoolElement.
| b | The boolean. |
| pos | The position. |
|
static |
Create a StringElement (char* overload).
| s | The string. |
| pos | The position. |
Definition at line 344 of file data.cc.
References create().
Here is the call graph for this function:
|
static |
Create a DoubleElement.
| d | The double. |
| pos | The position. |
|
static |
Create an IntElement (int overload).
| i | The integer. |
| pos | The position. |
Definition at line 314 of file data.cc.
References create().
Here is the call graph for this function:
|
static |
Create a BigIntElement.
| i | The big integer. |
| pos | The position. |
|
static |
Create an IntElement (long int overload).
| i | The integer. |
| pos | The position. |
Definition at line 319 of file data.cc.
References create().
Here is the call graph for this function:
|
static |
Create an IntElement.
| i | The integer. |
| pos | The position. |
|
static |
Create a NullElement.
| pos | The position. |
Definition at line 299 of file data.cc.
Referenced by isc::dhcp::configureDhcp4Server(), isc::dhcp::configureDhcp6Server(), create(), create(), create(), isc::data::StampedValue::create(), isc::dhcp::CBControlDHCPv4::databaseConfigApply(), isc::dhcp::CBControlDHCPv6::databaseConfigApply(), isc::dhcp::CfgHostsList::externalize(), isc::data::MapElement::get(), isc::dhcp::PacketQueue< PacketTypePtr >::getInfo(), isc::dhcp::PacketQueueRing< PacketTypePtr >::getInfo(), isc::stats::Observation::getJSON(), isc::data::StampedElement::getMetadata(), isc::dhcp::Memfile_LeaseMgr::getStatus(), isc::dhcp::ClientClassDictionary::initMatchExpr(), isc::dhcp::DHCPQueueControlParser::parse(), isc::perfmon::PerfMonMgr::perfmonControlHandler(), isc::perfmon::PerfMonMgr::perfmonGetAllDurationsHandler(), isc::subnet_cmds::SubnetCmdsImpl::subnetToElement(), isc::db::DatabaseConnection::toElement(), isc::dhcp::Cfg4o6::toElement(), isc::dhcp::CfgDUID::toElement(), isc::dhcp::CfgExpiration::toElement(), isc::dhcp::CfgHostOperations::toElement(), isc::dhcp::CfgIface::toElement(), isc::dhcp::CfgMACSource::toElement(), isc::dhcp::CfgRSOO::toElement(), isc::dhcp::ClientClassDef::toElement(), isc::dhcp::ClientClasses::toElement(), isc::dhcp::D2ClientConfig::toElement(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Network4::toElement(), isc::dhcp::Network6::toElement(), isc::dhcp::Network::toElement(), isc::dhcp::NetworkStateImpl::toElement(), isc::dhcp::Pool4::toElement(), isc::dhcp::Pool6::toElement(), isc::dhcp::Pool::toElement(), isc::dhcp::SharedNetwork4::toElement(), isc::dhcp::SharedNetwork6::toElement(), isc::dhcp::SrvConfig::toElement(), isc::dhcp::Subnet::toElement(), isc::dhcp::TemplateClientClassDef::toElement(), isc::perfmon::DurationKey::toElement(), isc::perfmon::DurationKeyParser::toElement(), isc::perfmon::MonitoredDuration::toElement(), isc::dhcp::Host::toElement4(), isc::dhcp::Host::toElement6(), isc::dhcp::CfgOption::toElementWithMetadata(), isc::dhcp::CfgOptionDef::toElementWithMetadata(), isc::perfmon::MonitoredDuration::toValueRow(), isc::dhcp::AllocEngine::updateLease4ExtendedInfo(), isc::dhcp::AllocEngine::updateLease6ExtendedInfo(), isc::dhcp::LeaseMgr::upgradeLease4ExtendedInfo(), isc::dhcp::LeaseMgr::upgradeLease6ExtendedInfo(), and isc::perfmon::MonitoredDuration::valueRowColumns().
|
static |
Create a StringElement.
| s | The string. |
| pos | The position. |
|
static |
Create an IntElement (int32_t overload).
| i | The integer. |
| pos | The position. |
|
static |
Creates an empty ListElement type ElementPtr.
| pos | A structure holding position of the data element value in the configuration string. It is used for error logging purposes. |
Definition at line 349 of file data.cc.
Referenced by isc::dhcp::CfgHostsList::add(), isc::dhcp::CfgHostsList::externalize(), isc::perfmon::PerfMonMgr::formatDurationDataAsElements(), isc::perfmon::PerfMonMgr::formatDurationDataAsResultSet(), isc::dhcp::CfgHostsList::get(), isc::stats::Observation::getJSON(), isc::yang::Translator::getList(), isc::data::StampedElement::getMetadata(), isc::data::mergeDiffAdd(), isc::dhcp::ControlSocketsParser::parse(), isc::dhcp::processDhcp4Config(), isc::dhcp::processDhcp6Config(), isc::dhcp::CfgHostDbAccess::toElement(), isc::dhcp::CfgHostOperations::toElement(), isc::dhcp::CfgIface::toElement(), isc::dhcp::CfgMACSource::toElement(), isc::dhcp::CfgRSOO::toElement(), isc::dhcp::CfgSharedNetworks< SharedNetworkPtrType, SharedNetworkCollection >::toElement(), isc::dhcp::CfgSubnets4::toElement(), isc::dhcp::CfgSubnets6::toElement(), isc::dhcp::ClientClassDictionary::toElement(), isc::dhcp::ClientClasses::toElement(), isc::dhcp::Network::toElement(), isc::dhcp::NetworkStateImpl::toElement(), isc::dhcp::SharedNetwork4::toElement(), isc::dhcp::SharedNetwork6::toElement(), isc::dhcp::SrvConfig::toElement(), isc::dhcp::Subnet4::toElement(), isc::dhcp::Subnet6::toElement(), isc::dhcp::Host::toElement4(), isc::dhcp::Host::toElement6(), isc::dhcp::CfgOption::toElementWithMetadata(), isc::dhcp::CfgOptionDef::toElementWithMetadata(), isc::perfmon::MonitoredDuration::toValueRow(), isc::dhcp::AllocEngine::updateLease6ExtendedInfo(), and isc::perfmon::MonitoredDuration::valueRowColumns().
|
static |
Creates an empty MapElement type ElementPtr.
| pos | A structure holding position of the data element value in the configuration string. It is used for error logging purposes. |
Definition at line 354 of file data.cc.
Referenced by isc::dhcp::configureDhcp4Server(), isc::dhcp::configureDhcp6Server(), isc::dhcp::CfgHostsList::externalize(), isc::perfmon::PerfMonMgr::formatDurationDataAsResultSet(), isc::dhcp::PacketQueue< PacketTypePtr >::getInfo(), isc::data::StampedElement::getMetadata(), isc::dhcp::Memfile_LeaseMgr::getStatus(), isc::limits::LimitManager::lease_callout(), isc::data::mergeDiffDel(), isc::host_cmds::HostDataParser< isc::dhcp::HostReservationParser4 >::parseWithSubnet(), isc::perfmon::PerfMonMgr::perfmonControlHandler(), isc::perfmon::PerfMonMgr::perfmonGetAllDurationsHandler(), isc::data::removeIdentical(), isc::dhcp::SimpleParser4::setAllDefaults(), isc::dhcp::SimpleParser6::setAllDefaults(), isc::db::DatabaseConnection::toElement(), isc::dhcp::Cfg4o6::toElement(), isc::dhcp::CfgDUID::toElement(), isc::dhcp::CfgExpiration::toElement(), isc::dhcp::CfgGlobals::toElement(), isc::dhcp::CfgIface::toElement(), isc::dhcp::ClientClassDef::toElement(), isc::dhcp::D2ClientConfig::toElement(), isc::dhcp::Lease4::toElement(), isc::dhcp::Lease6::toElement(), isc::dhcp::Network::toElement(), isc::dhcp::NetworkStateImpl::toElement(), isc::dhcp::Pool::toElement(), isc::dhcp::SrvConfig::toElement(), isc::dhcp::Subnet::toElement(), isc::http::CfgHttpHeader::toElement(), isc::perfmon::DurationKey::toElement(), isc::perfmon::DurationKeyParser::toElement(), isc::perfmon::MonitoredDuration::toElement(), isc::dhcp::Host::toElement4(), isc::dhcp::Host::toElement6(), isc::dhcp::CfgOption::toElementWithMetadata(), isc::dhcp::CfgOptionDef::toElementWithMetadata(), isc::dhcp::CBControlDHCP< ConfigBackendMgrType >::translateAndAddGlobalsToConfig(), isc::dhcp::AllocEngine::updateLease4ExtendedInfo(), isc::dhcp::AllocEngine::updateLease6ExtendedInfo(), isc::dhcp::Lease::updateUserContextISC(), and isc::dhcp::LeaseMgr::upgradeLease4ExtendedInfo().
|
inlinevirtual |
Return the double value.
Reimplemented in isc::data::DoubleElement.
Definition at line 285 of file data.h.
References throwTypeError.
Referenced by isc::data::DoubleElement::equals(), isc::data::operator<(), and isc::data::DoubleElement::toJSON().
|
virtual |
Return true if there are no elements in the list.
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 218 of file data.cc.
References throwTypeError.
|
pure virtual |
Test equality.
| other | The other element to compare with. |
| level | The maximum level of recursion. |
| BadValue | when nesting depth is more than level. |
Implemented in isc::data::BigIntElement, isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, isc::data::NullElement, and isc::data::StringElement.
References Element(), and MAX_NESTING_LEVEL.
Referenced by isc::data::ListElement::equals(), isc::data::MapElement::equals(), isc::data::operator!=(), and isc::data::operator==().
Here is the call graph for this function:
|
virtual |
Recursively finds any data at the given identifier.
The identifier is a /-separated list of names of nested maps, with the last name being the leaf that is returned.
For instance, if you have a MapElement that contains another MapElement at the key "foo", and that second MapElement contains Another Element at key "bar", the identifier for that last element from the first is "foo/bar".
| identifier | The identifier of the element to find |
Reimplemented in isc::data::MapElement.
Definition at line 243 of file data.cc.
References throwTypeError.
Referenced by isc::data::MapElement::find().
|
virtual |
See Element::find()
| identifier | The identifier of the element to find |
| t | Reference to store the resulting ElementPtr, if found. |
Reimplemented in isc::data::MapElement.
|
static |
These functions will parse the given string (JSON) representation of a compound element.
If there is a parse error, an exception of the type isc::data::JSONError is thrown.
Creates an Element from the given JSON string
| in | The string to parse the element from |
| preproc | specified whether preprocessing (e.g. comment removal) should be performed |
Definition at line 859 of file data.cc.
References fromJSON(), and preprocess().
Referenced by fromJSON(), fromJSON(), fromJSON(), isc::dhcp_ddns::NameChangeRequest::fromJSON(), fromJSONFile(), fromWire(), fromWire(), user_chk::UserFile::makeUser(), and isc::dhcp::CBControlDHCP< ConfigBackendMgrType >::translateAndAddGlobalsToConfig().
Here is the call graph for this function:
|
static |
Creates an Element from the given input stream containing JSON formatted data.
| in | The string to parse the element from |
| preproc | specified whether preprocessing (e.g. comment removal) should be performed |
| JSONError |
Definition at line 762 of file data.cc.
References fromJSON(), and preprocess().
Here is the call graph for this function:
|
static |
Creates an Element from the given input stream, where we keep track of the location in the stream for error reporting.
| in | The string to parse the element from. |
| file | The input file name. |
| line | A reference to the int where the function keeps track of the current line. |
| pos | A reference to the int where the function keeps track of the current position within the current line. |
| level | The maximum level of recursion. |
| JSONError |
Definition at line 786 of file data.cc.
References isc_throw.
|
static |
Creates an Element from the given input stream containing JSON formatted data.
| in | The string to parse the element from |
| file_name | specified input file name (used in error reporting) |
| preproc | specified whether preprocessing (e.g. comment removal) should be performed |
| JSONError |
| JSONError |
Definition at line 776 of file data.cc.
References fromJSON(), and preprocess().
Here is the call graph for this function:
|
static |
Reads contents of specified file and interprets it as JSON.
| file_name | name of the file to read |
| preproc | specified whether preprocessing (e.g. comment removal) should be performed |
Definition at line 878 of file data.cc.
References fromJSON(), and isc_throw.
Here is the call graph for this function:
|
static |
Creates an Element from the wire format in the given string.
| s | The input string. |
Definition at line 1053 of file data.cc.
References fromJSON().
Here is the call graph for this function:
|
static |
These function parse 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.
| in | The input stringstream. |
| length | The length of the wireformat data in the stream. |
Definition at line 1061 of file data.cc.
References fromJSON().
Here is the call graph for this function:
|
virtual |
Returns the ElementPtr at the given index.
If the index is out of bounds, this function throws an std::out_of_range exception.
| i | The position of the ElementPtr to return |
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 188 of file data.cc.
References throwTypeError.
Referenced by isc::data::ListElement::equals(), isc::data::MapElement::equals(), isc::data::MapElement::find(), and removeEmptyContainersRecursively().
|
virtual |
Returns the ElementPtr at the given key.
| name | The key of the Element to return |
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 223 of file data.cc.
References throwTypeError.
|
virtual |
returns element as non-const pointer.
| i | The position of the ElementPtr to retrieve. |
Reimplemented in isc::data::ListElement.
Definition at line 193 of file data.cc.
References throwTypeError.
Referenced by removeEmptyContainersRecursively().
|
inline |
|
inline |
Definition at line 191 of file data.h.
Referenced by isc::data::BigIntElement::equals(), isc::data::BoolElement::equals(), isc::data::DoubleElement::equals(), isc::data::IntElement::equals(), isc::data::ListElement::equals(), isc::data::MapElement::equals(), isc::data::NullElement::equals(), isc::data::StringElement::equals(), and isc::data::operator<().
|
virtual |
Get the boolean value.
| t | The reference to the boolean. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Get the double value.
| t | The reference to the double. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Get the integer value.
| t | The reference to the integer. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Get the map value.
| t | The reference to the map. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Get the string value.
| t | The reference to the string. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Get the list value.
| t | The reference to the list. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
inlinevirtual |
Return the integer value.
Reimplemented in isc::data::IntElement.
Definition at line 275 of file data.h.
References throwTypeError.
Referenced by isc::data::BigIntElement::equals(), isc::data::IntElement::equals(), isc::data::operator<(), and isc::data::IntElement::toJSON().
|
inlinevirtual |
Return the list value.
Reimplemented in isc::data::ListElement.
Definition at line 300 of file data.h.
References throwTypeError.
Referenced by isc::data::ListElement::toJSON().
|
inlinevirtual |
Return the map value.
Reimplemented in isc::data::MapElement.
Definition at line 306 of file data.h.
References throwTypeError.
Referenced by isc::data::MapElement::equals().
|
static |
Converts the string to the corresponding type Throws a TypeError if the name is unknown.
| type_name | The name to get the type of. |
Definition at line 735 of file data.cc.
References any, bigint, boolean, integer, isc_throw, list, map, null, real, and string.
|
static |
input text preprocessor.
This method performs preprocessing of the input stream (which is expected to contain a text version of to be parsed JSON). For now the sole supported operation is bash-style (line starting with #) comment removal, but it will be extended later to cover more cases (C, C++ style comments, file inclusions, maybe macro replacements?).
This method processes the whole input stream. It reads all contents of the input stream, filters the content and returns the result in a different stream.
| in | input stream to be preprocessed. |
| out | output stream (filtered content will be written here). |
Definition at line 1754 of file data.cc.
Referenced by fromJSON(), fromJSON(), and fromJSON().
|
virtual |
Removes the element at the given position.
If the index is out of nothing happens.
| i | The index of the element to remove. |
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 208 of file data.cc.
References throwTypeError.
Referenced by removeEmptyContainersRecursively().
|
virtual |
Remove the ElementPtr at the given key.
| name | The key of the Element to remove |
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 233 of file data.cc.
References throwTypeError.
| void isc::data::Element::removeEmptyContainersRecursively | ( | unsigned | level = MAX_NESTING_LEVEL | ) |
Remove all empty maps and lists from this Element and its descendants.
| level | nesting level. |
Definition at line 57 of file data.cc.
References get(), getNonConst(), list, map, remove(), size(), and stringValue().
Here is the call graph for this function:
|
virtual |
Sets the ElementPtr at the given index.
If the index is out of bounds, this function throws an std::out_of_range exception.
| i | The position of the ElementPtr to set |
| element | The ElementPtr to set at the position |
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 198 of file data.cc.
References throwTypeError.
|
virtual |
Sets the ElementPtr at the given key.
| name | The key of the Element to set |
| element | The ElementPtr to set at the given key. |
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 228 of file data.cc.
References throwTypeError.
|
virtual |
Set the boolean value.
| t | The new boolean value. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Set the double value.
| v | The new double value. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
inline |
Set the integer value (int overload).
| i | The new integer value. |
Definition at line 424 of file data.h.
References setValue().
Here is the call graph for this function:
|
virtual |
Set the big integer value.
| v | The new big integer value. |
Reimplemented in isc::data::BigIntElement, isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
inline |
Set the integer value (long int overload).
| i | The new integer value. |
Definition at line 415 of file data.h.
References setValue().
Here is the call graph for this function:
|
virtual |
Set the integer value.
| v | The new integer value. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
Definition at line 153 of file data.cc.
Referenced by setValue(), and setValue().
|
virtual |
Set the map value.
| v | The new map value. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Set the string value.
| v | The new string value. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Set the list value.
| v | The new list value. |
Reimplemented in isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, and isc::data::StringElement.
|
virtual |
Returns the number of elements in the list.
Reimplemented in isc::data::ListElement, and isc::data::MapElement.
Definition at line 213 of file data.cc.
References throwTypeError.
Referenced by isc::data::ListElement::equals(), isc::data::MapElement::equals(), isc::data::MapElement::find(), isc::data::mergeDiffDel(), and removeEmptyContainersRecursively().
| std::string isc::data::Element::str | ( | ) | const |
Returns a string representing the Element and all its child elements.
The resulting string will contain the Element in JSON format. Based on toJSON.
Definition at line 104 of file data.cc.
References toJSON().
Referenced by isc::data::operator<<(), and isc::data::StringElement::toJSON().
Here is the call graph for this function:
|
inlinevirtual |
Return the string value.
Reimplemented in isc::data::StringElement.
Definition at line 295 of file data.h.
References throwTypeError.
Referenced by isc::data::StringElement::equals(), isc::data::operator<(), removeEmptyContainersRecursively(), and isc::data::StringElement::toJSON().
|
pure virtual |
Converts the Element to JSON format and appends it to the given output stream.
| ss | The output stream where to append the JSON format. |
| level | The maximum level of recursion. |
| BadValue | when nesting depth is more than level. |
Implemented in isc::data::BigIntElement, isc::data::BoolElement, isc::data::DoubleElement, isc::data::IntElement, isc::data::ListElement, isc::data::MapElement, isc::data::NullElement, and isc::data::StringElement.
References MAX_NESTING_LEVEL.
| std::string isc::data::Element::toWire | ( | ) | const |
| void isc::data::Element::toWire | ( | std::ostream & | out | ) | const |
|
static |
Returns the name of the given type as a string.
| type | The type to return the name of. |
Definition at line 709 of file data.cc.
References any, bigint, boolean, integer, list, map, null, real, and string.
Referenced by isc::data::SimpleParser::checkKeywords(), and isc::data::StampedValue::create().
|
inlinestatic |
Returns Position object with line_ and pos_ set to 0, and with an empty file name.
The object containing two zeros is a default for most of the methods creating Element objects. The returned value is static so as it is not created every time the function with the default position argument is called.
Definition at line 139 of file data.h.
Referenced by isc::data::SimpleParser::getPosition(), and isc::dhcp::ValueStorage< uint32_t >::getPosition().
|
staticconstexpr |
Maximum nesting level of Element objects.
Many methods and functions perform a recursive walk on an element containing lists or/and maps. This recursion is limited to using an allowed level of nesting argument which is decremented at each recursive call until it reaches 0. This was extended to recursive parsing of a JSON text as stack overflows were reported with excessive recursion on specially crafted input. This constant is the default allowed level of nesting, its value is arbitrary (but enough for all realistic cases) and used before limiting recursion in all recursive methods/functions.
Definition at line 86 of file data.h.
Referenced by equals(), isc::data::prettyPrint(), and toJSON().