ALValue is a class to manipulate differente value type. More...
#include <alvalue/alvalue.h>
Classes | |
union | unionValue |
unionValue is a union to different type of ALValue. More... | |
Public Types | |
enum | Type { TypeInvalid = 0, TypeArray, TypeBool, TypeInt, TypeFloat, TypeString, TypeObject, TypeBinary } |
Type of ALValue. More... | |
typedef int | TALValueInt |
Type definition to int. | |
typedef float | TALValueFloat |
Type definition to float. | |
typedef double | TALValueDouble |
Type definition to double. | |
typedef bool | TALValueBool |
Type definition to bool. | |
typedef std::string | TALValueString |
Type definition to std::string. | |
typedef std::vector< unsigned char > | TAlValueBinaryData |
Vector of unsigned char used for binary data. | |
typedef TAlValueBinaryData::iterator | ITAlValueBinaryData |
Iterator to a vector of unsigned char used for binary data. | |
typedef TAlValueBinaryData::const_iterator | CITAlValueBinaryData |
Const iterator to a vector of unsigned char used for binary data. | |
typedef std::vector< ALValue > | TAlValueArray |
Vector of ALValue. | |
typedef TAlValueArray::iterator | ITAlValueArray |
Iterator to a vector of ALValue. | |
typedef TAlValueArray::const_iterator | CITAlValueArray |
Const iterator to a vector of ALValue. | |
typedef std::vector< std::string > | TStringArray |
Vector of std::string. | |
typedef std::vector< float > | TFloatArray |
Vector of float. | |
typedef std::vector< int > | TIntArray |
Vector of int. | |
Public Member Functions | |
ALValue () | |
Default constructor. | |
ALValue (const bool &value) | |
Constructor. | |
ALValue (const int &value) | |
Constructor. | |
ALValue (const double &value) | |
Constructor. | |
ALValue (const float &value) | |
Constructor. | |
ALValue (const std::string &value) | |
Constructor. | |
ALValue (const char *value) | |
Constructor. | |
ALValue (const std::vector< std::string > &pListString) | |
Constructor. | |
ALValue (const std::vector< float > &pListFloat) | |
Constructor. | |
ALValue (const std::vector< int > &pListInt) | |
Constructor. | |
ALValue (const void *value, int nBytes) | |
Constructor. | |
ALValue (const char **pArrayOfString, int nNbrString) | |
Constructor. | |
ALValue (const float *pFloat, int nNbrElement) | |
Constructor. | |
ALValue (const int *pInt, int nNbrElement) | |
Constructor. | |
ALValue (const TAlValueBinaryData &rhs) | |
Copy constructor form binary data. | |
ALValue (ALValue const &rhs) | |
Copy constructor. | |
virtual | ~ALValue () |
Desctuctor. | |
void | clear () |
Erase the current value. | |
ALValue & | operator= (const ALValue &rhs) |
Makes a copy of rhs, discarding previous content, so that the new content of is equivalent in both type and value to rhs. | |
ALValue & | operator= (const bool &rhs) |
ALValue & | operator= (const int &rhs) |
ALValue & | operator= (const double &rhs) |
ALValue & | operator= (const float &rhs) |
ALValue & | operator= (const char *rhs) |
ALValue & | operator= (const TAlValueBinaryData &rhs) |
bool | operator== (ALValue const &other) const |
alvalue.Type == other.alvalue.Type && alvalue.unionValue == other.alvalue.unionValue | |
bool | operator!= (ALValue const &other) const |
alvalue.Type != other.alvalue.Type && alvalue.unionValue != other.alvalue.unionValue | |
operator bool & () | |
Conversion operator to bool. | |
operator const bool () const | |
Conversion operator to const bool. | |
operator int & () | |
Conversion operator to int. | |
operator const int () const | |
Conversion operator to const int. | |
operator float & () | |
Conversion operator to float. | |
operator const float () const | |
Conversion operator to const float. | |
operator const double () const | |
Conversion operator to const double. | |
operator std::string & () | |
Conversion operator to std::string. | |
operator const std::string & () const | |
Conversion operator to const std::string. | |
operator TAlValueBinaryData & () | |
Conversion operator to binary data. | |
operator const TAlValueBinaryData & () const | |
Conversion operator to const binary data. | |
operator const void * () const | |
Conversion operator to const void*. | |
operator TStringArray () const | |
Conversion operator to a vector of stf::string. | |
operator TFloatArray () const | |
Conversion operator to a vector of float. | |
operator TIntArray () const | |
Conversion operator to a vector of int. | |
ALValue & | setObject (const void *pData, int nDataSizeInBytes) |
Set ALValue with an object data. | |
void | SetBinary (const void *rhs, int nDataSizeInBytes) |
Set ALValue with a binary data. | |
ALValue & | SetBinaryNoCopy (const void *rhs, int nDataSizeInBytes) |
Set ALValue with a binary data. It won't copy the data. | |
const void * | GetBinary () const |
Explicit operator to convert to const void*. | |
const void * | getObject () const |
Explicit operator to convert to const void*. | |
float * | getPtrValue () |
Get pointer on value, only allowed with 32bits variable. | |
void | ToStringArray (TStringArray &pArrayToFill, bool bInsertDefaultOnError=false) const |
Explicit convert to vector<string>. | |
void | ToFloatArray (TFloatArray &pArrayToFill, bool bInsertDefaultOnError=false) const |
Explicit convert to vector<float>. | |
void | ToIntArray (TIntArray &pArrayToFill, bool bInsertDefaultOnError=false) const |
Explicit convert to vector<int>. | |
ALValue & | operator[] (int i) |
Get a reference to the ALValue at position i in the vector. | |
const ALValue & | operator[] (int i) const |
Get a reference to the ALValue at position i in the vector. | |
enum Type | getType () const |
Gat the type of the stored value. | |
bool | isValid () const |
Check if the value has been set. | |
bool | isArray () const |
Check if the value is an array. | |
bool | isBool () const |
Check if the value is a boolean. | |
bool | isInt () const |
Check if the value is an integer. | |
bool | isFloat () const |
Check if the value is a float. | |
bool | isString () const |
Check if the value is a string. | |
bool | isObject () const |
Check if the value is a binary object. | |
bool | isBinary () const |
Check if the value is a binary. | |
unsigned int | getSize () const |
Get the size for string, objectm array, binary, invalid values. | |
void | arrayReserve (int size) |
Specify the size the array values will use. | |
void | arraySetSize (int size) |
Specify the size of the array this will call vector::resize. | |
void | arrayPush (const ALValue &pSrcToCopyNotOwned) |
Adds a new element at the end of the vector, after its current last element. | |
void | arrayPopFront () |
Pop the first element of the array. Deleting it. | |
std::string | toString (Verbosity pnVerbosity=VerbosityMini) const |
Get a string describing this object, for debug purpose. | |
std::string | toPythonBuffer () const |
Build python buffer from ALValue binary. | |
bool | decodeB64 (const char *pszB64) |
Decode a buffer from B64 to binary. | |
bool | decodeB64Object (const char *pszB64) |
Decode a buffer from B64 to binary object. | |
void | encodeB64 (std::string &strOutput) const |
Encode a binaries alvalue to B64 (binary 64 / uuencoded). | |
void | unSerializeFromText (const char *szInput, int nLimitToLen=0x7FFFFFFF) |
Create an ALValue from a text. | |
std::string | serializeToText (void) const |
Create a text describing an ALValue. | |
const unionValue | getUnionValue () |
Get the value of the ALValue. | |
TAlValueArray * | getArrayPtr () const |
Get pointer on array value. | |
Static Public Member Functions | |
static enum Type | deduceType (const char *szInput, int nLimitToLen=0x7FFFFFFF) |
Analyses a string and try to guess the type of data describe in the string. | |
static bool | xUnSerializeFromText_InnerTest (void) |
Internal function to validate the correct functionnality of unSerializeFromText. | |
template<typename T0 > | |
static ALValue | array (const T0 &a0) |
template<typename T0 , typename T1 > | |
static ALValue | array (const T0 &a0, const T1 &a1) |
template<typename T0 , typename T1 , typename T2 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2) |
template<typename T0 , typename T1 , typename T2 , typename T3 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2, const T3 &a3) |
template<typename T0 , typename T1 , typename T2 , typename T3 , typename T4 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2, const T3 &a3, const T4 &a4) |
template<typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2, const T3 &a3, const T4 &a4, const T5 &a5) |
template<typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2, const T3 &a3, const T4 &a4, const T5 &a5, const T6 &a6) |
template<typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2, const T3 &a3, const T4 &a4, const T5 &a5, const T6 &a6, const T7 &a7) |
template<typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2, const T3 &a3, const T4 &a4, const T5 &a5, const T6 &a6, const T7 &a7, const T8 &a8) |
template<typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 > | |
static ALValue | array (const T0 &a0, const T1 &a1, const T2 &a2, const T3 &a3, const T4 &a4, const T5 &a5, const T6 &a6, const T7 &a7, const T8 &a8, const T9 &a9) |
static std::string | TypeToString (enum Type pnType) |
Get a string with name of ALValue type. | |
Protected Attributes | |
int | _type |
Type of the ALValue. | |
union unionValue | _value |
Value of the ALValue. | |
Friends | |
class | ALNetwork |
void | ConvertALValueToSoapXml (const ALValue *pAlValue, std::string &strToFill, bool bInAnArray) |
ALValue is a class to manipulate differente value type.
It's using to convert multiple value type to one type, to ease the communication or storage of differente values.
enum AL::ALValue::Type |
Type of ALValue.
ALValue v; v = 0.1;
AL::ALValue::ALValue | ( | const bool & | value | ) |
Constructor.
value | value of the ALValue |
AL::ALValue::ALValue | ( | const int & | value | ) |
Constructor.
value | value of the ALValue |
AL::ALValue::ALValue | ( | const double & | value | ) |
Constructor.
value | value of the ALValue |
AL::ALValue::ALValue | ( | const float & | value | ) |
Constructor.
value | value of the ALValue |
AL::ALValue::ALValue | ( | const std::string & | value | ) |
Constructor.
value | value of the ALValue |
AL::ALValue::ALValue | ( | const char * | value | ) |
Constructor.
value | value of the ALValue |
AL::ALValue::ALValue | ( | const std::vector< std::string > & | pListString | ) |
Constructor.
pListString | value of the ALValue |
AL::ALValue::ALValue | ( | const std::vector< float > & | pListFloat | ) |
Constructor.
pListFloat | value of the ALValue |
AL::ALValue::ALValue | ( | const std::vector< int > & | pListInt | ) |
Constructor.
pListInt | value of the ALValue |
AL::ALValue::ALValue | ( | const void * | value, |
int | nBytes | ||
) |
Constructor.
value | value of the ALValue |
nBytes | size of the value |
AL::ALValue::ALValue | ( | const char ** | pArrayOfString, |
int | nNbrString | ||
) |
Constructor.
pArrayOfString | value of the ALValue |
nNbrString | string's number |
AL::ALValue::ALValue | ( | const float * | pFloat, |
int | nNbrElement | ||
) |
Constructor.
pFloat | value of the ALValue |
nNbrElement | float's number |
AL::ALValue::ALValue | ( | const int * | pInt, |
int | nNbrElement | ||
) |
Constructor.
pInt | value of the ALValue |
nNbrElement | int's number |
AL::ALValue::ALValue | ( | const TAlValueBinaryData & | rhs | ) |
Copy constructor form binary data.
rhs | value copied |
AL::ALValue::ALValue | ( | ALValue const & | rhs | ) |
Copy constructor.
rhs | value copied |
void AL::ALValue::arrayPopFront | ( | ) |
Pop the first element of the array. Deleting it.
Does completely delete the first element of the array, if the AL::ALValue is an array, and if it is not empty.
void AL::ALValue::arrayPush | ( | const ALValue & | pSrcToCopyNotOwned | ) |
Adds a new element at the end of the vector, after its current last element.
The content of this new element is initialized to a copy of pSrcToCopyNotOwned.
pSrcToCopyNotOwned | Value to be copied to the new element. Push a new value in the array |
void AL::ALValue::arrayReserve | ( | int | size | ) |
Specify the size the array values will use.
Requests that the capacity of the allocated storage space for the ALValue of the vector container be at least enough to hold size elements.
size | minimum amount desired as capacity of allocated storage |
ALError | if alvalue.type != TypeArray |
void AL::ALValue::arraySetSize | ( | int | size | ) |
Specify the size of the array this will call vector::resize.
size | the new size of the array |
bool AL::ALValue::decodeB64 | ( | const char * | pszB64 | ) |
Decode a buffer from B64 to binary.
Decode a string containing some binaries encoded in B64 (binary 64 / uuencoded)
pszB64 | the buffer to decode |
bool AL::ALValue::decodeB64Object | ( | const char * | pszB64 | ) |
Decode a buffer from B64 to binary object.
Decode a string containing some binaries encoded in B64 (binary 64 / uuencoded)
pszB64 | the buffer to decode |
static enum Type AL::ALValue::deduceType | ( | const char * | szInput, |
int | nLimitToLen = 0x7FFFFFFF |
||
) | [static] |
Analyses a string and try to guess the type of data describe in the string.
eg: "5" => int; "'toto'" => string; [3,5] => array ...
szInput | a text to analyse, eg: "[36, 3, "toto", 3.5, [1,2,3]]" |
nLimitToLen | limit analysis to nLimitToLen first characters |
ALERROR |
void AL::ALValue::encodeB64 | ( | std::string & | strOutput | ) | const |
Encode a binaries alvalue to B64 (binary 64 / uuencoded).
strOutput | the buffer to receive or data encoded in B64 |
TAlValueArray* AL::ALValue::getArrayPtr | ( | ) | const |
Get pointer on array value.
const void* AL::ALValue::GetBinary | ( | ) | const |
Explicit operator to convert to const void*.
const void* AL::ALValue::getObject | ( | ) | const |
Explicit operator to convert to const void*.
float* AL::ALValue::getPtrValue | ( | ) |
Get pointer on value, only allowed with 32bits variable.
unsigned int AL::ALValue::getSize | ( | ) | const |
Get the size for string, objectm array, binary, invalid values.
ALERROR | if the value is null |
enum Type AL::ALValue::getType | ( | ) | const |
const unionValue AL::ALValue::getUnionValue | ( | ) |
Get the value of the ALValue.
bool AL::ALValue::isArray | ( | ) | const |
Check if the value is an array.
bool AL::ALValue::isBinary | ( | ) | const |
Check if the value is a binary.
bool AL::ALValue::isBool | ( | ) | const |
Check if the value is a boolean.
bool AL::ALValue::isFloat | ( | ) | const |
Check if the value is a float.
bool AL::ALValue::isInt | ( | ) | const |
Check if the value is an integer.
bool AL::ALValue::isObject | ( | ) | const |
Check if the value is a binary object.
bool AL::ALValue::isString | ( | ) | const |
Check if the value is a string.
bool AL::ALValue::isValid | ( | ) | const |
Check if the value has been set.
AL::ALValue::operator bool & | ( | ) |
Conversion operator to bool.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator const bool | ( | ) | const |
Conversion operator to const bool.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator const double | ( | ) | const |
Conversion operator to const double.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator const float | ( | ) | const |
Conversion operator to const float.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator const int | ( | ) | const |
Conversion operator to const int.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator const std::string & | ( | ) | const |
Conversion operator to const std::string.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator const TAlValueBinaryData & | ( | ) | const |
Conversion operator to const binary data.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator const void * | ( | ) | const |
Conversion operator to const void*.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator float & | ( | ) |
Conversion operator to float.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator int & | ( | ) |
Conversion operator to int.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator std::string & | ( | ) |
Conversion operator to std::string.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator TAlValueBinaryData & | ( | ) |
Conversion operator to binary data.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator TFloatArray | ( | ) | const |
Conversion operator to a vector of float.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator TIntArray | ( | ) | const |
Conversion operator to a vector of int.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
AL::ALValue::operator TStringArray | ( | ) | const |
Conversion operator to a vector of stf::string.
Assert the object is compatible with a wanted type. If the object is unitialiazed, it will be changed to the good type
ALERROR |
bool AL::ALValue::operator!= | ( | ALValue const & | other | ) | const |
alvalue.Type != other.alvalue.Type && alvalue.unionValue != other.alvalue.unionValue
Makes a copy of rhs, discarding previous content, so that the new content of is equivalent in both type and value to rhs.
rhs | value copied |
ALValue& AL::ALValue::operator= | ( | const bool & | rhs | ) |
ALValue& AL::ALValue::operator= | ( | const int & | rhs | ) |
ALValue& AL::ALValue::operator= | ( | const double & | rhs | ) |
ALValue& AL::ALValue::operator= | ( | const float & | rhs | ) |
ALValue& AL::ALValue::operator= | ( | const char * | rhs | ) |
ALValue& AL::ALValue::operator= | ( | const TAlValueBinaryData & | rhs | ) |
bool AL::ALValue::operator== | ( | ALValue const & | other | ) | const |
alvalue.Type == other.alvalue.Type && alvalue.unionValue == other.alvalue.unionValue
ALValue& AL::ALValue::operator[] | ( | int | i | ) |
const ALValue& AL::ALValue::operator[] | ( | int | i | ) | const |
std::string AL::ALValue::serializeToText | ( | void | ) | const |
void AL::ALValue::SetBinary | ( | const void * | rhs, |
int | nDataSizeInBytes | ||
) |
Set ALValue with a binary data.
rhs | pointer to data |
nDataSizeInBytes | data's size |
ALValue& AL::ALValue::SetBinaryNoCopy | ( | const void * | rhs, |
int | nDataSizeInBytes | ||
) |
ALValue& AL::ALValue::setObject | ( | const void * | pData, |
int | nDataSizeInBytes | ||
) |
void AL::ALValue::ToFloatArray | ( | TFloatArray & | pArrayToFill, |
bool | bInsertDefaultOnError = false |
||
) | const |
Explicit convert to vector<float>.
pArrayToFill | the value to fill with string value from the ALValue |
bInsertDefaultOnError | a flag to inform what to do on a not wanted type. If set to false, invalid value are skipped, on true empty string will be inserted in the vector |
void AL::ALValue::ToIntArray | ( | TIntArray & | pArrayToFill, |
bool | bInsertDefaultOnError = false |
||
) | const |
Explicit convert to vector<int>.
pArrayToFill | the value to fill with string value from the ALValue |
bInsertDefaultOnError | a flag to inform what to do on a not wanted type. If set to false, invalid value are skipped, on true empty string will be inserted in the vector |
std::string AL::ALValue::toPythonBuffer | ( | ) | const |
Build python buffer from ALValue binary.
Decode a string containing some binaries encoded in B64 (binary 64 / uuencoded).
std::string AL::ALValue::toString | ( | Verbosity | pnVerbosity = VerbosityMini | ) | const |
Get a string describing this object, for debug purpose.
pnVerbosity | style of ouput format |
ALERROR |
void AL::ALValue::ToStringArray | ( | TStringArray & | pArrayToFill, |
bool | bInsertDefaultOnError = false |
||
) | const |
Explicit convert to vector<string>.
pArrayToFill | the value to fill with string value from the ALValue |
bInsertDefaultOnError | a flag to inform what to do on a not wanted type. If set to false, invalid value are skipped, on true empty string will be inserted in the vector |
static std::string AL::ALValue::TypeToString | ( | enum Type | pnType | ) | [static] |
Get a string with name of ALValue type.
void AL::ALValue::unSerializeFromText | ( | const char * | szInput, |
int | nLimitToLen = 0x7FFFFFFF |
||
) |
Create an ALValue from a text.
szInput | the source analysed to construct the alvalue, eg: "1" or "[36,3,"toto",3.5,[1,2,3]]" |
nLimitToLen | limit analysis to nLimitToLen first characters (used in recursion) |
ALERROR |
static bool AL::ALValue::xUnSerializeFromText_InnerTest | ( | void | ) | [static] |
Internal function to validate the correct functionnality of unSerializeFromText.