AIM
|
#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) | |
AIMValue & | operator= (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 | |
AIMValue & | operator[] (int index) |
AIMValue & | operator[] (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 | |
AIMValue & | operator[] (const std::string &key) |
AIMValue & | operator[] (const std::string &key) const |
AIMValue & | operator[] (const char *key) |
AIMValue & | operator[] (const char *key) const |
std::string | toJSONValue () const |
Friends | |
std::ostream & | operator<< (std::ostream &os, const AIMValue &value) |
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>
The possible values types
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
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
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
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
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
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
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
|
inline |
Get a copy of the string value
Needed for SWIG, while SWIG can't handle non-const string references
|
inline |
Get the value type
This method returns the value type of the AIMValue
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
|
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
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
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool AIMValue::isNumeric | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the AIMValue from the map value
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")