MeVisLab Toolbox Reference
|
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 () | |
Variant (const Variant &value) | |
Variant (const std::string &value) | |
Variant (Type type, const std::string &value) | |
use this for FilePath, PngImageData, JpgImageData More... | |
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 More... | |
Type | type () const |
get type of variant More... | |
bool | isValid () const |
check if the Variants type is not Invalid More... | |
bool | canConvert (Type t) const |
check if the Variant can be converted to the given type More... | |
template<typename T > | |
const T & | asType () const |
access content of variant directly, NOTE: use with care More... | |
void | clear () |
free memory currently occupied by Variant and set type to Invalid More... | |
std::string | toString () const |
bool | toBool () const |
MLint32 | toInt (bool *ok=nullptr) const |
MLuint32 | toUInt (bool *ok=nullptr) const |
MLint64 | toInt64 (bool *ok=nullptr) const |
MLuint64 | toUInt64 (bool *ok=nullptr) const |
MLfloat | toFloat (bool *ok=nullptr) const |
MLdouble | toDouble (bool *ok=nullptr) const |
Vector2 | toVec2 (bool *ok=nullptr) const |
Vector3 | toVec3 (bool *ok=nullptr) const |
Vector4 | toVec4 (bool *ok=nullptr) const |
Vector6 | toVec6 (bool *ok=nullptr) const |
Matrix3 | toMat3 (bool *ok=nullptr) const |
Matrix4 | toMat4 (bool *ok=nullptr) 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 More... | |
std::istream & | read (std::istream &in, bool asBinary) |
Static Public Member Functions | |
template<> | |
void | writeValueAsText (std::ostream &out, const float &value) |
template<> | |
void | writeValueAsText (std::ostream &out, const double &value) |
static std::ostream & | writeEscapedString (std::ostream &out, const std::string &s) |
static public utility methods More... | |
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 More... | |
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) More... | |
static MLuint32 | getCodeForType (Type t) |
translation between variant type and 4-char-codes (used in both persistence types) More... | |
static Type | getTypeForCode (MLuint32) |
The Variant class stores different data types.
Conversion between (integer) types is supported to some degree.
Definition at line 35 of file mlVariant.h.
enum ml::Variant::Type |
Enumerator | |
---|---|
Invalid | |
Bool | |
String | |
Int | |
UInt | |
Int64 | |
UInt64 | |
Float | |
Double | |
Vec2 | |
Vec3 | |
Vec4 | |
Vec6 | |
Mat3 | |
Mat4 | |
FilePath | |
PngImageData | |
JpgImageData | |
TypeCount |
Definition at line 38 of file mlVariant.h.
ml::Variant::Variant | ( | ) |
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
|
inline |
access content of variant directly, NOTE: use with care
Definition at line 78 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)
|
inline |
check if the Variants type is not Invalid
Definition at line 71 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 | ||
) |
|
static |
|
static |
Definition at line 191 of file mlVariant.h.
References T.
bool ml::Variant::toBool | ( | ) | const |
MLdouble ml::Variant::toDouble | ( | bool * | ok = nullptr | ) | const |
MLfloat ml::Variant::toFloat | ( | bool * | ok = nullptr | ) | const |
MLint32 ml::Variant::toInt | ( | bool * | ok = nullptr | ) | const |
MLint64 ml::Variant::toInt64 | ( | bool * | ok = nullptr | ) | const |
Matrix3 ml::Variant::toMat3 | ( | bool * | ok = nullptr | ) | const |
Matrix4 ml::Variant::toMat4 | ( | bool * | ok = nullptr | ) | const |
std::string ml::Variant::toString | ( | ) | const |
MLuint32 ml::Variant::toUInt | ( | bool * | ok = nullptr | ) | const |
MLuint64 ml::Variant::toUInt64 | ( | bool * | ok = nullptr | ) | const |
Vector2 ml::Variant::toVec2 | ( | bool * | ok = nullptr | ) | const |
Vector3 ml::Variant::toVec3 | ( | bool * | ok = nullptr | ) | const |
Vector4 ml::Variant::toVec4 | ( | bool * | ok = nullptr | ) | const |
Vector6 ml::Variant::toVec6 | ( | bool * | ok = nullptr | ) | const |
|
inline |
get type of variant
Definition at line 68 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(), ml::CSOWriteValueToStream< CSOPathPoints >(), and ml::CSOWriteValueToStream< Variant >().
|
static |
static public utility methods
write/read quoted, escaped string, for persistence
|
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 178 of file mlVariant.h.
References T.
|
inlinestatic |
Definition at line 169 of file mlVariant.h.
|
inlinestatic |
Definition at line 160 of file mlVariant.h.
|
inlinestatic |
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 154 of file mlVariant.h.