Kea  1.9.9-git
isc::data::IntElement Class Reference

Notes: IntElement type is changed to int64_t. More...

#include <data.h>

+ Inheritance diagram for isc::data::IntElement:

Public Member Functions

 IntElement (int64_t v, const Position &pos=ZERO_POSITION())
 
bool equals (const Element &other) const
 
bool getValue (int64_t &t) const
 
int64_t intValue () const
 
bool setValue (long long int v)
 
void toJSON (std::ostream &ss) const
 Converts the Element to JSON format and appends it to the given stringstream. More...
 
- Public Member Functions inherited from isc::data::Element
virtual ~Element ()
 
const PositiongetPosition () const
 Returns position where the data element's value starts in a configuration string. More...
 
int getType () const
 
std::string str () const
 Returns a string representing the Element and all its child elements; note that this is different from stringValue(), which only returns the single value of a StringElement. More...
 
std::string toWire () const
 Returns the wireformat for the Element and all its child elements. More...
 
void toWire (std::ostream &out) const
 
virtual double doubleValue () const
 
virtual bool boolValue () const
 
virtual std::string stringValue () const
 
virtual const std::vector< ElementPtr > & listValue () const
 
virtual const std::map< std::string, ConstElementPtr > & mapValue () const
 
virtual bool getValue (double &t) const
 
virtual bool getValue (bool &t) const
 
virtual bool getValue (std::string &t) const
 
virtual bool getValue (std::vector< ElementPtr > &t) const
 
virtual bool getValue (std::map< std::string, ConstElementPtr > &t) const
 
bool setValue (const long int i)
 
bool setValue (const int i)
 
virtual bool setValue (const double v)
 
virtual bool setValue (const bool t)
 
virtual bool setValue (const std::string &v)
 
virtual bool setValue (const std::vector< ElementPtr > &v)
 
virtual bool setValue (const std::map< std::string, ConstElementPtr > &v)
 
virtual ConstElementPtr get (const int i) const
 Returns the ElementPtr at the given index. More...
 
virtual ElementPtr getNonConst (const int i) const
 returns element as non-const pointer More...
 
virtual void set (const size_t i, ElementPtr element)
 Sets the ElementPtr at the given index. More...
 
virtual void add (ElementPtr element)
 Adds an ElementPtr to the list. More...
 
virtual void remove (const int i)
 Removes the element at the given position. More...
 
virtual size_t size () const
 Returns the number of elements in the list. More...
 
virtual bool empty () const
 Return true if there are no elements in the list. More...
 
virtual ConstElementPtr get (const std::string &name) const
 Returns the ElementPtr at the given key. More...
 
virtual void set (const std::string &name, ConstElementPtr element)
 Sets the ElementPtr at the given key. More...
 
virtual void remove (const std::string &name)
 Remove the ElementPtr at the given key. More...
 
virtual bool contains (const std::string &name) const
 Checks if there is data at the given key. More...
 
virtual ConstElementPtr find (const std::string &identifier) const
 Recursively finds any data at the given identifier. More...
 
virtual bool find (const std::string &identifier, ConstElementPtr &t) const
 See Element::find() More...
 

Additional Inherited Members

- Public Types inherited from isc::data::Element
enum  types {
  integer, real, boolean, null,
  string, list, map, any
}
 
- Static Public Member Functions inherited from isc::data::Element
static const PositionZERO_POSITION ()
 Returns Position object with line_ and pos_ set to 0, and with an empty file name. More...
 
static ElementPtr create (const Position &pos=ZERO_POSITION())
 
static ElementPtr create (const long long int i, const Position &pos=ZERO_POSITION())
 
static ElementPtr create (const int i, const Position &pos=ZERO_POSITION())
 
static ElementPtr create (const long int i, const Position &pos=ZERO_POSITION())
 
static ElementPtr create (const double d, const Position &pos=ZERO_POSITION())
 
static ElementPtr create (const bool b, const Position &pos=ZERO_POSITION())
 
static ElementPtr create (const std::string &s, const Position &pos=ZERO_POSITION())
 
static ElementPtr create (const char *s, const Position &pos=ZERO_POSITION())
 
static ElementPtr createList (const Position &pos=ZERO_POSITION())
 Creates an empty ListElement type ElementPtr. More...
 
static ElementPtr createMap (const Position &pos=ZERO_POSITION())
 Creates an empty MapElement type ElementPtr. More...
 
static ElementPtr fromJSON (const std::string &in, bool preproc=false)
 These functions will parse the given string (JSON) representation of a compound element. More...
 
static ElementPtr fromJSON (std::istream &in, bool preproc=false)
 Creates an Element from the given input stream containing JSON formatted data. More...
 
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. More...
 
static ElementPtr fromJSON (std::istream &in, const std::string &file, int &line, int &pos)
 Creates an Element from the given input stream, where we keep track of the location in the stream for error reporting. More...
 
static ElementPtr fromJSONFile (const std::string &file_name, bool preproc=false)
 Reads contents of specified file and interprets it as JSON. More...
 
static std::string typeToName (Element::types type)
 Returns the name of the given type as a string. More...
 
static Element::types nameToType (const std::string &type_name)
 Converts the string to the corresponding type Throws a TypeError if the name is unknown. More...
 
static void preprocess (std::istream &in, std::stringstream &out)
 input text preprocessor More...
 
static ElementPtr fromWire (std::stringstream &in, int length)
 These function pparse the wireformat at the given stringstream (of the given length). More...
 
static ElementPtr fromWire (const std::string &s)
 Creates an Element from the wire format in the given string Since the wire format is JSON, this is the same as fromJSON, and could be removed. More...
 
- Protected Member Functions inherited from isc::data::Element
 Element (int t, const Position &pos=ZERO_POSITION())
 Constructor. More...
 

Detailed Description

Notes: IntElement type is changed to int64_t.

Due to C++ problems on overloading and automatic type conversion, (C++ tries to convert integer type values and reference/pointer if value types do not match exactly) We decided the storage as int64_t, three (long long, long, int) override function definitions and cast int/long/long long to int64_t via long long. Therefore, call by value methods (create, setValue) have three (int,long,long long) definitions. Others use int64_t.

Definition at line 544 of file data.h.

Constructor & Destructor Documentation

isc::data::IntElement::IntElement ( int64_t  v,
const Position pos = ZERO_POSITION() 
)
inline

Definition at line 549 of file data.h.

Member Function Documentation

bool isc::data::IntElement::equals ( const Element other) const
virtual
Returns
true if the other ElementPtr has the same type and value

Implements isc::data::Element.

Definition at line 959 of file data.cc.

References isc::data::Element::getType(), and isc::data::Element::intValue().

+ Here is the call graph for this function:

bool isc::data::IntElement::getValue ( int64_t &  t) const
inlinevirtual

Reimplemented from isc::data::Element.

Definition at line 553 of file data.h.

int64_t isc::data::IntElement::intValue ( ) const
inlinevirtual

Reimplemented from isc::data::Element.

Definition at line 551 of file data.h.

bool isc::data::IntElement::setValue ( long long int  v)
inlinevirtual

Reimplemented from isc::data::Element.

Definition at line 555 of file data.h.

void isc::data::IntElement::toJSON ( std::ostream &  ss) const
virtual

Converts the Element to JSON format and appends it to the given stringstream.

Implements isc::data::Element.

Definition at line 776 of file data.cc.


The documentation for this class was generated from the following files: