#include <mcllib/MCVariant.h>
Inheritance diagram for MCVariantType:
Public Types | |
typedef const MCVariantType & | constref_MCVariantType |
Type of a const regeference to a variant type. | |
Public Member Functions | |
mcuint32 | getTypeId () const |
Obtain the internal type identifier for the variant. | |
const MCString & | getTypeName () const |
Get the name of the type of this variant. | |
bool | isDefined () const |
Determine if the variant value is undefined. | |
MCVariantType (const MCVariantType &vt) | |
Copy constructor. | |
MCVariantType () | |
Default constructor. | |
operator bool () const | |
Determine if the variant value can be considered true. | |
bool | operator< (const MCVariantType &vt) const |
Test if this variant type is less than another. | |
MCVariantType & | operator= (const MCVariantType &vt) |
Assigment. | |
bool | operator== (const MCVariantType &vt) const |
Test if this variant type is equal to another. | |
void | put (MCStringStream &os) const |
Put to a string stream. | |
void | put (MCSerializer &serializer) const |
Put to a serializer (serialize it). | |
MCString | toString () const |
Get a string representation of the value. | |
~MCVariantType () | |
Destructor. | |
Static Public Member Functions | |
mcuint32 | getTypeId (const char *typeName) |
Obtain the type id for a type name. | |
const MCString & | getTypeName (mcuint32 typeId) |
Get the type name of a type id. | |
MCVariantType | parse (const MCString &val) |
Parse a string and return a variant object for that string If the string is an empty string, or the special string "null" (excluding quotes and irrespective of case), an undefined variant value is returned. | |
Protected Member Functions | |
mclpriv::MCVTImpl * | getImpl () |
Obtain the private implementation contained in the variant type. | |
const mclpriv::MCVTImpl * | getImpl () const |
Obtain the private implementation contained in the variant type. | |
MCVariantType (const MCVariantType &vt, mcuint32 type) | |
Constructor used by derived types. | |
MCVariantType (mcuint32 type) | |
Constructor used by derived types. | |
Friends | |
MCStringStream & | operator<< (MCStringStream &os, MCVariantType &vt) |
Alternative put to MCStringStream using << syntax. | |
MCSerializer & | operator<< (MCSerializer &os, MCVariantType &vt) |
Alternative put to serializer using << syntax. |
Variants store any of the data types used by the rest of the library. There is no derived type to represent an undefined value. An undefined value means an empty variant was constructed and not assigned to. Undefined values equates to unset or null in other languages. Variants are typically used in the interface to systems where many different types of data can be transferred over the API boundary and the developer does not know in advance which type of data will be returned (example Database API, SNMP API)
|
Default constructor. Creates a undefined value |
|
Destructor. Clean up the implementation. |
|
Copy constructor. If the target variant type cannot accept values of the source variant type then an exception is thrown. |
|
Obtain the type id for a type name.
|
|
Obtain the internal type identifier for the variant. ALl variants of the same type have the same type identifier. The type ids are used to distinguish between the various types.
|
|
Get the type name of a type id.
|
|
Get the name of the type of this variant.
|
|
Determine if the variant value is undefined. All derived classes construct defined values. Only the MCVariantType() constructor will construct an undefined value.
|
|
Determine if the variant value can be considered true. Every value of the standard variant types returns true except for the following:-
|
|
Test if this variant type is less than another.
|
|
Assigment. If the target variant type cannot accept values of the source variant type then an exception is thrown. |
|
Test if this variant type is equal to another.
|
|
Parse a string and return a variant object for that string If the string is an empty string, or the special string "null" (excluding quotes and irrespective of case), an undefined variant value is returned. If the string is an integer value (as determined by strtol()) with no trailing characters, a MCVTInt64 variant value is returned. If the string is a float value (as determined by strtod()) with no trailing characters, a MCVTFloat64 variant value is returned. If the string is the special strings "true" or "false" (excluding quotes and irrespective of case), the corresponding MCVTBool variant value is returned. Otherwise an MCVTString variant value is returned.
|
|
Put to a string stream. The contained data is converted to a string representation when it is put to a string stream.
|
|
Put to a serializer (serialize it).
|
|
Get a string representation of the value. To get greater control (e.g. over numeric output format) put the variant to an ostream after putting suitable IO manipulators to the ostream
|