AIM
 All Classes Functions Variables Typedefs Enumerations
AIMValue Class Reference

#include <AIMValue.h>

Public Types

enum  AIMValue_Type {
  INT, BOOL, FLOAT, DOUBLE,
  STRING, VECTOR, MAP, EMPTY
}
 

Public Member Functions

 AIMValue (const int value)
 
 AIMValue (const bool value)
 
 AIMValue (const float value)
 
 AIMValue (const double value)
 
 AIMValue (const char *value)
 
 AIMValue (const std::string &value)
 
 AIMValue (const std::map< std::string, AIMValue > &value)
 
 AIMValue (const std::vector< AIMValue > &value)
 
 AIMValue (const AIMValue &other)
 
AIMValueoperator= (const AIMValue &rhs)
 
bool isEmpty () const
 
bool isNumeric () const
 
bool isInt () const
 
bool isBool () const
 
bool isFloat () const
 
bool isDouble () const
 
bool isString () const
 
bool isMap () const
 
bool isVector () const
 
AIMValue_Type const getType () const
 
void * getValue () const
 
std::string getTypeString () const
 
int getIntValue () const
 
 operator int () const
 
float getFloatValue () const
 
 operator float () const
 
bool getBoolValue () const
 
 operator bool () const
 
double getDoubleValue () const
 
 operator double () const
 
std::string & getStringValue () const
 
std::string & getStringValue ()
 
const std::string getStringValueCopy ()
 
 operator std::string & ()
 
 operator std::string & () const
 
std::vector< AIMValue > & getVectorValue () const
 
std::vector< AIMValue > & getVectorValue ()
 
 operator std::vector< AIMValue > & ()
 
 operator std::vector< AIMValue > & () const
 
AIMValueoperator[] (int index)
 
AIMValueoperator[] (int index) const
 
std::map< std::string, AIMValue > & getMapValue () const
 
std::map< std::string, AIMValue > & getMapValue ()
 
 operator std::map< std::string, AIMValue > & ()
 
 operator std::map< std::string, AIMValue > & () const
 
AIMValueoperator[] (const std::string &key)
 
AIMValueoperator[] (const std::string &key) const
 
AIMValueoperator[] (const char *key)
 
AIMValueoperator[] (const char *key) const
 
std::string toJSONValue () const
 

Friends

std::ostream & operator<< (std::ostream &os, const AIMValue &value)
 

Detailed Description

AIMValue.h

Created on: Feb 5, 2013 Author: Ted Schmidt

This class defines the values types of an AI-module.
Value types which are supported: int, bool, float, double, vector<AIMValue>, map<string, AIMValue>

Member Enumeration Documentation

The possible values types

Constructor & Destructor Documentation

AIMValue::AIMValue ( const int  value)

int value type

AIMValue::AIMValue ( const bool  value)

bool value type

AIMValue::AIMValue ( const float  value)

float value type

AIMValue::AIMValue ( const double  value)

double value type

AIMValue::AIMValue ( const char *  value)

char pointer value type

AIMValue::AIMValue ( const std::string &  value)

string value type

AIMValue::AIMValue ( const std::map< std::string, AIMValue > &  value)

map<string, AIMValue> value type

AIMValue::AIMValue ( const std::vector< AIMValue > &  value)

<vector<AIMValue> value type

Member Function Documentation

bool AIMValue::getBoolValue ( ) const

Get the bool value

This method returns the bool representation of the value stored in the AIMValue.
If the type of the stored value is not a number or string then a runtime_error is thrown

Returns
bool The integer value
double AIMValue::getDoubleValue ( ) const

Get the double value

This method returns the double representation of the value stored in the AIMValue.
If the type of the stored value is not a number or string then a runtime_error is thrown

Returns
double The integer value
float AIMValue::getFloatValue ( ) const

Get the float value

This method returns the float representation of the value stored in the AIMValue.
If the type of the stored value is not a number or string then a runtime_error is thrown

Returns
float The integer value
int AIMValue::getIntValue ( ) const

Get the int value

This method returns the int representation of the value stored in the AIMValue.
If the type of the stored value is not a number or string then a runtime_error is thrown

Returns
int The integer value
std::map< std::string, AIMValue > & AIMValue::getMapValue ( ) const

Get the map value

This method returns the map value of the value stored in the AIMValue.
If the type of the stored value is not map then a runtime_error is thrown

Returns
map The integer value
std::string & AIMValue::getStringValue ( ) const

Get the string value

This method returns the string value of the value stored in the AIMValue.
If the type of the stored value is not a number or string then a runtime_error is thrown

Returns
string The integer value
const std::string AIMValue::getStringValueCopy ( )
inline

Get a copy of the string value

Needed for SWIG, while SWIG can't handle non-const string references

AIMValue_Type const AIMValue::getType ( ) const
inline

Get the value type

This method returns the value type of the AIMValue

Returns
AIMValue_Type The value type as propertyValue_Type
std::string AIMValue::getTypeString ( ) const

Get a string representation of the value type

This method returns a string representation of the value type of the AIMValue

Returns
A string representation of AIMValue_Type
void* AIMValue::getValue ( ) const
inline

Get the value

This method returns the value pointer of the value stored in the AIMValue
This void pointer can be casted statically to the type returned with getType

Returns
void* The void pointer to the value pointer
std::vector< AIMValue > & AIMValue::getVectorValue ( ) const

Get the vector value

This method returns the vector value of the value stored in the AIMValue.
If the type of the stored value is not vector then a runtime_error is thrown

Returns
vector The integer value
bool AIMValue::isBool ( ) const
inline

Check for bool value

This method checks whether the value wrapped in the AIMValue is a bool

Returns
bool Returns true if the AIMValue is a bool
bool AIMValue::isDouble ( ) const
inline

Check for double value

This method checks whether the value wrapped in the AIMValue is a double

Returns
bool Returns true if the AIMValue is a double
bool AIMValue::isEmpty ( ) const
inline

Check for empty value

This method checks whether the value wrapped in the AIMValue is empty (null)

Returns
bool Returns true if there is no value wrapped in the AIMValue
bool AIMValue::isFloat ( ) const
inline

Check for float value

This method checks whether the value wrapped in the AIMValue is a float

Returns
bool Returns true if the AIMValue is a float
bool AIMValue::isInt ( ) const
inline

Check for int value

This method checks whether the value wrapped in the AIMValue is a int

Returns
bool Returns true if the AIMValue is a int
bool AIMValue::isMap ( ) const
inline

Check for map value

This method checks whether the value wrapped in the AIMValue is a map

Returns
bool Returns true if the AIMValue is a map
bool AIMValue::isNumeric ( ) const

Check for numeric value

This method checks whether the value wrapped in the AIMValue is numeric

Returns
bool Returns true if there is a numberic value wrapped in the AIMValue
bool AIMValue::isString ( ) const
inline

Check for string value

This method checks whether the value wrapped in the AIMValue is a string

Returns
bool Returns true if the AIMValue is a string
bool AIMValue::isVector ( ) const
inline

Check for vector value

This method checks whether the value wrapped in the AIMValue is a vector

Returns
bool Returns true if the AIMValue is a vector
AIMValue::operator bool ( ) const
inline
See Also
getBoolValue()
AIMValue::operator double ( ) const
inline
AIMValue::operator float ( ) const
inline
See Also
getFloatValue()
AIMValue::operator int ( ) const
inline
See Also
getIntValue()
AIMValue::operator std::map< std::string, AIMValue > & ( )
inline
See Also
getMapValue()
AIMValue::operator std::string & ( )
inline
See Also
getStringValue()
AIMValue::operator std::vector< AIMValue > & ( )
inline
See Also
getVectorValue()
AIMValue& AIMValue::operator[] ( int  index)
inline

Get the AIMValue from the vector data type

This method returns the AIMValue from a MapValue based on the key value If the type of the stored value is not map then a runtime_error is thrown

string key The key for the map value index

Returns
AIMValue A reference to the AIMvalue at the key position
AIMValue& AIMValue::operator[] ( const std::string &  key)
inline

Get the AIMValue from the map data type

This method returns the AIMValue from a MapValue based on the key value If the type of the stored value is not map then a runtime_error is thrown

string key The key for the map value index

Returns
AIMValue A reference to the AIMvalue at the key position
AIMValue& AIMValue::operator[] ( const char *  key)
inline

Get the AIMValue from the map value

See Also
&operator[](const std::string& key)
std::string AIMValue::toJSONValue ( ) const

Return JSON representation

This method returns the value of the AIMValue in JSON format as text.
(This is to be independent of the boost lib.)
toJSONValue() return examples:
AIMValue((float)0.0001).toJSONValue() -> 0.0001
AIMValue(string("0.0001")).toJSONValue() -> "0.0001"
AIMValue(vector<int>(2,1)).toJSONValue() -> [1,1]
AIMValue((map<string, AIMValue>)m).toJSONValue() -> {"key":"value"}
with m["key"] = AIMValue("value")

Returns
string The JSON representation in text

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