MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / Variant

Class Variant

include/cpp/Variant.h:21–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 template<> inline bool isStringType(const cpp::Variant &inRHS);
20
21 struct Variant
22 {
23 enum Type
24 {
25 typeObject = 0,
26 typeString,
27 typeDouble,
28 typeInt,
29 typeInt64,
30 typeBool,
31 };
32
33 union
34 {
35 // Although this is typed as 'char', it might be char16_t in the case of smart strings
36 const char *valStringPtr;
37 hx::Object *valObject;
38 double valDouble;
39 cpp::Int64 valInt64;
40 int valInt;
41 bool valBool;
42 };
43 Type type;
44 unsigned int valStringLen;
45
46
47
48 inline bool isNull() const {
49 return (type==typeObject && !valObject) || (type==typeString && !valStringPtr); }
50 inline bool isNumeric() const;
51 inline bool isBool() const;
52 inline int asInt() const;
53 inline bool isInt() const;
54 inline cpp::Int64 asInt64() const;
55 inline bool isInt64() const;
56 inline bool isString() const;
57 inline double asDouble() const;
58 inline hx::Object *asObject() const { return type==typeObject ? valObject : 0; }
59 inline hx::Object *asDynamic() const{ return type==typeObject ? valObject : toDynamic(); }
60 inline hx::Object *toDynamic() const; // later
61 inline String asString() const;
62 inline String getString() const;
63
64 inline Variant() : valInt64(0), type(typeObject) { }
65 //inline Variant() { copyBuf.b[0] = copyBuf.b[1] = 0; }
66 inline Variant(const null &) : type(typeObject), valObject(0) { }
67 inline Variant(bool inValue) : type(typeBool), valBool(inValue) { }
68 inline Variant(double inValue) : type(typeDouble), valDouble(inValue) { }
69 inline Variant(const ::String &inValue); // later
70
71 inline Variant(cpp::Int64 inValue) : type(typeInt64), valInt64(inValue) { }
72 inline Variant(cpp::UInt64 inValue) : type(typeInt64), valInt64(inValue) { }
73 inline Variant(int inValue) : type(typeInt), valInt(inValue) { }
74 inline Variant(cpp::UInt32 inValue) : type(typeInt), valInt(inValue) { }
75 inline Variant(cpp::Int16 inValue) : type(typeInt), valInt(inValue) { }
76 inline Variant(cpp::UInt16 inValue) : type(typeInt), valInt(inValue) { }
77 inline Variant(cpp::Int8 inValue) : type(typeInt), valInt(inValue) { }
78 inline Variant(cpp::UInt8 inValue) : type(typeInt), valInt(inValue) { }

Callers 1

Variant.hFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected