dmlite  0.6
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
dmlite::Extensible Class Reference

Helpful typedef for KeyValue containers. More...

#include <extensible.h>

Inheritance diagram for dmlite::Extensible:
Inheritance graph
[legend]

Public Types

typedef DictType_::const_iterator const_iterator
 Iterators. More...
 

Public Member Functions

bool hasField (const std::string &key) const
 Returns true if there is a field name "key". More...
 
const boost::any & operator[] (const std::string &key) const
 
boost::any & operator[] (const std::string &key)
 
bool operator== (const Extensible &) const
 
bool operator!= (const Extensible &) const
 
bool operator> (const Extensible &) const
 
bool operator< (const Extensible &) const
 
unsigned long size () const
 Number of elements inside this Extensible. More...
 
void clear ()
 Removes all the content. More...
 
void copy (const Extensible &s)
 
void erase (const std::string &)
 Removes an entry. More...
 
std::string serialize (void) const
 Serializes to JSON. In principle, it only supports POD. More...
 
void deserialize (const std::string &serial)
 Deserializes from a JSON string. More...
 
std::vector< std::string > getKeys (void) const
 Get all the keys available. More...
 
bool getBool (const std::string &key, bool defaultValue=false) const
 Gets a boolean. May be able to perform some conversions. More...
 
long getLong (const std::string &key, long defaultValue=0) const
 Gets an integer. May be able to perform some conversions. More...
 
unsigned long getUnsigned (const std::string &key, unsigned long defaultValue=0) const
 Gets an unsigned integer. May be able to perform some conversions. More...
 
double getDouble (const std::string &key, double defaultValue=0) const
 Gets a float. May be able to perform some conversions. More...
 
int64_t getS64 (const std::string &key, int64_t defaultValue=0) const
 Gets a signed 64 bits type. More...
 
uint64_t getU64 (const std::string &key, uint64_t defaultValue=0) const
 Gets an unsigned 64 bits type. More...
 
std::string getString (const std::string &key, const std::string &defaultValue="") const
 Gets a string. May perform some conversions. More...
 
Extensible getExtensible (const std::string &key, const Extensible &defaultValue=Extensible()) const
 Gets a nested dictionary. More...
 
std::vector< boost::any > getVector (const std::string &key, const std::vector< boost::any > &defaultValue=std::vector< boost::any >()) const
 Gets an array. More...
 
const_iterator begin () const
 
const_iterator end () const
 

Static Public Member Functions

static bool anyToBoolean (const boost::any &any)
 Converts an any to a boolean, casting if needed. More...
 
static unsigned anyToUnsigned (const boost::any &any)
 Converts an any to an unsigned, casting if needed. More...
 
static long anyToLong (const boost::any &any)
 Converts an any to a long, casting if needed. More...
 
static double anyToDouble (const boost::any &any)
 Converts an any to a double, casting if needed. More...
 
static std::string anyToString (const boost::any &any)
 Converts an any to a string, casting if needed. More...
 
static int64_t anyToS64 (const boost::any &any)
 Converts an any to a int64_t. More...
 
static uint64_t anyToU64 (const boost::any &any)
 Converts an any to a uint64_t. More...
 

Private Types

typedef std::pair< std::string, boost::any > EntryType_
 
typedef std::vector< EntryType_DictType_
 

Private Member Functions

void populate (const boost::property_tree::ptree &root)
 

Private Attributes

DictType_ dictionary_
 

Detailed Description

Helpful typedef for KeyValue containers.

Member Typedef Documentation

◆ const_iterator

typedef DictType_::const_iterator dmlite::Extensible::const_iterator

Iterators.

◆ DictType_

typedef std::vector<EntryType_> dmlite::Extensible::DictType_
private

◆ EntryType_

typedef std::pair<std::string, boost::any> dmlite::Extensible::EntryType_
private

Member Function Documentation

◆ anyToBoolean()

static bool dmlite::Extensible::anyToBoolean ( const boost::any &  any)
static

Converts an any to a boolean, casting if needed.

◆ anyToDouble()

static double dmlite::Extensible::anyToDouble ( const boost::any &  any)
static

Converts an any to a double, casting if needed.

◆ anyToLong()

static long dmlite::Extensible::anyToLong ( const boost::any &  any)
static

Converts an any to a long, casting if needed.

◆ anyToS64()

static int64_t dmlite::Extensible::anyToS64 ( const boost::any &  any)
static

Converts an any to a int64_t.

◆ anyToString()

static std::string dmlite::Extensible::anyToString ( const boost::any &  any)
static

Converts an any to a string, casting if needed.

◆ anyToU64()

static uint64_t dmlite::Extensible::anyToU64 ( const boost::any &  any)
static

Converts an any to a uint64_t.

◆ anyToUnsigned()

static unsigned dmlite::Extensible::anyToUnsigned ( const boost::any &  any)
static

Converts an any to an unsigned, casting if needed.

◆ begin()

const_iterator dmlite::Extensible::begin ( void  ) const
inline

◆ clear()

void dmlite::Extensible::clear ( )

Removes all the content.

◆ copy()

void dmlite::Extensible::copy ( const Extensible s)

Copies the content from another Extensible Note: This will call clear first!

◆ deserialize()

void dmlite::Extensible::deserialize ( const std::string &  serial)

Deserializes from a JSON string.

◆ end()

const_iterator dmlite::Extensible::end ( ) const
inline

◆ erase()

void dmlite::Extensible::erase ( const std::string &  )

Removes an entry.

◆ getBool()

bool dmlite::Extensible::getBool ( const std::string &  key,
bool  defaultValue = false 
) const

Gets a boolean. May be able to perform some conversions.

◆ getDouble()

double dmlite::Extensible::getDouble ( const std::string &  key,
double  defaultValue = 0 
) const

Gets a float. May be able to perform some conversions.

◆ getExtensible()

Extensible dmlite::Extensible::getExtensible ( const std::string &  key,
const Extensible defaultValue = Extensible() 
) const

Gets a nested dictionary.

◆ getKeys()

std::vector<std::string> dmlite::Extensible::getKeys ( void  ) const

Get all the keys available.

◆ getLong()

long dmlite::Extensible::getLong ( const std::string &  key,
long  defaultValue = 0 
) const

Gets an integer. May be able to perform some conversions.

◆ getS64()

int64_t dmlite::Extensible::getS64 ( const std::string &  key,
int64_t  defaultValue = 0 
) const

Gets a signed 64 bits type.

◆ getString()

std::string dmlite::Extensible::getString ( const std::string &  key,
const std::string &  defaultValue = "" 
) const

Gets a string. May perform some conversions.

◆ getU64()

uint64_t dmlite::Extensible::getU64 ( const std::string &  key,
uint64_t  defaultValue = 0 
) const

Gets an unsigned 64 bits type.

◆ getUnsigned()

unsigned long dmlite::Extensible::getUnsigned ( const std::string &  key,
unsigned long  defaultValue = 0 
) const

Gets an unsigned integer. May be able to perform some conversions.

◆ getVector()

std::vector<boost::any> dmlite::Extensible::getVector ( const std::string &  key,
const std::vector< boost::any > &  defaultValue = std::vector< boost::any >() 
) const

Gets an array.

◆ hasField()

bool dmlite::Extensible::hasField ( const std::string &  key) const

Returns true if there is a field name "key".

◆ operator!=()

bool dmlite::Extensible::operator!= ( const Extensible ) const

◆ operator<()

bool dmlite::Extensible::operator< ( const Extensible ) const

◆ operator==()

bool dmlite::Extensible::operator== ( const Extensible ) const

◆ operator>()

bool dmlite::Extensible::operator> ( const Extensible ) const

◆ operator[]() [1/2]

const boost::any& dmlite::Extensible::operator[] ( const std::string &  key) const

Returns a reference to the value associated with "key". Will throw DmException(DM_INVALID_VALUE,...) when not found.

◆ operator[]() [2/2]

boost::any& dmlite::Extensible::operator[] ( const std::string &  key)

Returns a modifiable reference to the value associated with "key". Will create the entry if it does not exist.

◆ populate()

void dmlite::Extensible::populate ( const boost::property_tree::ptree &  root)
private

◆ serialize()

std::string dmlite::Extensible::serialize ( void  ) const

Serializes to JSON. In principle, it only supports POD.

◆ size()

unsigned long dmlite::Extensible::size ( ) const

Number of elements inside this Extensible.

Member Data Documentation

◆ dictionary_

DictType_ dmlite::Extensible::dictionary_
private

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