MeVisLabToolboxReference
|
The Variant class stores different data types. More...
#include <mlVariant.h>
Public Types | |
enum | Type { Invalid, Bool, String, Int, UInt, Int64, UInt64, Float, Double, Vec2, Vec3, Vec4, Vec6, Mat3, Mat4, FilePath, PngImageData, JpgImageData, TypeCount } |
Public Member Functions | |
Variant () | |
Variant (const Variant &value) | |
Variant (const std::string &value) | |
Variant (Type type, const std::string &value) | |
use this for FilePath, PngImageData, JpgImageData | |
Variant (bool value) | |
Variant (MLint32 value) | |
Variant (MLuint32 value) | |
Variant (MLint64 value) | |
Variant (MLuint64 value) | |
Variant (MLfloat value) | |
Variant (MLdouble value) | |
Variant (const Vector2 &value) | |
Variant (const Vector3 &value) | |
Variant (const Vector4 &value) | |
Variant (const Vector6 &value) | |
Variant (const Matrix3 &value) | |
Variant (const Matrix4 &value) | |
Variant (Type type, const void *valuePtr) | |
for internal use, copies data from valuePtr, with length according to type | |
Type | type () const |
get type of variant | |
bool | isValid () const |
check if the Variants type is not Invalid | |
bool | canConvert (Type t) const |
check if the Variant can be converted to the given type | |
template<typename T > | |
const T & | asType () const |
access content of variant directly, NOTE: use with care | |
void | clear () |
free memory currently occupied by Variant and set type to Invalid | |
std::string | toString () const |
bool | toBool () const |
MLint32 | toInt (bool *ok=0) const |
MLuint32 | toUInt (bool *ok=0) const |
MLint64 | toInt64 (bool *ok=0) const |
MLuint64 | toUInt64 (bool *ok=0) const |
MLfloat | toFloat (bool *ok=0) const |
MLdouble | toDouble (bool *ok=0) const |
Vector2 | toVec2 (bool *ok=0) const |
Vector3 | toVec3 (bool *ok=0) const |
Vector4 | toVec4 (bool *ok=0) const |
Vector6 | toVec6 (bool *ok=0) const |
Matrix3 | toMat3 (bool *ok=0) const |
Matrix4 | toMat4 (bool *ok=0) const |
Variant & | operator= (const Variant &v) |
bool | operator== (const Variant &v) const |
bool | operator!= (const Variant &v) const |
std::ostream & | write (std::ostream &out, bool asBinary, bool writeType=true) const |
write variant to/read variant from stream, either as text or in binary form | |
std::istream & | read (std::istream &in, bool asBinary) |
template<> | |
void | writeValueAsText (std::ostream &out, const float &value) |
template<> | |
void | writeValueAsText (std::ostream &out, const double &value) |
Static Public Member Functions | |
static std::ostream & | writeEscapedString (std::ostream &out, const std::string &s) |
write/read quoted, escaped string, for persistence | |
static std::string | readEscapedString (std::istream &in) |
template<typename T > | |
static void | writeValue (std::ostream &out, const T &value, bool binary, bool last=true) |
write value to/read value from stream, either as text or in binary form; if last is false, a comma is appended/expected (and skipped) after the value | |
template<typename T > | |
static void | readValue (std::istream &in, T &value, bool binary, bool last=true) |
template<typename T > | |
static void | writeValueAsText (std::ostream &out, const T &value) |
write value to stream as text, temporarily sets sufficient precision for float and double values (this assumes that the default number format is used) | |
static MLuint32 | getCodeForType (Type t) |
translation between variant type and 4-char-codes (used in both persistence types) | |
static Type | getTypeForCode (MLuint32) |
The Variant class stores different data types.
Conversion between (integer) types is supported to some degree.
Definition at line 28 of file mlVariant.h.
enum ml::Variant::Type |
Invalid | |
Bool | |
String | |
Int | |
UInt | |
Int64 | |
UInt64 | |
Float | |
Double | |
Vec2 | |
Vec3 | |
Vec4 | |
Vec6 | |
Mat3 | |
Mat4 | |
FilePath | |
PngImageData | |
JpgImageData | |
TypeCount |
Definition at line 31 of file mlVariant.h.
ml::Variant::Variant | ( | ) |
ml::Variant::Variant | ( | const Variant & | value | ) |
ml::Variant::Variant | ( | const std::string & | value | ) |
ml::Variant::Variant | ( | Type | type, |
const std::string & | value | ||
) |
use this for FilePath, PngImageData, JpgImageData
ml::Variant::Variant | ( | bool | value | ) |
ml::Variant::Variant | ( | MLint32 | value | ) |
ml::Variant::Variant | ( | MLuint32 | value | ) |
ml::Variant::Variant | ( | MLint64 | value | ) |
ml::Variant::Variant | ( | MLuint64 | value | ) |
ml::Variant::Variant | ( | MLfloat | value | ) |
ml::Variant::Variant | ( | MLdouble | value | ) |
ml::Variant::Variant | ( | const Vector2 & | value | ) |
ml::Variant::Variant | ( | const Vector3 & | value | ) |
ml::Variant::Variant | ( | const Vector4 & | value | ) |
ml::Variant::Variant | ( | const Vector6 & | value | ) |
ml::Variant::Variant | ( | const Matrix3 & | value | ) |
ml::Variant::Variant | ( | const Matrix4 & | value | ) |
ml::Variant::Variant | ( | Type | type, |
const void * | valuePtr | ||
) |
for internal use, copies data from valuePtr, with length according to type
const T& ml::Variant::asType | ( | ) | const [inline] |
access content of variant directly, NOTE: use with care
Definition at line 70 of file mlVariant.h.
References T.
Referenced by ml::CSOReadValueFromStream().
bool ml::Variant::canConvert | ( | Type | t | ) | const |
check if the Variant can be converted to the given type
void ml::Variant::clear | ( | ) |
free memory currently occupied by Variant and set type to Invalid
translation between variant type and 4-char-codes (used in both persistence types)
bool ml::Variant::isValid | ( | void | ) | const [inline] |
check if the Variants type is not Invalid
Definition at line 63 of file mlVariant.h.
Referenced by ml::CSOReadValueFromStream(), and ml::CSOReadValueFromStream< CSOPathPoints >().
bool ml::Variant::operator!= | ( | const Variant & | v | ) | const |
bool ml::Variant::operator== | ( | const Variant & | v | ) | const |
std::istream& ml::Variant::read | ( | std::istream & | in, |
bool | asBinary | ||
) |
Referenced by ml::CSOReadValueFromStream(), and ml::CSOReadValueFromStream< CSOPathPoints >().
static std::string ml::Variant::readEscapedString | ( | std::istream & | in | ) | [static] |
void ml::Variant::readValue | ( | std::istream & | in, |
T & | value, | ||
bool | binary, | ||
bool | last = true |
||
) | [static] |
Definition at line 183 of file mlVariant.h.
References T.
bool ml::Variant::toBool | ( | ) | const |
MLdouble ml::Variant::toDouble | ( | bool * | ok = 0 | ) | const |
MLfloat ml::Variant::toFloat | ( | bool * | ok = 0 | ) | const |
MLint32 ml::Variant::toInt | ( | bool * | ok = 0 | ) | const |
Referenced by ml::CSOReadValueFromStream< CSOPathPoints >().
MLint64 ml::Variant::toInt64 | ( | bool * | ok = 0 | ) | const |
Matrix3 ml::Variant::toMat3 | ( | bool * | ok = 0 | ) | const |
Matrix4 ml::Variant::toMat4 | ( | bool * | ok = 0 | ) | const |
std::string ml::Variant::toString | ( | ) | const |
MLuint32 ml::Variant::toUInt | ( | bool * | ok = 0 | ) | const |
MLuint64 ml::Variant::toUInt64 | ( | bool * | ok = 0 | ) | const |
Vector2 ml::Variant::toVec2 | ( | bool * | ok = 0 | ) | const |
Vector3 ml::Variant::toVec3 | ( | bool * | ok = 0 | ) | const |
Vector4 ml::Variant::toVec4 | ( | bool * | ok = 0 | ) | const |
Vector6 ml::Variant::toVec6 | ( | bool * | ok = 0 | ) | const |
Type ml::Variant::type | ( | ) | const [inline] |
get type of variant
Definition at line 60 of file mlVariant.h.
std::ostream& ml::Variant::write | ( | std::ostream & | out, |
bool | asBinary, | ||
bool | writeType = true |
||
) | const |
write variant to/read variant from stream, either as text or in binary form
Referenced by ml::CSOWriteValueToStream(), and ml::CSOWriteValueToStream< CSOPathPoints >().
static std::ostream& ml::Variant::writeEscapedString | ( | std::ostream & | out, |
const std::string & | s | ||
) | [static] |
write/read quoted, escaped string, for persistence
void ml::Variant::writeValue | ( | std::ostream & | out, |
const T & | value, | ||
bool | binary, | ||
bool | last = true |
||
) | [static] |
write value to/read value from stream, either as text or in binary form; if last is false, a comma is appended/expected (and skipped) after the value
Definition at line 170 of file mlVariant.h.
References T.
void ml::Variant::writeValueAsText | ( | std::ostream & | out, |
const float & | value | ||
) | [inline] |
Definition at line 152 of file mlVariant.h.
void ml::Variant::writeValueAsText | ( | std::ostream & | out, |
const double & | value | ||
) | [inline] |
Definition at line 161 of file mlVariant.h.
void ml::Variant::writeValueAsText | ( | std::ostream & | out, |
const T & | value | ||
) | [inline, static] |
write value to stream as text, temporarily sets sufficient precision for float and double values (this assumes that the default number format is used)
Definition at line 146 of file mlVariant.h.