KrisLibrary  1.0.0
Public Member Functions | List of all members
PropertyMap Class Reference

A simple map from keys to values. More...

#include <PropertyMap.h>

Inheritance diagram for PropertyMap:

Public Member Functions

 PropertyMap (const std::map< std::string, std::string > &)
 
template<class T >
 PropertyMap (const std::map< std::string, T > &)
 
template<class T >
 PropertyMap (const std::vector< std::string > &keys, const std::vector< T > &values)
 
bool contains (const std::string &key) const
 
bool remove (const std::string &key)
 
void set (const std::string &key, const std::string &value)
 
bool get (const std::string &key, std::string &value) const
 
std::string as (const std::string &key) const
 
void setArray (const std::string &key, const std::vector< std::string > &values)
 
bool getArray (const std::string &key, std::vector< std::string > &values) const
 
std::vector< std::string > asArray (const std::string &key) const
 
template<class T >
void set (const std::string &key, const T &value)
 
template<class T >
bool get (const std::string &key, T &value) const
 
template<class T >
as (const std::string &key) const
 
template<class T >
getDefault (const std::string &key, T defaultValue=T()) const
 
template<class T >
void setArray (const std::string &key, const std::vector< T > &value)
 
template<class T >
bool getArray (const std::string &key, std::vector< T > &values) const
 
template<class T >
std::vector< T > asArray (const std::string &key) const
 
bool Load (TiXmlElement *node)
 
bool Save (TiXmlElement *node) const
 
bool LoadJSON (std::istream &in)
 
bool SaveJSON (std::ostream &out) const
 
bool Load (const char *fn)
 
bool Save (const char *fn) const
 
void Print (std::ostream &out) const
 

Detailed Description

A simple map from keys to values.

Values are easily converted to basic types using the as<T>(key) method. This method will convert the string into a stream and use the >> operator to convert to the desired type.

Basic types are conveted into values using the set(key,value) method. This will convert the value to a string using the << operator.

Property maps also support basic whitespace-separated arrays. getArray, setArray, and asArray can be used to set/get those arrays.

Property maps can be easily converted to/from JSON objects and XML node attributes. Loading/saving to disk is done through JSON serialization.


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