Nebula
Loading...
Searching...
No Matches
variant.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
15#include "math/vec2.h"
16#include "math/vec4.h"
17#include "math/mat4.h"
18#include "math/quat.h"
19#include "math/transform44.h"
20#include "util/string.h"
21#include "util/guid.h"
22#include "util/blob.h"
23#include "memory/memory.h"
24#include "core/refcounted.h"
25
26//------------------------------------------------------------------------------
27namespace Util
28{
30{
31public:
69
71 Variant();
73 Variant(byte rhs);
75 Variant(short rhs);
77 Variant(ushort rhs);
79 Variant(int rhs);
81 Variant(uint rhs);
83 Variant(int64_t rhs);
85 Variant(uint64_t rhs);
87 Variant(float rhs);
89 Variant(double rhs);
91 Variant(bool rhs);
93 Variant(const Math::vec2& v);
95 Variant(const Math::vec3& v);
97 Variant(const Math::vec4& v);
99 Variant(const Math::quat& q);
101 Variant(const Math::mat4& m);
105 Variant(const Util::String& rhs);
107 Variant(const Util::Blob& blob);
109 Variant(const Util::Guid& guid);
111 Variant(const char* chrPtr);
115 Variant(void* ptr);
117 Variant(std::nullptr_t);
119 Variant(const Util::Array<int>& rhs);
121 Variant(const Util::Array<float>& rhs);
123 Variant(const Util::Array<bool>& rhs);
139 Variant(const Variant& rhs);
140
142 ~Variant();
144 void SetType(Type t);
146 Type GetType() const;
148 void Clear();
149
151 void operator=(const Variant& rhs);
153 void operator=(byte val);
155 void operator=(short val);
157 void operator=(ushort val);
159 void operator=(int val);
161 void operator=(uint val);
163 void operator=(int64_t val);
165 void operator=(uint64_t val);
167 void operator=(float val);
169 void operator=(double val);
171 void operator=(bool val);
173 void operator=(const Math::vec2& val);
175 void operator=(const Math::vec3& val);
177 void operator=(const Math::vec4& val);
179 void operator=(const Math::quat& val);
181 void operator=(const Math::mat4& val);
183 void operator=(const Math::transform44& val);
185 void operator=(const Util::String& s);
187 void operator=(const Util::Blob& val);
189 void operator=(const Util::Guid& val);
191 void operator=(const char* chrPtr);
193 void operator=(Core::RefCounted* ptr);
195 void operator=(void* ptr);
197 void operator=(const Util::Array<int>& rhs);
199 void operator=(const Util::Array<float>& rhs);
201 void operator=(const Util::Array<bool>& rhs);
203 void operator=(const Util::Array<Math::vec2>& rhs);
205 void operator=(const Util::Array<Math::vec3>& rhs);
207 void operator=(const Util::Array<Math::vec4>& rhs);
209 void operator=(const Util::Array<Math::mat4>& rhs);
211 void operator=(const Util::Array<Util::String>& rhs);
213 void operator=(const Util::Array<Util::Blob>& rhs);
215 void operator=(const Util::Array<Util::Guid>& rhs);
216
218 bool operator==(const Variant& rhs) const;
220 bool operator==(byte rhs) const;
222 bool operator==(short rhs) const;
224 bool operator==(ushort rhs) const;
226 bool operator==(int rhs) const;
228 bool operator==(uint rhs) const;
230 bool operator==(int64_t rhs) const;
232 bool operator==(uint64_t rhs) const;
234 bool operator==(float rhs) const;
236 bool operator==(double rhs) const;
238 bool operator==(bool rhs) const;
240 bool operator==(const Math::vec2& rhs) const;
242 bool operator==(const Math::vec4& rhs) const;
244 bool operator==(const Math::quat& rhs) const;
246 bool operator==(const Util::String& rhs) const;
248 bool operator==(const Util::Guid& rhs) const;
250 bool operator==(const char* chrPtr) const;
252 bool operator==(Core::RefCounted* ptr) const;
254 bool operator==(void* ptr) const;
255
257 bool operator!=(const Variant& rhs) const;
259 bool operator!=(byte rhs) const;
261 bool operator!=(short rhs) const;
263 bool operator!=(ushort rhs) const;
265 bool operator!=(int rhs) const;
267 bool operator!=(uint rhs) const;
269 bool operator!=(int64_t rhs) const;
271 bool operator!=(uint64_t rhs) const;
273 bool operator!=(float rhs) const;
275 bool operator!=(double rhs) const;
277 bool operator!=(bool rhs) const;
279 bool operator!=(const Math::vec2& rhs) const;
281 bool operator!=(const Math::vec4& rhs) const;
283 bool operator!=(const Math::quat& rhs) const;
285 bool operator!=(const Util::String& rhs) const;
287 bool operator!=(const Util::Guid& rhs) const;
289 bool operator!=(const char* chrPtr) const;
291 bool operator!=(Core::RefCounted* ptr) const;
293 bool operator!=(void* ptr) const;
294
296 bool operator>(const Variant& rhs) const;
298 bool operator<(const Variant& rhs) const;
300 bool operator>=(const Variant& rhs) const;
302 bool operator<=(const Variant& rhs) const;
303
305 void SetByte(byte val);
307 byte GetByte() const;
309 void SetShort(short val);
311 short GetShort() const;
313 void SetUShort(ushort val);
315 ushort GetUShort() const;
317 void SetInt(int val);
319 int GetInt() const;
321 void SetUInt(uint val);
323 uint GetUInt() const;
325 void SetInt64(int64_t val);
327 int64_t GetInt64() const;
329 void SetUInt64(uint64_t val);
331 uint64_t GetUInt64() const;
333 void SetFloat(float val);
335 float GetFloat() const;
337 void SetDouble(double val);
339 double GetDouble() const;
341 void SetBool(bool val);
343 bool GetBool() const;
345 void SetString(const Util::String& val);
347 const Util::String& GetString() const;
349 void SetVec2(const Math::vec2& val);
351 Math::vec2 GetVec2() const;
353 void SetVec3(const Math::vec3& val);
355 Math::vec3 GetVec3() const;
357 void SetVec4(const Math::vec4& val);
359 Math::vec4 GetVec4() const;
361 void SetQuat(const Math::quat& val);
363 Math::quat GetQuat() const;
365 void SetMat4(const Math::mat4& val);
367 const Math::mat4& GetMat4() const;
369 void SetTransform44(const Math::transform44& val);
371 const Math::transform44& GetTransform44() const;
373 void SetBlob(const Util::Blob& val);
375 const Util::Blob& GetBlob() const;
377 void SetGuid(const Util::Guid& val);
379 const Util::Guid& GetGuid() const;
381 void SetObject(Core::RefCounted* ptr);
385 void SetVoidPtr(void* ptr);
387 void* GetVoidPtr() const;
389 void SetIntArray(const Util::Array<int>& val);
391 const Util::Array<int>& GetIntArray() const;
393 void SetFloatArray(const Util::Array<float>& val);
395 const Util::Array<float>& GetFloatArray() const;
397 void SetBoolArray(const Util::Array<bool>& val);
399 const Util::Array<bool>& GetBoolArray() const;
401 void SetVec2Array(const Util::Array<Math::vec2>& val);
405 void SetVec3Array(const Util::Array<Math::vec3>& val);
409 void SetVec4Array(const Util::Array<Math::vec4>& val);
413 void SetMat4Array(const Util::Array<Math::mat4>& val);
421 void SetGuidArray(const Util::Array<Util::Guid>& val);
425 void SetBlobArray(const Util::Array<Util::Blob>& val);
428
430 template <typename TYPE>
431 TYPE Get() const;
432
434 Util::String ToString() const;
436 bool SetParseString(const Util::String& string);
437
439 const SizeT Size() const;
441 const void* AsVoidPtr() const;
442
444 static Variant FromString(const Util::String& string);
448 static Type StringToType(const Util::String& str);
449
450private:
452 void Delete();
454 void Copy(const Variant& rhs);
455
457 union
458 {
459 byte i8;
460 short i16;
462 int i;
464 int64_t i64;
465 uint64_t u64;
466 bool b;
467 double d;
468 float f[4];
474 void* voidPtr;
486 };
487};
488
489//------------------------------------------------------------------------------
492inline
494 type(Void),
495 string(0)
496{
497 // empty
498}
499
500//------------------------------------------------------------------------------
503inline void
505{
506 if (String == this->type)
507 {
508 n_assert(this->string);
509 delete this->string;
510 this->string = 0;
511 }
512 else if (Mat4 == this->type)
513 {
514 n_assert(this->m);
515 delete this->m;
516 this->m = 0;
517 }
518 else if (Guid == this->type)
519 {
520 n_assert(this->guid);
521 delete this->guid;
522 this->guid = 0;
523 }
524 else if (Blob == this->type)
525 {
526 n_assert(this->blob);
527 delete this->blob;
528 this->blob = 0;
529 }
530 else if (Object == this->type)
531 {
532 if (this->object)
533 {
534 this->object->Release();
535 this->object = 0;
536 }
537 }
538 else if (VoidPtr == this->type)
539 {
540 this->voidPtr = 0;
541 }
542 else if (IntArray == this->type)
543 {
544 n_assert(this->intArray);
545 delete this->intArray;
546 this->intArray = 0;
547 }
548 else if (FloatArray == this->type)
549 {
550 n_assert(this->floatArray);
551 delete this->floatArray;
552 this->floatArray = 0;
553 }
554 else if (BoolArray == this->type)
555 {
556 n_assert(this->boolArray);
557 delete this->boolArray;
558 this->boolArray = 0;
559 }
560 else if (Vec2Array == this->type)
561 {
562 n_assert(this->vec2Array);
563 delete this->vec2Array;
564 this->vec2Array = 0;
565 }
566 else if (Vec3Array == this->type)
567 {
568 n_assert(this->float3Array);
569 delete this->float3Array;
570 this->float3Array = 0;
571 }
572 else if (Vec4Array == this->type)
573 {
574 n_assert(this->vec4Array);
575 delete this->vec4Array;
576 this->vec4Array = 0;
577 }
578 else if (Mat4Array == this->type)
579 {
580 n_assert(this->mat4Array);
581 delete this->mat4Array;
582 this->mat4Array = 0;
583 }
584 else if (StringArray == this->type)
585 {
586 n_assert(this->stringArray);
587 delete this->stringArray;
588 this->stringArray = 0;
589 }
590 else if (GuidArray == this->type)
591 {
592 n_assert(this->guidArray);
593 delete this->guidArray;
594 this->guidArray = 0;
595 }
596 else if (BlobArray == this->type)
597 {
598 n_assert(this->blobArray);
599 delete this->blobArray;
600 this->blobArray = 0;
601 }
602 this->type = Void;
603}
604
605//------------------------------------------------------------------------------
608inline void
610{
611 this->Delete();
612}
613
614//------------------------------------------------------------------------------
617inline void
619{
620 n_assert(Void == this->type);
621 this->type = rhs.type;
622 switch (rhs.type)
623 {
624 case Void:
625 break;
626 case Byte:
627 this->i8 = rhs.i8;
628 break;
629 case Short:
630 this->i16 = rhs.i16;
631 break;
632 case UShort:
633 this->ui16 = rhs.ui16;
634 break;
635 case Int:
636 this->i = rhs.i;
637 break;
638 case UInt:
639 this->u = rhs.u;
640 break;
641 case Int64:
642 this->i64 = rhs.i64;
643 break;
644 case UInt64:
645 this->u64 = rhs.u64;
646 break;
647 case Float:
648 this->f[0] = rhs.f[0];
649 break;
650 case Double:
651 this->d = rhs.d;
652 break;
653 case Bool:
654 this->b = rhs.b;
655 break;
656 case Vec2:
657 this->f[0] = rhs.f[0];
658 this->f[1] = rhs.f[1];
659 break;
660 case Vec3:
661 this->f[0] = rhs.f[0];
662 this->f[1] = rhs.f[1];
663 this->f[2] = rhs.f[2];
664 break;
665 case Vec4:
666 this->f[0] = rhs.f[0];
667 this->f[1] = rhs.f[1];
668 this->f[2] = rhs.f[2];
669 this->f[3] = rhs.f[3];
670 break;
671 case Quaternion:
672 this->f[0] = rhs.f[0];
673 this->f[1] = rhs.f[1];
674 this->f[2] = rhs.f[2];
675 this->f[3] = rhs.f[3];
676 break;
677 case String:
678 this->string = new Util::String(*rhs.string);
679 break;
680 case Mat4:
681 this->m = new Math::mat4(*rhs.m);
682 break;
683 case Transform44:
684 this->t = new Math::transform44(*rhs.t);
685 break;
686 case Blob:
687 this->blob = new Util::Blob(*rhs.blob);
688 break;
689 case Guid:
690 this->guid = new Util::Guid(*rhs.guid);
691 break;
692 case Object:
693 this->object = rhs.object;
694 if (this->object)
695 {
696 this->object->AddRef();
697 }
698 break;
699 case VoidPtr:
700 this->voidPtr = rhs.voidPtr;
701 break;
702 case IntArray:
703 this->intArray = new Util::Array<int>(*rhs.intArray);
704 break;
705 case FloatArray:
706 this->floatArray = new Util::Array<float>(*rhs.floatArray);
707 break;
708 case BoolArray:
709 this->boolArray = new Util::Array<bool>(*rhs.boolArray);
710 break;
711 case Vec2Array:
713 break;
714 case Vec3Array:
716 break;
717 case Vec4Array:
719 break;
720 case Mat4Array:
722 break;
723 case StringArray:
725 break;
726 case GuidArray:
728 break;
729 case BlobArray:
731 break;
732 default:
733 n_error("Variant::Copy(): invalid type!");
734 break;
735 }
736}
737
738//------------------------------------------------------------------------------
741inline
743 type(Void)
744{
745 this->Copy(rhs);
746}
747
748//------------------------------------------------------------------------------
751inline
753 type(Byte),
754 i8(rhs)
755{
756 // empty
757}
758
759//------------------------------------------------------------------------------
762inline
764 type(Short),
765 i16(rhs)
766{
767 // empty
768}
769
770//------------------------------------------------------------------------------
773inline
775 type(UShort),
776 ui16(rhs)
777{
778 // empty
779}
780
781//------------------------------------------------------------------------------
784inline
786 type(Int),
787 i(rhs)
788{
789 // empty
790}
791
792//------------------------------------------------------------------------------
795inline
797type(UInt),
798 u(rhs)
799{
800 // empty
801}
802
803//------------------------------------------------------------------------------
806inline
807Variant::Variant(int64_t rhs) :
808 type(Int64),
809 i64(rhs)
810{
811 // empty
812}
813
814//------------------------------------------------------------------------------
817inline
818Variant::Variant(uint64_t rhs) :
819 type(UInt64),
820 u64(rhs)
821{
822 // empty
823}
824//------------------------------------------------------------------------------
827inline
829 type(Float)
830{
831 this->f[0] = rhs;
832}
833
834//------------------------------------------------------------------------------
837inline
838Variant::Variant(double rhs) :
839 type(Double),
840 d(rhs)
841{
842 // empty
843}
844
845//------------------------------------------------------------------------------
848inline
850 type(Bool),
851 b(rhs)
852{
853 // empty
854}
855
856
857//------------------------------------------------------------------------------
860inline
862 type(Vec2)
863{
864 this->f[0] = rhs.x;
865 this->f[1] = rhs.y;
866}
867
868//------------------------------------------------------------------------------
871inline
873 type(Vec3)
874{
875 rhs.storeu(this->f);
876}
877
878//------------------------------------------------------------------------------
881inline
883 type(Vec4)
884{
885 rhs.storeu(this->f);
886}
887
888//------------------------------------------------------------------------------
891inline
893 type(Quaternion)
894{
895 rhs.storeu(this->f);
896}
897
898//------------------------------------------------------------------------------
901inline
903 type(String)
904{
905 this->string = new Util::String(rhs);
906}
907
908//------------------------------------------------------------------------------
911inline
912Variant::Variant(const char* chrPtr) :
913 type(String)
914{
915 this->string = new Util::String(chrPtr);
916}
917
918//------------------------------------------------------------------------------
921inline
923 type(Object)
924{
925 this->object = ptr;
926 if (this->object)
927 {
928 this->object->AddRef();
929 }
930}
931
932//------------------------------------------------------------------------------
935inline
937 type(VoidPtr)
938{
939 this->voidPtr = ptr;
940}
941
942//------------------------------------------------------------------------------
945inline
946Variant::Variant(std::nullptr_t) :
947 type(VoidPtr)
948{
949 this->voidPtr = nullptr;
950}
951
952//------------------------------------------------------------------------------
955inline
957 type(Mat4)
958{
959 this->m = new Math::mat4(rhs);
960}
961
962//------------------------------------------------------------------------------
965inline
967 type(Transform44)
968{
969 this->t = new Math::transform44(rhs);
970}
971
972//------------------------------------------------------------------------------
975inline
977 type(Blob)
978{
979 this->blob = new Util::Blob(rhs);
980}
981
982//------------------------------------------------------------------------------
985inline
987 type(Guid)
988{
989 this->guid = new Util::Guid(rhs);
990}
991
992//------------------------------------------------------------------------------
995inline
997 type(IntArray)
998{
999 this->intArray = new Util::Array<int>(rhs);
1000}
1001
1002//------------------------------------------------------------------------------
1005inline
1007 type(FloatArray)
1008{
1009 this->floatArray = new Util::Array<float>(rhs);
1010}
1011
1012//------------------------------------------------------------------------------
1015inline
1017 type(BoolArray)
1018{
1019 this->boolArray = new Util::Array<bool>(rhs);
1020}
1021
1022//------------------------------------------------------------------------------
1025inline
1027 type(Vec2Array)
1028{
1029 this->vec2Array = new Util::Array<Math::vec2>(rhs);
1030}
1031
1032//------------------------------------------------------------------------------
1035inline
1037 type(Vec3Array)
1038{
1039 this->float3Array = new Util::Array<Math::vec3>(rhs);
1040}
1041
1042//------------------------------------------------------------------------------
1045inline
1047 type(Vec4Array)
1048{
1049 this->vec4Array = new Util::Array<Math::vec4>(rhs);
1050}
1051
1052//------------------------------------------------------------------------------
1055inline
1057 type(Mat4Array)
1058{
1059 this->mat4Array = new Util::Array<Math::mat4>(rhs);
1060}
1061
1062//------------------------------------------------------------------------------
1065inline
1067 type(StringArray)
1068{
1069 this->stringArray = new Util::Array<Util::String>(rhs);
1070}
1071
1072//------------------------------------------------------------------------------
1075inline
1077 type(GuidArray)
1078{
1079 this->guidArray = new Util::Array<Util::Guid>(rhs);
1080}
1081
1082//------------------------------------------------------------------------------
1085inline
1087 type(BlobArray)
1088{
1089 this->blobArray = new Util::Array<Util::Blob>(rhs);
1090}
1091
1092//------------------------------------------------------------------------------
1095inline
1097{
1098 this->Delete();
1099}
1100
1101//------------------------------------------------------------------------------
1104inline void
1106{
1107 this->Delete();
1108 this->type = t;
1109 switch (t)
1110 {
1111 case String:
1112 this->string = new Util::String;
1113 break;
1114 case Mat4:
1115 this->m = new Math::mat4;
1116 break;
1117 case Transform44:
1118 this->t = new Math::transform44;
1119 break;
1120 case Blob:
1121 this->blob = new Util::Blob;
1122 break;
1123 case Guid:
1124 this->guid = new Util::Guid;
1125 break;
1126 case Object:
1127 this->object = 0;
1128 break;
1129 case VoidPtr:
1130 this->voidPtr = 0;
1131 break;
1132 case IntArray:
1133 this->intArray = new Util::Array<int>;
1134 break;
1135 case FloatArray:
1136 this->floatArray = new Util::Array<float>;
1137 break;
1138 case BoolArray:
1139 this->boolArray = new Util::Array<bool>;
1140 break;
1141 case Vec2Array:
1143 break;
1144 case Vec3Array:
1146 break;
1147 case Vec4Array:
1149 break;
1150 case Mat4Array:
1152 break;
1153 case StringArray:
1155 break;
1156 case GuidArray:
1158 break;
1159 case BlobArray:
1161 break;
1162 default:
1163 break;
1164 }
1165}
1166
1167//------------------------------------------------------------------------------
1170inline Variant::Type
1172{
1173 return this->type;
1174}
1175
1176//------------------------------------------------------------------------------
1179inline void
1181{
1182 this->Delete();
1183 this->Copy(rhs);
1184}
1185
1186//------------------------------------------------------------------------------
1189inline void
1191{
1192 this->Delete();
1193 this->type = Byte;
1194 this->i8 = val;
1195}
1196
1197//------------------------------------------------------------------------------
1200inline void
1202{
1203 this->Delete();
1204 this->type = Short;
1205 this->i16 = val;
1206}
1207
1208//------------------------------------------------------------------------------
1211inline void
1213{
1214 this->Delete();
1215 this->type = UShort;
1216 this->ui16 = val;
1217}
1218
1219//------------------------------------------------------------------------------
1222inline void
1224{
1225 this->Delete();
1226 this->type = Int;
1227 this->i = val;
1228}
1229
1230//------------------------------------------------------------------------------
1233inline void
1235{
1236 this->Delete();
1237 this->type = UInt;
1238 this->u = val;
1239}
1240
1241//------------------------------------------------------------------------------
1244inline void
1246{
1247 this->Delete();
1248 this->type = Int64;
1249 this->i64 = val;
1250}
1251
1252//------------------------------------------------------------------------------
1255inline void
1257{
1258 this->Delete();
1259 this->type = UInt64;
1260 this->u64 = val;
1261}
1262
1263//------------------------------------------------------------------------------
1266inline void
1268{
1269 this->Delete();
1270 this->type = Float;
1271 this->f[0] = val;
1272}
1273
1274//------------------------------------------------------------------------------
1277inline void
1279{
1280 this->Delete();
1281 this->type = Double;
1282 this->d = val;
1283}
1284
1285//------------------------------------------------------------------------------
1288inline void
1290{
1291 this->Delete();
1292 this->type = Bool;
1293 this->b = val;
1294}
1295
1296//------------------------------------------------------------------------------
1299inline void
1301{
1302 this->Delete();
1303 this->type = Vec2;
1304 this->f[0] = val.x;
1305 this->f[1] = val.y;
1306}
1307
1308//------------------------------------------------------------------------------
1311inline void
1313{
1314 this->Delete();
1315 this->type = Vec3;
1316 val.storeu(this->f);
1317}
1318
1319//------------------------------------------------------------------------------
1322inline void
1324{
1325 this->Delete();
1326 this->type = Vec4;
1327 val.storeu(this->f);
1328}
1329
1330//------------------------------------------------------------------------------
1333inline void
1335{
1336 this->Delete();
1337 this->type = Quaternion;
1338 val.storeu(this->f);
1339}
1340
1341//------------------------------------------------------------------------------
1344inline void
1346{
1347 if (String == this->type)
1348 {
1349 *this->string = s;
1350 }
1351 else
1352 {
1353 this->Delete();
1354 this->string = new Util::String(s);
1355 }
1356 this->type = String;
1357}
1358
1359//------------------------------------------------------------------------------
1362inline void
1363Variant::operator=(const char* chrPtr)
1364{
1365 *this = Util::String(chrPtr);
1366}
1367
1368//------------------------------------------------------------------------------
1371inline void
1373{
1374 if (Mat4 == this->type)
1375 {
1376 *this->m = val;
1377 }
1378 else
1379 {
1380 this->Delete();
1381 this->m = new Math::mat4(val);
1382 }
1383 this->type = Mat4;
1384}
1385
1386//------------------------------------------------------------------------------
1389inline void
1391{
1392 if (Transform44 == this->type)
1393 {
1394 *this->t = val;
1395 }
1396 else
1397 {
1398 this->Delete();
1399 this->t = new Math::transform44(val);
1400 }
1401 this->type = Transform44;
1402}
1403//------------------------------------------------------------------------------
1406inline void
1408{
1409 if (Guid == this->type)
1410 {
1411 *this->guid = val;
1412 }
1413 else
1414 {
1415 this->Delete();
1416 this->guid = new Util::Guid(val);
1417 }
1418 this->type = Guid;
1419}
1420
1421//------------------------------------------------------------------------------
1424inline void
1426{
1427 if (Blob == this->type)
1428 {
1429 *this->blob = val;
1430 }
1431 else
1432 {
1433 this->Delete();
1434 this->blob = new Util::Blob(val);
1435 }
1436 this->type = Blob;
1437}
1438
1439//------------------------------------------------------------------------------
1442inline void
1444{
1445 this->Delete();
1446 this->type = Object;
1447 this->object = ptr;
1448 if (this->object)
1449 {
1450 this->object->AddRef();
1451 }
1452}
1453
1454//------------------------------------------------------------------------------
1457inline void
1459{
1460 this->Delete();
1461 this->type = VoidPtr;
1462 this->voidPtr = ptr;
1463}
1464
1465//------------------------------------------------------------------------------
1468inline void
1470{
1471 if (IntArray == this->type)
1472 {
1473 *this->intArray = val;
1474 }
1475 else
1476 {
1477 this->Delete();
1478 this->intArray = new Util::Array<int>(val);
1479 }
1480 this->type = IntArray;
1481}
1482
1483//------------------------------------------------------------------------------
1486inline void
1488{
1489 if (FloatArray == this->type)
1490 {
1491 *this->floatArray = val;
1492 }
1493 else
1494 {
1495 this->Delete();
1496 this->floatArray = new Util::Array<float>(val);
1497 }
1498 this->type = FloatArray;
1499}
1500
1501//------------------------------------------------------------------------------
1504inline void
1506{
1507 if (BoolArray == this->type)
1508 {
1509 *this->boolArray = val;
1510 }
1511 else
1512 {
1513 this->Delete();
1514 this->boolArray = new Util::Array<bool>(val);
1515 }
1516 this->type = BoolArray;
1517}
1518
1519
1520//------------------------------------------------------------------------------
1523inline void
1525{
1526 if (Vec2Array == this->type)
1527 {
1528 *this->vec2Array = rhs;
1529 }
1530 else
1531 {
1532 this->Delete();
1533 this->vec2Array = new Util::Array<Math::vec2>(rhs);
1534 }
1535 this->type = Vec2Array;
1536}
1537
1538//------------------------------------------------------------------------------
1541inline void
1543{
1544 if (Vec3Array == this->type)
1545 {
1546 *this->float3Array = val;
1547 }
1548 else
1549 {
1550 this->Delete();
1551 this->float3Array = new Util::Array<Math::vec3>(val);
1552 }
1553 this->type = Vec3Array;
1554}
1555
1556//------------------------------------------------------------------------------
1559inline void
1561{
1562 if (Vec4Array == this->type)
1563 {
1564 *this->vec4Array = val;
1565 }
1566 else
1567 {
1568 this->Delete();
1569 this->vec4Array = new Util::Array<Math::vec4>(val);
1570 }
1571 this->type = Vec4Array;
1572}
1573
1574//------------------------------------------------------------------------------
1577inline void
1579{
1580 if (Mat4Array == this->type)
1581 {
1582 *this->mat4Array = val;
1583 }
1584 else
1585 {
1586 this->Delete();
1587 this->mat4Array = new Util::Array<Math::mat4>(val);
1588 }
1589 this->type = Mat4Array;
1590}
1591
1592//------------------------------------------------------------------------------
1595inline void
1597{
1598 if (StringArray == this->type)
1599 {
1600 *this->stringArray = val;
1601 }
1602 else
1603 {
1604 this->Delete();
1605 this->stringArray = new Util::Array<Util::String>(val);
1606 }
1607 this->type = StringArray;
1608}
1609
1610//------------------------------------------------------------------------------
1613inline void
1615{
1616 if (GuidArray == this->type)
1617 {
1618 *this->guidArray = val;
1619 }
1620 else
1621 {
1622 this->Delete();
1623 this->guidArray = new Util::Array<Util::Guid>(val);
1624 }
1625 this->type = GuidArray;
1626}
1627
1628//------------------------------------------------------------------------------
1631inline void
1633{
1634 if (BlobArray == this->type)
1635 {
1636 *this->blobArray = val;
1637 }
1638 else
1639 {
1640 this->Delete();
1641 this->blobArray = new Util::Array<Util::Blob>(val);
1642 }
1643 this->type = BlobArray;
1644}
1645
1646//------------------------------------------------------------------------------
1649inline bool
1651{
1652 if (rhs.type == this->type)
1653 {
1654 switch (rhs.type)
1655 {
1656 case Void:
1657 return true;
1658 case Byte:
1659 return (this->i8 == rhs.i8);
1660 case Short:
1661 return (this->i16 == rhs.i16);
1662 case UShort:
1663 return (this->ui16 == rhs.ui16);
1664 case Int:
1665 return (this->i == rhs.i);
1666 case UInt:
1667 return (this->u == rhs.u);
1668 case Int64:
1669 return (this->i64 == rhs.i64);
1670 case UInt64:
1671 return (this->u64 == rhs.u64);
1672 case Bool:
1673 return (this->b == rhs.b);
1674 case Float:
1675 return (this->f[0] == rhs.f[0]);
1676 case Double:
1677 return (this->d == rhs.d);
1678 case String:
1679 return ((*this->string) == (*rhs.string));
1680 case Vec2:
1681 return ((this->f[0] == rhs.f[0]) && (this->f[1] == rhs.f[1]));
1682 case Vec4:
1683 return ((this->f[0] == rhs.f[0]) &&
1684 (this->f[1] == rhs.f[1]) &&
1685 (this->f[2] == rhs.f[2]) &&
1686 (this->f[3] == rhs.f[3]));
1687 case Quaternion:
1688 return ((this->f[0] == rhs.f[0]) &&
1689 (this->f[1] == rhs.f[1]) &&
1690 (this->f[2] == rhs.f[2]) &&
1691 (this->f[3] == rhs.f[3]));
1692 case Guid:
1693 return ((*this->guid) == (*rhs.guid));
1694 case Blob:
1695 return ((*this->blob) == (*rhs.blob));
1696 case Object:
1697 return (this->object == rhs.object);
1698 case VoidPtr:
1699 return (this->voidPtr == rhs.voidPtr);
1700 case Mat4:
1701 return ((*this->m) == (*rhs.m));
1702 case Transform44:
1703 return ((*this->t) == (*rhs.t));
1704 default:
1705 n_error("Variant::operator==(): invalid variant type!");
1706 return false;
1707 }
1708 }
1709 return false;
1710}
1711
1712//------------------------------------------------------------------------------
1715inline bool
1717{
1718 if (rhs.type == this->type)
1719 {
1720 switch (rhs.type)
1721 {
1722 case Void:
1723 return true;
1724 case Byte:
1725 return (this->i8 > rhs.i8);
1726 case Short:
1727 return (this->i16 > rhs.i16);
1728 case UShort:
1729 return (this->ui16 > rhs.ui16);
1730 case Int:
1731 return (this->i > rhs.i);
1732 case UInt:
1733 return (this->u > rhs.u);
1734 case Int64:
1735 return (this->i64 > rhs.i64);
1736 case UInt64:
1737 return (this->u64 > rhs.u64);
1738 case Bool:
1739 return (this->b > rhs.b);
1740 case Float:
1741 return (this->f[0] > rhs.f[0]);
1742 case Double:
1743 return (this->d > rhs.d);
1744 case String:
1745 return ((*this->string) > (*rhs.string));
1746 case Vec2:
1747 return ((this->f[0] > rhs.f[0]) && (this->f[1] > rhs.f[1]));
1748 case Vec4:
1749 return ((this->f[0] > rhs.f[0]) &&
1750 (this->f[1] > rhs.f[1]) &&
1751 (this->f[2] > rhs.f[2]) &&
1752 (this->f[3] > rhs.f[3]));
1753 case Quaternion:
1754 return ((this->f[0] > rhs.f[0]) &&
1755 (this->f[1] > rhs.f[1]) &&
1756 (this->f[2] > rhs.f[2]) &&
1757 (this->f[3] > rhs.f[3]));
1758 case Guid:
1759 return ((*this->guid) > (*rhs.guid));
1760 case Blob:
1761 return ((*this->blob) > (*rhs.blob));
1762 case Object:
1763 return (this->object > rhs.object);
1764 case VoidPtr:
1765 return (this->voidPtr > rhs.voidPtr);
1766 default:
1767 n_error("Variant::operator>(): invalid variant type!");
1768 return false;
1769 }
1770 }
1771 return false;
1772}
1773
1774//------------------------------------------------------------------------------
1777inline bool
1778Variant::operator<(const Variant& rhs) const
1779{
1780 if (rhs.type == this->type)
1781 {
1782 switch (rhs.type)
1783 {
1784 case Void:
1785 return true;
1786 case Byte:
1787 return (this->i8 < rhs.i8);
1788 case Short:
1789 return (this->i16 < rhs.i16);
1790 case UShort:
1791 return (this->ui16 < rhs.ui16);
1792 case Int:
1793 return (this->i < rhs.i);
1794 case UInt:
1795 return (this->u < rhs.u);
1796 case Int64:
1797 return (this->i64 < rhs.i64);
1798 case UInt64:
1799 return (this->u64 < rhs.u64);
1800 case Bool:
1801 return (this->b < rhs.b);
1802 case Float:
1803 return (this->f[0] < rhs.f[0]);
1804 case Double:
1805 return (this->d > rhs.d);
1806 case String:
1807 return ((*this->string) < (*rhs.string));
1808 case Vec2:
1809 return ((this->f[0] < rhs.f[0]) && (this->f[1] < rhs.f[1]));
1810 case Vec4:
1811 return ((this->f[0] < rhs.f[0]) &&
1812 (this->f[1] < rhs.f[1]) &&
1813 (this->f[2] < rhs.f[2]) &&
1814 (this->f[3] < rhs.f[3]));
1815 case Quaternion:
1816 return ((this->f[0] < rhs.f[0]) &&
1817 (this->f[1] < rhs.f[1]) &&
1818 (this->f[2] < rhs.f[2]) &&
1819 (this->f[3] < rhs.f[3]));
1820 case Guid:
1821 return ((*this->guid) < (*rhs.guid));
1822 case Blob:
1823 return ((*this->blob) < (*rhs.blob));
1824 case Object:
1825 return (this->object < rhs.object);
1826 case VoidPtr:
1827 return (this->voidPtr < rhs.voidPtr);
1828 default:
1829 n_error("Variant::operator<(): invalid variant type!");
1830 return false;
1831 }
1832 }
1833 return false;
1834}
1835
1836
1837//------------------------------------------------------------------------------
1840inline bool
1842{
1843 if (rhs.type == this->type)
1844 {
1845 switch (rhs.type)
1846 {
1847 case Void:
1848 return true;
1849 case Byte:
1850 return (this->i8 >= rhs.i8);
1851 case Short:
1852 return (this->i16 >= rhs.i16);
1853 case UShort:
1854 return (this->ui16 >= rhs.ui16);
1855 case Int:
1856 return (this->i >= rhs.i);
1857 case UInt:
1858 return (this->u >= rhs.u);
1859 case Int64:
1860 return (this->i64 >= rhs.i64);
1861 case UInt64:
1862 return (this->u64 >= rhs.u64);
1863 case Bool:
1864 return (this->b >= rhs.b);
1865 case Float:
1866 return (this->f[0] >= rhs.f[0]);
1867 case Double:
1868 return (this->d >= rhs.d);
1869 case String:
1870 return ((*this->string) >= (*rhs.string));
1871 case Vec2:
1872 return ((this->f[0] >= rhs.f[0]) && (this->f[1] >= rhs.f[1]));
1873 case Vec4:
1874 return ((this->f[0] >= rhs.f[0]) &&
1875 (this->f[1] >= rhs.f[1]) &&
1876 (this->f[2] >= rhs.f[2]) &&
1877 (this->f[3] >= rhs.f[3]));
1878 case Quaternion:
1879 return ((this->f[0] >= rhs.f[0]) &&
1880 (this->f[1] >= rhs.f[1]) &&
1881 (this->f[2] >= rhs.f[2]) &&
1882 (this->f[3] >= rhs.f[3]));
1883 case Guid:
1884 return ((*this->guid) >= (*rhs.guid));
1885 case Blob:
1886 return ((*this->blob) >= (*rhs.blob));
1887 case Object:
1888 return (this->object >= rhs.object);
1889 case VoidPtr:
1890 return (this->voidPtr >= rhs.voidPtr);
1891 default:
1892 n_error("Variant::operator>(): invalid variant type!");
1893 return false;
1894 }
1895 }
1896 return false;
1897}
1898
1899//------------------------------------------------------------------------------
1902inline bool
1903Variant::operator<=(const Variant& rhs) const
1904{
1905 if (rhs.type == this->type)
1906 {
1907 switch (rhs.type)
1908 {
1909 case Void:
1910 return true;
1911 case Byte:
1912 return (this->i8 <= rhs.i8);
1913 case Short:
1914 return (this->i16 <= rhs.i16);
1915 case UShort:
1916 return (this->ui16 <= rhs.ui16);
1917 case Int:
1918 return (this->i <= rhs.i);
1919 case UInt:
1920 return (this->u <= rhs.u);
1921 case Int64:
1922 return (this->i64 <= rhs.i64);
1923 case UInt64:
1924 return (this->u64 <= rhs.u64);
1925 case Bool:
1926 return (this->b <= rhs.b);
1927 case Float:
1928 return (this->f[0] <= rhs.f[0]);
1929 case Double:
1930 return (this->d >= rhs.d);
1931 case String:
1932 return ((*this->string) <= (*rhs.string));
1933 case Vec2:
1934 return ((this->f[0] <= rhs.f[0]) && (this->f[1] <= rhs.f[1]));
1935 case Vec4:
1936 return ((this->f[0] <= rhs.f[0]) &&
1937 (this->f[1] <= rhs.f[1]) &&
1938 (this->f[2] <= rhs.f[2]) &&
1939 (this->f[3] <= rhs.f[3]));
1940 case Quaternion:
1941 return ((this->f[0] <= rhs.f[0]) &&
1942 (this->f[1] <= rhs.f[1]) &&
1943 (this->f[2] <= rhs.f[2]) &&
1944 (this->f[3] <= rhs.f[3]));
1945 case Guid:
1946 return ((*this->guid) <= (*rhs.guid));
1947 case Blob:
1948 return ((*this->blob) <= (*rhs.blob));
1949 case Object:
1950 return (this->object <= rhs.object);
1951 case VoidPtr:
1952 return (this->voidPtr <= rhs.voidPtr);
1953 default:
1954 n_error("Variant::operator<(): invalid variant type!");
1955 return false;
1956 }
1957 }
1958 return false;
1959}
1960
1961//------------------------------------------------------------------------------
1964inline bool
1966{
1967 return !(*this == rhs);
1968}
1969
1970//------------------------------------------------------------------------------
1973inline bool
1974Variant::operator==(byte rhs) const
1975{
1976 n_assert(Byte == this->type);
1977 return (this->i8 == rhs);
1978}
1979
1980//------------------------------------------------------------------------------
1983inline bool
1984Variant::operator==(short rhs) const
1985{
1986 n_assert(Short == this->type);
1987 return (this->i16 == rhs);
1988}
1989
1990//------------------------------------------------------------------------------
1993inline bool
1995{
1996 n_assert(UShort == this->type);
1997 return (this->ui16 == rhs);
1998}
1999
2000//------------------------------------------------------------------------------
2003inline bool
2005{
2006 n_assert(Int == this->type);
2007 return (this->i == rhs);
2008}
2009
2010//------------------------------------------------------------------------------
2013inline bool
2015{
2016 n_assert(UInt == this->type);
2017 return (this->u == rhs);
2018}
2019
2020//------------------------------------------------------------------------------
2023inline bool
2024Variant::operator==(int64_t rhs) const
2025{
2026 n_assert(Int64 == this->type);
2027 return (this->i64 == rhs);
2028}
2029
2030//------------------------------------------------------------------------------
2033inline bool
2034Variant::operator==(uint64_t rhs) const
2035{
2036 n_assert(UInt64 == this->type);
2037 return (this->u64 == rhs);
2038}
2039
2040//------------------------------------------------------------------------------
2043inline bool
2044Variant::operator==(float rhs) const
2045{
2046 n_assert(Float == this->type);
2047 return (this->f[0] == rhs);
2048}
2049
2050//------------------------------------------------------------------------------
2053inline bool
2054Variant::operator==(double rhs) const
2055{
2056 n_assert(Double == this->type);
2057 return (this->d == rhs);
2058}
2059
2060//------------------------------------------------------------------------------
2063inline bool
2064Variant::operator==(bool rhs) const
2065{
2066 n_assert(Bool == this->type);
2067 return (this->b == rhs);
2068}
2069
2070//------------------------------------------------------------------------------
2073inline bool
2075{
2076 n_assert(String == this->type);
2077 return ((*this->string) == rhs);
2078}
2079
2080//------------------------------------------------------------------------------
2083inline bool
2084Variant::operator==(const char* chrPtr) const
2085{
2086 return *this == Util::String(chrPtr);
2087}
2088
2089
2090//------------------------------------------------------------------------------
2093inline bool
2095{
2096 n_assert(Vec2 == this->type);
2097 return (this->f[0] == rhs.x && this->f[1] == rhs.y);
2098}
2099
2100//------------------------------------------------------------------------------
2103inline bool
2105{
2106 n_assert(Vec4 == this->type);
2107 return ((this->f[0] == rhs.x) &&
2108 (this->f[1] == rhs.y) &&
2109 (this->f[2] == rhs.z) &&
2110 (this->f[3] == rhs.w));
2111}
2112
2113//------------------------------------------------------------------------------
2116inline bool
2118{
2119 n_assert(Quaternion == this->type);
2120 return ((this->f[0] == rhs.x) &&
2121 (this->f[1] == rhs.y) &&
2122 (this->f[2] == rhs.z) &&
2123 (this->f[3] == rhs.w));
2124}
2125
2126//------------------------------------------------------------------------------
2129inline bool
2131{
2132 n_assert(Guid == this->type);
2133 return (*this->guid) == rhs;
2134}
2135
2136//------------------------------------------------------------------------------
2139inline bool
2141{
2142 n_assert(Object == this->type);
2143 return this->object == ptr;
2144}
2145
2146//------------------------------------------------------------------------------
2149inline bool
2150Variant::operator==(void* ptr) const
2151{
2152 n_assert(VoidPtr == this->type);
2153 return this->voidPtr == ptr;
2154}
2155
2156//------------------------------------------------------------------------------
2159inline bool
2160Variant::operator!=(byte rhs) const
2161{
2162 n_assert(Byte == this->type);
2163 return (this->i8 != rhs);
2164}
2165
2166//------------------------------------------------------------------------------
2169inline bool
2170Variant::operator!=(short rhs) const
2171{
2172 n_assert(Short == this->type);
2173 return (this->i16 != rhs);
2174}
2175
2176//------------------------------------------------------------------------------
2179inline bool
2181{
2182 n_assert(UShort == this->type);
2183 return (this->ui16 != rhs);
2184}
2185
2186//------------------------------------------------------------------------------
2189inline bool
2191{
2192 n_assert(Int == this->type);
2193 return (this->i != rhs);
2194}
2195
2196//------------------------------------------------------------------------------
2199inline bool
2201{
2202 n_assert(UInt == this->type);
2203 return (this->u != rhs);
2204}
2205
2206//------------------------------------------------------------------------------
2209inline bool
2210Variant::operator!=(int64_t rhs) const
2211{
2212 n_assert(Int64 == this->type);
2213 return (this->i64 != rhs);
2214}
2215
2216//------------------------------------------------------------------------------
2219inline bool
2220Variant::operator!=(uint64_t rhs) const
2221{
2222 n_assert(UInt64 == this->type);
2223 return (this->u64 != rhs);
2224}
2225
2226//------------------------------------------------------------------------------
2229inline bool
2230Variant::operator!=(float rhs) const
2231{
2232 n_assert(Float == this->type);
2233 return (this->f[0] != rhs);
2234}
2235
2236//------------------------------------------------------------------------------
2239inline bool
2240Variant::operator!=(double rhs) const
2241{
2242 n_assert(Double == this->type);
2243 return (this->d != rhs);
2244}
2245
2246//------------------------------------------------------------------------------
2249inline bool
2250Variant::operator!=(bool rhs) const
2251{
2252 n_assert(Bool == this->type);
2253 return (this->b != rhs);
2254}
2255
2256//------------------------------------------------------------------------------
2259inline bool
2261{
2262 n_assert(String == this->type);
2263 return (*this->string) != rhs;
2264}
2265
2266//------------------------------------------------------------------------------
2269inline bool
2270Variant::operator!=(const char* chrPtr) const
2271{
2272 return *this != Util::String(chrPtr);
2273}
2274
2275
2276//------------------------------------------------------------------------------
2279inline bool
2281{
2282 n_assert(Vec2 == this->type);
2283 return (this->f[0] != rhs.x || this->f[1] != rhs.y);
2284}
2285
2286//------------------------------------------------------------------------------
2289inline bool
2291{
2292 n_assert(Vec4 == this->type);
2293 return ((this->f[0] != rhs.x) ||
2294 (this->f[1] != rhs.y) ||
2295 (this->f[2] != rhs.z) ||
2296 (this->f[3] != rhs.w));
2297}
2298
2299//------------------------------------------------------------------------------
2302inline bool
2304{
2305 n_assert(Quaternion == this->type);
2306 return ((this->f[0] != rhs.x) ||
2307 (this->f[1] != rhs.y) ||
2308 (this->f[2] != rhs.z) ||
2309 (this->f[3] != rhs.w));
2310}
2311
2312//------------------------------------------------------------------------------
2315inline bool
2317{
2318 n_assert(Guid == this->type);
2319 return (*this->guid) != rhs;
2320}
2321
2322//------------------------------------------------------------------------------
2325inline bool
2327{
2328 n_assert(Object == this->type);
2329 return (this->object == ptr);
2330}
2331
2332//------------------------------------------------------------------------------
2335inline bool
2336Variant::operator!=(void* ptr) const
2337{
2338 n_assert(VoidPtr == this->type);
2339 return (this->voidPtr == ptr);
2340}
2341
2342//------------------------------------------------------------------------------
2345inline void
2347{
2348 *this = val;
2349}
2350
2351//------------------------------------------------------------------------------
2354inline byte
2356{
2357 n_assert(Byte == this->type);
2358 return this->i8;
2359}
2360
2361//------------------------------------------------------------------------------
2364inline void
2366{
2367 *this = val;
2368}
2369
2370//------------------------------------------------------------------------------
2373inline void
2375{
2376 *this = val;
2377}
2378
2379//------------------------------------------------------------------------------
2382inline short
2384{
2385 n_assert(Short == this->type);
2386 return this->i16;
2387}
2388
2389//------------------------------------------------------------------------------
2392inline ushort
2394{
2395 n_assert(UShort == this->type);
2396 return this->ui16;
2397}
2398
2399//------------------------------------------------------------------------------
2402inline void
2404{
2405 *this = val;
2406}
2407
2408//------------------------------------------------------------------------------
2411inline void
2413{
2414 *this = val;
2415}
2416
2417//------------------------------------------------------------------------------
2420inline int
2422{
2423 n_assert(Int == this->type);
2424 return this->i;
2425}
2426
2427//------------------------------------------------------------------------------
2430inline uint
2432{
2433 n_assert(UInt == this->type);
2434 return this->u;
2435}
2436
2437//------------------------------------------------------------------------------
2440inline void
2442{
2443 n_assert(Int64 == this->type);
2444 this->i64 = val;
2445}
2446
2447//------------------------------------------------------------------------------
2450inline int64_t
2452{
2453 n_assert(Int64 == this->type);
2454 return this->i64;
2455}
2456
2457//------------------------------------------------------------------------------
2460inline void
2462{
2463 n_assert(UInt64 == this->type);
2464 this->u64 = val;
2465}
2466
2467//------------------------------------------------------------------------------
2470inline uint64_t
2472{
2473 n_assert(UInt64 == this->type);
2474 return this->u64;
2475}
2476
2477//------------------------------------------------------------------------------
2480inline void
2482{
2483 *this = val;
2484}
2485
2486//------------------------------------------------------------------------------
2489inline float
2491{
2492 n_assert(Float == this->type);
2493 return this->f[0];
2494}
2495
2496//------------------------------------------------------------------------------
2499inline void
2501{
2502 *this = val;
2503}
2504
2505//------------------------------------------------------------------------------
2508inline double
2510{
2511 n_assert(Double == this->type);
2512 return this->d;
2513}
2514
2515//------------------------------------------------------------------------------
2518inline void
2520{
2521 *this = val;
2522}
2523
2524//------------------------------------------------------------------------------
2527inline bool
2529{
2530 n_assert(Bool == this->type);
2531 return this->b;
2532}
2533
2534//------------------------------------------------------------------------------
2537inline void
2539{
2540 *this = val;
2541}
2542
2543//------------------------------------------------------------------------------
2546inline const Util::String&
2548{
2549 n_assert(String == this->type);
2550 return *(this->string);
2551}
2552
2553//------------------------------------------------------------------------------
2556inline void
2558{
2559 *this = val;
2560}
2561
2562//------------------------------------------------------------------------------
2565inline Math::vec2
2567{
2568 n_assert(Vec2 == this->type);
2569 return Math::vec2(this->f[0], this->f[1]);
2570}
2571
2572//------------------------------------------------------------------------------
2575inline void
2577{
2578 *this = val;
2579}
2580
2581//------------------------------------------------------------------------------
2584inline Math::vec3
2586{
2587 return Math::vec3();
2588}
2589
2590//------------------------------------------------------------------------------
2593inline void
2595{
2596 *this = val;
2597}
2598
2599//------------------------------------------------------------------------------
2602inline Math::vec4
2604{
2605 n_assert(Vec4 == this->type);
2606 return Math::vec4(this->f[0], this->f[1], this->f[2], this->f[3]);
2607}
2608
2609//------------------------------------------------------------------------------
2612inline void
2614{
2615 *this = val;
2616}
2617
2618//------------------------------------------------------------------------------
2621inline Math::quat
2623{
2624 n_assert(Quaternion == this->type);
2625 return Math::quat(this->f[0], this->f[1], this->f[2], this->f[3]);
2626}
2627
2628//------------------------------------------------------------------------------
2631inline void
2633{
2634 *this = val;
2635}
2636
2637//------------------------------------------------------------------------------
2640inline const Math::mat4&
2642{
2643 n_assert(Mat4 == this->type);
2644 return *(this->m);
2645}
2646
2647//------------------------------------------------------------------------------
2650inline void
2652{
2653 *this = val;
2654}
2655
2656//------------------------------------------------------------------------------
2659inline const Math::transform44&
2661{
2662 n_assert(Transform44 == this->type);
2663 return *(this->t);
2664}
2665
2666//------------------------------------------------------------------------------
2669inline void
2671{
2672 *this = val;
2673}
2674
2675//------------------------------------------------------------------------------
2678inline const Util::Guid&
2680{
2681 n_assert(Guid == this->type);
2682 return *(this->guid);
2683}
2684
2685//------------------------------------------------------------------------------
2688inline void
2690{
2691 *this = val;
2692}
2693
2694//------------------------------------------------------------------------------
2697inline const Util::Blob&
2699{
2700 n_assert(Blob == this->type);
2701 return *(this->blob);
2702}
2703
2704//------------------------------------------------------------------------------
2707inline void
2709{
2710 *this = ptr;
2711}
2712
2713//------------------------------------------------------------------------------
2716inline Core::RefCounted*
2718{
2719 n_assert(Object == this->type);
2720 return this->object;
2721}
2722
2723//------------------------------------------------------------------------------
2726inline void
2728{
2729 *this = ptr;
2730}
2731
2732//------------------------------------------------------------------------------
2735inline void*
2737{
2738 n_assert(VoidPtr == this->type);
2739 return this->voidPtr;
2740}
2741
2742//------------------------------------------------------------------------------
2745inline void
2747{
2748 *this = val;
2749}
2750
2751//------------------------------------------------------------------------------
2754inline const Util::Array<int>&
2756{
2757 n_assert(IntArray == this->type);
2758 return *(this->intArray);
2759}
2760
2761//------------------------------------------------------------------------------
2764inline void
2766{
2767 *this = val;
2768}
2769
2770//------------------------------------------------------------------------------
2773inline const Util::Array<float>&
2775{
2776 n_assert(FloatArray == this->type);
2777 return *(this->floatArray);
2778}
2779
2780//------------------------------------------------------------------------------
2783inline void
2785{
2786 *this = val;
2787}
2788
2789//------------------------------------------------------------------------------
2792inline const Util::Array<bool>&
2794{
2795 n_assert(BoolArray == this->type);
2796 return *(this->boolArray);
2797}
2798
2799//------------------------------------------------------------------------------
2802inline void
2804{
2805 *this = val;
2806}
2807
2808//------------------------------------------------------------------------------
2811inline const Util::Array<Math::vec2>&
2813{
2814 n_assert(Vec2Array == this->type);
2815 return *(this->vec2Array);
2816}
2817
2818//------------------------------------------------------------------------------
2821inline void
2823{
2824 *this = val;
2825}
2826
2827//------------------------------------------------------------------------------
2830inline const Util::Array<Math::vec3>&
2832{
2833 n_assert(Vec3Array == this->type);
2834 return *(this->float3Array);
2835}
2836
2837//------------------------------------------------------------------------------
2840inline void
2842{
2843 *this = val;
2844}
2845
2846//------------------------------------------------------------------------------
2849inline const Util::Array<Math::vec4>&
2851{
2852 n_assert(Vec4Array == this->type);
2853 return *(this->vec4Array);
2854}
2855
2856//------------------------------------------------------------------------------
2859inline void
2861{
2862 *this = val;
2863}
2864
2865//------------------------------------------------------------------------------
2868inline const Util::Array<Math::mat4>&
2870{
2871 n_assert(Mat4Array == this->type);
2872 return *(this->mat4Array);
2873}
2874
2875//------------------------------------------------------------------------------
2878inline void
2880{
2881 *this = val;
2882}
2883
2884//------------------------------------------------------------------------------
2887inline const Util::Array<Util::String>&
2889{
2890 n_assert(StringArray == this->type);
2891 return *(this->stringArray);
2892}
2893
2894//------------------------------------------------------------------------------
2897inline void
2899{
2900 *this = val;
2901}
2902
2903//------------------------------------------------------------------------------
2906inline const Util::Array<Util::Guid>&
2908{
2909 n_assert(GuidArray == this->type);
2910 return *(this->guidArray);
2911}
2912
2913//------------------------------------------------------------------------------
2916inline void
2918{
2919 *this = val;
2920}
2921
2922//------------------------------------------------------------------------------
2925inline const Util::Array<Util::Blob>&
2927{
2928 n_assert(BlobArray == this->type);
2929 return *(this->blobArray);
2930}
2931
2932//------------------------------------------------------------------------------
2935template <typename TYPE>
2936inline TYPE
2938{
2939 static_assert(true, "Get method for TYPE is not implemented!");
2940 TYPE ret;
2941 return ret;
2942}
2943
2944//------------------------------------------------------------------------------
2947template <>
2948inline byte
2950{
2951 return this->GetByte();
2952}
2953
2954//------------------------------------------------------------------------------
2957template <>
2958inline short
2960{
2961 return this->GetShort();
2962}
2963
2964//------------------------------------------------------------------------------
2967template <>
2968inline int
2970{
2971 return this->GetInt();
2972}
2973
2974//------------------------------------------------------------------------------
2977template <>
2978inline uint
2980{
2981 return this->GetUInt();
2982}
2983
2984//------------------------------------------------------------------------------
2987template <>
2988inline int64_t
2990{
2991 return this->GetInt64();
2992}
2993
2994//------------------------------------------------------------------------------
2997template <>
2998inline uint64_t
3000{
3001 return this->GetUInt64();
3002}
3003
3004//------------------------------------------------------------------------------
3007template <>
3008inline bool
3010{
3011 return this->GetBool();
3012}
3013
3014//------------------------------------------------------------------------------
3017template <>
3018inline double
3020{
3021 return this->GetDouble();
3022}
3023
3024//------------------------------------------------------------------------------
3027template <>
3028inline float
3030{
3031 return this->GetFloat();
3032}
3033
3034//------------------------------------------------------------------------------
3037template <>
3038inline Math::vec2
3040{
3041 return this->GetVec2();
3042}
3043
3044//------------------------------------------------------------------------------
3047template <>
3048inline Math::vec3
3050{
3051 return this->GetVec3();
3052}
3053
3054//------------------------------------------------------------------------------
3057template <>
3058inline Math::vec4
3060{
3061 return this->GetVec4();
3062}
3063
3064//------------------------------------------------------------------------------
3067template <>
3068inline Math::quat
3070{
3071 return this->GetQuat();
3072}
3073
3074//------------------------------------------------------------------------------
3077template <>
3078inline Math::mat4
3080{
3081 return this->GetMat4();
3082}
3083
3084//------------------------------------------------------------------------------
3087template <>
3088inline Math::transform44
3090{
3091 return this->GetTransform44();
3092}
3093
3094//------------------------------------------------------------------------------
3097template <>
3098inline Util::String
3100{
3101 return this->GetString();
3102}
3103
3104//------------------------------------------------------------------------------
3107template <>
3108inline Util::Guid
3110{
3111 return this->GetGuid();
3112}
3113
3114//------------------------------------------------------------------------------
3117template <>
3118inline Util::Blob
3120{
3121 return this->GetBlob();
3122}
3123
3124//------------------------------------------------------------------------------
3127template <>
3128inline Util::Array<int>
3130{
3131 return this->GetIntArray();
3132}
3133
3134//------------------------------------------------------------------------------
3137template <>
3138inline Util::Array<float>
3140{
3141 return this->GetFloatArray();
3142}
3143
3144//------------------------------------------------------------------------------
3147template <>
3148inline Util::Array<bool>
3150{
3151 return this->GetBoolArray();
3152}
3153
3154//------------------------------------------------------------------------------
3157template <>
3160{
3161 return this->GetVec2Array();
3162}
3163
3164//------------------------------------------------------------------------------
3167template <>
3170{
3171 return this->GetVec3Array();
3172}
3173
3174//------------------------------------------------------------------------------
3177template <>
3180{
3181 return this->GetVec4Array();
3182}
3183
3184//------------------------------------------------------------------------------
3187template <>
3190{
3191 return this->GetMat4Array();
3192}
3193
3194//------------------------------------------------------------------------------
3197template <>
3200{
3201 return this->GetStringArray();
3202}
3203
3204//------------------------------------------------------------------------------
3207template <>
3210{
3211 return this->GetGuidArray();
3212}
3213
3214//------------------------------------------------------------------------------
3217template <>
3220{
3221 return this->GetBlobArray();
3222}
3223
3224//------------------------------------------------------------------------------
3227inline Util::String
3229{
3230 Util::String retval = "";
3231 switch (this->type)
3232 {
3233 case Void: break;
3234 case Byte: { retval = Util::String::FromByte(this->GetByte()); break; }
3235 case Short: { retval = Util::String::FromShort(this->GetShort()); break; }
3236 case UShort: { retval = Util::String::FromUShort(this->GetUShort()); break; }
3237 case Int: { retval = Util::String::FromInt(this->GetInt()); break; }
3238 case UInt: { retval = Util::String::FromUInt(this->GetUInt()); break; }
3239 case Float: { retval = Util::String::FromFloat(this->GetFloat()); break; }
3240 case Double: { retval = Util::String::FromDouble(this->GetDouble()); break; }
3241 case Bool: { retval = Util::String::FromBool(this->GetBool()); break; }
3242 case Vec2: { retval = Util::String::FromVec2(this->GetVec2()); break; }
3243 case Vec3: { retval = Util::String::FromVec3(this->GetVec3()); break; }
3244 case Vec4: { retval = Util::String::FromVec4(this->GetVec4()); break; }
3245 case Quaternion: { retval = Util::String::FromQuat(this->GetQuat()); break; }
3246 case String: { retval = this->GetString(); break; }
3247 case Mat4: { retval = Util::String::FromMat4(this->GetMat4()); break; }
3248 case Transform44: { retval = Util::String::FromTransform44(this->GetTransform44()); break; }
3249 case Blob: { retval = Util::String::FromBlob(this->GetBlob()); break; }
3250 case Guid: { retval = this->GetGuid().AsString(); break; }
3251 case IntArray: { const Util::Array<int>& arr = this->GetIntArray(); for (int i = 0; i < arr.Size(); i++) { retval.AppendInt(arr[i]); retval += (i < arr.Size() - 1 ? "," : ""); } break; }
3252 case FloatArray: { const Util::Array<float>& arr = this->GetFloatArray(); for (int i = 0; i < arr.Size(); i++) { retval.AppendFloat(arr[i]); retval += (i < arr.Size() - 1 ? "," : ""); } break; }
3253 case BoolArray: { const Util::Array<bool>& arr = this->GetBoolArray(); for (int i = 0; i < arr.Size(); i++) { retval.AppendBool(arr[i]); retval += (i < arr.Size() - 1 ? "," : ""); } break; }
3254 case StringArray: { const Util::Array<Util::String>& arr = this->GetStringArray(); for (int i = 0; i < arr.Size(); i++) { retval.Append(arr[i]); retval += (i < arr.Size() - 1 ? "," : ""); } break; }
3255 default:
3256 n_error("Variant::ToString(): invalid type enum '%d'", this->type);
3257
3258 }
3259 return retval;
3260}
3261
3262//------------------------------------------------------------------------------
3267inline bool
3269{
3270 bool retval = false;
3271 switch (this->type)
3272 {
3273 case Int:
3274 case UInt: { if(string.IsValidInt()) { this->SetUInt(string.AsInt()); retval = true; } break; };
3275 case Float: { if(string.IsValidFloat()) { this->SetFloat(string.AsFloat()); retval = true; } break; }
3276 case Bool: { if(string.IsValidBool()) { this->SetBool(string.AsBool()); retval = true; } break; }
3277 case Vec2: { if(string.IsValidVec2()) { this->SetVec2(string.AsVec2()); retval = true; } break; }
3278 case Vec4: { if(string.IsValidVec4()) { this->SetVec4(string.AsVec4()); retval = true; } break; }
3279 case String: { this->SetString(string); retval = true; break; }
3280 case Mat4: { if(string.IsValidMat4()) { this->SetMat4(string.AsMat4()); retval = true; } break; }
3281 case Transform44: { if (string.IsValidTransform44()) { this->SetTransform44(string.AsTransform44()); retval = true; } break; }
3282
3283 case IntArray:
3284 {
3285 Util::Array<Util::String> tokens = string.Tokenize(",");
3286 Util::Array<int> result;
3287 IndexT i;
3288 for (i = 0; i < tokens.Size(); i++)
3289 {
3290 if (tokens[i].IsValidInt())
3291 {
3292 result.Append(tokens[i].AsInt());
3293 }
3294 }
3295 this->SetIntArray(result);
3296 retval = true;
3297 break;
3298 }
3299 case FloatArray:
3300 {
3301 Util::Array<Util::String> tokens = string.Tokenize(",");
3302 Util::Array<float> result;
3303 IndexT i;
3304 for (i = 0; i < tokens.Size(); i++)
3305 {
3306 if (tokens[i].IsValidFloat())
3307 {
3308 result.Append(tokens[i].AsFloat());
3309 }
3310 }
3311 this->SetFloatArray(result);
3312 retval = true;
3313 break;
3314 }
3315 case BoolArray:
3316 {
3317 Util::Array<Util::String> tokens = string.Tokenize(",");
3318 Util::Array<bool> result;
3319 IndexT i;
3320 for (i = 0; i < tokens.Size(); i++)
3321 {
3322 if (tokens[i].IsValidBool())
3323 {
3324 result.Append(tokens[i].AsBool());
3325 }
3326 }
3327 this->SetBoolArray(result);
3328 retval = true;
3329 break;
3330 }
3331 case StringArray:
3332 {
3333 Util::Array<Util::String> tokens = string.Tokenize(",");
3334 this->SetStringArray(tokens);
3335 retval = true;
3336 break;
3337 }
3338 default:
3339 break;
3340 }
3341 return retval;
3342}
3343
3344//------------------------------------------------------------------------------
3347inline
3348const SizeT
3350{
3351 switch (this->type)
3352 {
3353 case Void: return 0;
3354 case Byte: return sizeof(uint8);
3355 case Short: return sizeof(uint16);
3356 case UShort: return sizeof(uint16);
3357 case Int: return sizeof(uint32);
3358 case UInt: return sizeof(uint32);
3359 case Int64: return sizeof(uint64);
3360 case UInt64: return sizeof(uint64);
3361 case Float: return sizeof(float);
3362 case Double: return sizeof(double);
3363 case Bool: return sizeof(bool);
3364 case Vec2: return sizeof(float) * 2;
3365 case Vec4: return sizeof(float) * 4;
3366 case Quaternion: return sizeof(float) * 4;
3367 case String: return sizeof(Util::String);
3368 case Mat4: return sizeof(Math::mat4);
3369 case Transform44: return sizeof(Math::transform44);
3370 case Blob: return sizeof(Util::Blob);
3371 case Guid: return sizeof(Util::Guid);
3372 case Object: return sizeof(Core::RefCounted*);
3373 case VoidPtr: return sizeof(void*);
3374 case IntArray: return sizeof(Util::Array<int>);
3375 case FloatArray: return sizeof(Util::Array<float>);
3376 case BoolArray: return sizeof(Util::Array<bool>);
3377 case Vec2Array: return sizeof(Util::Array<Math::vec2>);
3378 case Vec4Array: return sizeof(Util::Array<Math::vec4>);
3379 case Mat4Array: return sizeof(Util::Array<Math::mat4>);
3380 case StringArray: return sizeof(Util::Array<Util::String>);
3381 case GuidArray: return sizeof(Util::Array<Util::Guid>);
3382 case BlobArray: return sizeof(Util::Array<Util::Blob>);
3383 default:
3384 n_error("Variant::Size(): invalid type enum '%d'!", this->type);
3385 return 0;
3386 }
3387}
3388
3389//------------------------------------------------------------------------------
3392inline
3393const void*
3395{
3396 switch (this->type)
3397 {
3398 case Void:
3399 return nullptr;
3400 case Byte:
3401 case Short:
3402 case UShort:
3403 case Int:
3404 case UInt:
3405 case Int64:
3406 case UInt64:
3407 case Float:
3408 case Double:
3409 case Bool:
3410 case Vec2:
3411 case Vec4:
3412 case Quaternion:
3413 case Object: // object and void ptr will be returned as pointers, not "as content"
3414 case VoidPtr:
3415 return &this->i8;
3416 case String:
3417 case Mat4:
3418 case Transform44:
3419 case Blob:
3420 case Guid:
3421 case IntArray:
3422 case FloatArray:
3423 case BoolArray:
3424 case Vec2Array:
3425 case Vec4Array:
3426 case Mat4Array:
3427 case StringArray:
3428 case GuidArray:
3429 case BlobArray:
3430 return this->voidPtr;
3431 default:
3432 n_error("Variant::AsVoidPtr(): invalid type enum '%d'!", this->type);
3433 return nullptr;
3434 }
3435}
3436
3437//------------------------------------------------------------------------------
3441inline Variant
3443{
3444 Variant val;
3445 if (string.IsValidInt()) val.SetInt(string.AsInt());
3446 else if (string.IsValidFloat()) val.SetFloat(string.AsFloat());
3447 else if (string.IsValidVec2()) val.SetVec2(string.AsVec2());
3448 else if (string.IsValidVec4()) val.SetVec4(string.AsVec4());
3449 else if (string.IsValidBool()) val.SetBool(string.AsBool());
3450 else if (string.IsValidMat4()) val.SetMat4(string.AsMat4());
3451 else val.SetString(string); // raw string
3452 return val;
3453}
3454
3455//------------------------------------------------------------------------------
3458inline Util::String
3460{
3461 switch (t)
3462 {
3463 case Void: return "void";
3464 case Byte: return "byte";
3465 case Short: return "short";
3466 case UShort: return "ushort";
3467 case Int: return "int";
3468 case UInt: return "uint";
3469 case Int64: return "int64";
3470 case UInt64: return "uint64";
3471 case Float: return "float";
3472 case Double: return "double";
3473 case Bool: return "bool";
3474 case Vec2: return "vec2";
3475 case Vec4: return "vec4";
3476 case Quaternion: return "quaternion";
3477 case String: return "string";
3478 case Mat4: return "mat4";
3479 case Transform44: return "transform44";
3480 case Blob: return "blob";
3481 case Guid: return "guid";
3482 case Object: return "object";
3483 case VoidPtr: return "voidptr";
3484 case IntArray: return "intarray";
3485 case FloatArray: return "floatarray";
3486 case BoolArray: return "boolarray";
3487 case Vec2Array: return "vec2array";
3488 case Vec4Array: return "vec4array";
3489 case Mat4Array: return "mat4array";
3490 case StringArray: return "stringarray";
3491 case GuidArray: return "guidarray";
3492 case BlobArray: return "blobarray";
3493 default:
3494 n_error("Variant::TypeToString(): invalid type enum '%d'!", t);
3495 return 0;
3496 }
3497}
3498
3499//------------------------------------------------------------------------------
3502inline Variant::Type
3504{
3505 if ("void" == str) return Void;
3506 else if ("byte" == str) return Byte;
3507 else if ("short" == str) return Short;
3508 else if ("ushort" == str) return UShort;
3509 else if ("int" == str) return Int;
3510 else if ("uint" == str) return UInt;
3511 else if ("int64" == str) return Int64;
3512 else if ("uint64" == str) return UInt64;
3513 else if ("float" == str) return Float;
3514 else if ("double" == str) return Double;
3515 else if ("bool" == str) return Bool;
3516 else if ("vec2" == str) return Vec2;
3517 else if ("vec4" == str) return Vec4;
3518 else if ("color" == str) return Vec4; // NOT A BUG!
3519 else if ("quaternion" == str) return Quaternion;
3520 else if ("string" == str) return String;
3521 else if ("mat4" == str) return Mat4;
3522 else if ("transform44" == str) return Transform44;
3523 else if ("blob" == str) return Blob;
3524 else if ("guid" == str) return Guid;
3525 else if ("object" == str) return Object;
3526 else if ("voidptr" == str) return VoidPtr;
3527 else if ("intarray" == str) return IntArray;
3528 else if ("floatarray" == str) return FloatArray;
3529 else if ("boolarray" == str) return BoolArray;
3530 else if ("vec2array" == str) return Vec2Array;
3531 else if ("vec4array" == str) return Vec4Array;
3532 else if ("mat4array" == str) return Mat4Array;
3533 else if ("stringarray" == str) return StringArray;
3534 else if ("guidarray" == str) return GuidArray;
3535 else if ("blobarray" == str) return BlobArray;
3536 else
3537 {
3538 n_error("Variant::StringToType(): invalid type string '%s'!", str.AsCharPtr());
3539 return Void;
3540 }
3541}
3542
3543
3544} // namespace Util
3545//------------------------------------------------------------------------------
The common base class of Nebula.
Definition refcounted.h:38
A 4x4 matrix which is described by translation, rotation and scale.
Definition transform44.h:20
Nebula's dynamic array class.
Definition array.h:60
void Append(const TYPE &first, const ELEM_TYPE &... elements)
Append multiple elements to the end of the array.
Definition array.h:1332
const SizeT Size() const
get number of elements in array
Definition array.h:878
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
Implements a GUID.
An "any type" variable.
Definition variant.h:30
void SetDouble(double val)
set double content
Definition variant.h:2500
Util::Array< Math::mat4 > * mat4Array
Definition variant.h:482
const Util::Array< Util::String > & GetStringArray() const
get string array content
Definition variant.h:2888
void SetBlob(const Util::Blob &val)
set blob
Definition variant.h:2689
int64_t GetInt64() const
get integer content
Definition variant.h:2451
Core::RefCounted * object
Definition variant.h:475
const Math::mat4 & GetMat4() const
get mat4 content
Definition variant.h:2641
Math::quat GetQuat() const
get quaternion content
Definition variant.h:2622
Type
variant types
Definition variant.h:34
@ Short
Definition variant.h:37
@ BlobArray
Definition variant.h:65
@ UInt64
Definition variant.h:42
@ Int
Definition variant.h:39
@ Vec4Array
Definition variant.h:62
@ Quaternion
Definition variant.h:49
@ Blob
Definition variant.h:53
@ Vec3Array
Definition variant.h:61
@ Transform44
Definition variant.h:52
@ Float
Definition variant.h:43
@ Bool
Definition variant.h:45
@ FloatArray
Definition variant.h:58
@ Vec2
Definition variant.h:46
@ GuidArray
Definition variant.h:66
@ String
Definition variant.h:50
@ Object
Definition variant.h:55
@ StringArray
Definition variant.h:63
@ Void
Definition variant.h:35
@ NumTypes
Definition variant.h:67
@ UInt
Definition variant.h:40
@ IntArray
Definition variant.h:57
@ Mat4Array
Definition variant.h:64
@ Vec3
Definition variant.h:47
@ Guid
Definition variant.h:54
@ Double
Definition variant.h:44
@ Mat4
Definition variant.h:51
@ VoidPtr
Definition variant.h:56
@ Vec2Array
Definition variant.h:60
@ Int64
Definition variant.h:41
@ Byte
Definition variant.h:36
@ Vec4
Definition variant.h:48
@ UShort
Definition variant.h:38
@ BoolArray
Definition variant.h:59
const Util::Array< Math::mat4 > & GetMat4Array() const
get mat4 array content
Definition variant.h:2869
Math::vec4 GetVec4() const
get vec4 content
Definition variant.h:2603
int GetInt() const
get integer content
Definition variant.h:2421
double d
Definition variant.h:467
const Util::String & GetString() const
get string content
Definition variant.h:2547
bool operator>=(const Variant &rhs) const
greater equal operator
Definition variant.h:1841
void * voidPtr
Definition variant.h:474
bool b
Definition variant.h:466
void SetFloat(float val)
set float content
Definition variant.h:2481
Util::Guid * guid
Definition variant.h:472
uint GetUInt() const
get unsigned integer content
Definition variant.h:2431
void SetBool(bool val)
set bool content
Definition variant.h:2519
Math::transform44 * t
Definition variant.h:470
bool GetBool() const
get bool content
Definition variant.h:2528
void Clear()
clear content, resets type to void
Definition variant.h:609
static Variant FromString(const Util::String &string)
create from string
Definition variant.h:3442
Util::Blob * blob
Definition variant.h:473
void SetShort(short val)
set short content
Definition variant.h:2365
bool operator!=(const Variant &rhs) const
inequality operator
Definition variant.h:1965
void SetBoolArray(const Util::Array< bool > &val)
set bool array content
Definition variant.h:2784
void operator=(const Variant &rhs)
assignment operator
Definition variant.h:1180
const Util::Array< Math::vec3 > & GetVec3Array() const
get vec4 array content
Definition variant.h:2831
void SetByte(byte val)
set byte content
Definition variant.h:2346
Util::Array< bool > * boolArray
Definition variant.h:478
ushort ui16
Definition variant.h:461
void SetBlobArray(const Util::Array< Util::Blob > &val)
set blob array content
Definition variant.h:2917
void SetVec3Array(const Util::Array< Math::vec3 > &val)
set vec4 array content
Definition variant.h:2822
Variant()
default constructor
Definition variant.h:493
Util::Array< Util::Guid > * guidArray
Definition variant.h:484
Type GetType() const
get type
Definition variant.h:1171
void SetGuid(const Util::Guid &val)
set guid content
Definition variant.h:2670
void SetString(const Util::String &val)
set string content
Definition variant.h:2538
Util::Array< Util::Blob > * blobArray
Definition variant.h:485
const Util::Array< float > & GetFloatArray() const
get float array content
Definition variant.h:2774
void SetFloatArray(const Util::Array< float > &val)
set float array content
Definition variant.h:2765
void SetType(Type t)
set type of attribute
Definition variant.h:1105
void SetInt64(int64_t val)
set integer content
Definition variant.h:2441
TYPE Get() const
Templated get method.
Definition variant.h:2937
void SetMat4Array(const Util::Array< Math::mat4 > &val)
set mat4 array content
Definition variant.h:2860
void SetVec4Array(const Util::Array< Math::vec4 > &val)
set vec4 array content
Definition variant.h:2841
const Util::Array< Util::Blob > & GetBlobArray() const
get blob array content
Definition variant.h:2926
bool operator==(const Variant &rhs) const
equality operator
Definition variant.h:1650
const Util::Guid & GetGuid() const
get guid content
Definition variant.h:2679
void SetVec2(const Math::vec2 &val)
set vec2 content
Definition variant.h:2557
float GetFloat() const
get float content
Definition variant.h:2490
void SetUInt64(uint64_t val)
set unsigned integer content
Definition variant.h:2461
void SetVoidPtr(void *ptr)
set opaque void pointer
uint64_t GetUInt64() const
get unsigned integer content
Definition variant.h:2471
void SetVec2Array(const Util::Array< Math::vec2 > &val)
set vec2 array content
Definition variant.h:2803
void SetStringArray(const Util::Array< Util::String > &val)
set string array content
Definition variant.h:2879
const Util::Array< Util::Guid > & GetGuidArray() const
get guid array content
Definition variant.h:2907
Math::vec3 GetVec3() const
get vec4 content
Definition variant.h:2585
Util::Array< Math::vec4 > * vec4Array
Definition variant.h:481
const void * AsVoidPtr() const
get pointer to data
Definition variant.h:3394
static Type StringToType(const Util::String &str)
convert string to type
Definition variant.h:3503
void Delete()
delete current content
Definition variant.h:504
void SetIntArray(const Util::Array< int > &val)
set int array content
Definition variant.h:2746
Type type
Definition variant.h:456
const Math::transform44 & GetTransform44() const
get transform44 content
Definition variant.h:2660
Core::RefCounted * GetObject() const
get object pointer
Definition variant.h:2717
void SetQuat(const Math::quat &val)
set quaternion content
Definition variant.h:2613
Math::mat4 * m
Definition variant.h:469
bool operator<(const Variant &rhs) const
less operator
Definition variant.h:1778
const Util::Blob & GetBlob() const
get blob
Definition variant.h:2698
static Util::String TypeToString(Type t)
convert type to string
Definition variant.h:3459
short i16
Definition variant.h:460
Util::Array< float > * floatArray
Definition variant.h:477
int i
Definition variant.h:462
void SetVec3(const Math::vec3 &val)
set vec4 content
Definition variant.h:2576
int64_t i64
Definition variant.h:464
double GetDouble() const
get double content
Definition variant.h:2509
float f[4]
Definition variant.h:468
short GetShort() const
get short content
Definition variant.h:2383
Util::String * string
Definition variant.h:471
byte i8
Definition variant.h:459
const Util::Array< Math::vec4 > & GetVec4Array() const
get vec4 array content
Definition variant.h:2850
bool SetParseString(const Util::String &string)
set value from string, if type doesn't match, returns false
bool operator<=(const Variant &rhs) const
less equal operator
Definition variant.h:1903
bool operator>(const Variant &rhs) const
greater operator
Definition variant.h:1716
void * GetVoidPtr() const
get void pointer
uint64_t u64
Definition variant.h:465
const SizeT Size() const
get size of data
Definition variant.h:3349
void SetInt(int val)
set integer content
Definition variant.h:2403
const Util::Array< Math::vec2 > & GetVec2Array() const
get vec2 array content
Definition variant.h:2812
Util::Array< int > * intArray
Definition variant.h:476
void SetObject(Core::RefCounted *ptr)
set object pointer
Definition variant.h:2708
~Variant()
destructor
Definition variant.h:1096
void Copy(const Variant &rhs)
copy current content
Definition variant.h:618
Util::Array< Math::vec2 > * vec2Array
Definition variant.h:479
void SetUInt(uint val)
set unsigned integer content
Definition variant.h:2412
void SetTransform44(const Math::transform44 &val)
set transform44 content
Definition variant.h:2651
Util::Array< Math::vec3 > * float3Array
Definition variant.h:480
void SetMat4(const Math::mat4 &val)
set mat4 content
Definition variant.h:2632
ushort GetUShort() const
get short content
Definition variant.h:2393
Math::vec2 GetVec2() const
get vec2 content
Definition variant.h:2566
Util::Array< Util::String > * stringArray
Definition variant.h:483
const Util::Array< int > & GetIntArray() const
get int array content
Definition variant.h:2755
void SetGuidArray(const Util::Array< Util::Guid > &val)
set guid array content
Definition variant.h:2898
Util::String ToString() const
convert value to string
Definition variant.h:3228
uint u
Definition variant.h:463
void SetUShort(ushort val)
set ushort content
Definition variant.h:2374
void SetVec4(const Math::vec4 &val)
set vec4 content
Definition variant.h:2594
const Util::Array< bool > & GetBoolArray() const
get bool array content
Definition variant.h:2793
byte GetByte() const
get byte content
Definition variant.h:2355
void __cdecl n_error(const char *msg,...)
This function is called when a serious situation is encountered which requires abortion of the applic...
Definition debug.cc:138
#define n_assert(exp)
Definition debug.h:50
Implements a memory related functions.
A pinned array is an array which manages its own virtual memory.
Definition String.cs:6
A 4x4 single point precision float matrix.
Definition mat4.h:47
A quaternion is usually used to represent an orientation in 3D space.
Definition quat.h:30
float y
Definition quat.h:78
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition quat.h:183
float z
Definition quat.h:78
float w
Definition quat.h:78
float x
Definition quat.h:78
A 2-component float vector class.
Definition vec2.h:21
scalar x
Definition vec2.h:86
scalar y
Definition vec2.h:87
A 3D vector.
Definition vec3.h:39
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition vec3.h:195
A 4D vector.
Definition vec4.h:24
float y
Definition vec4.h:93
float z
Definition vec4.h:93
float w
Definition vec4.h:93
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition vec4.h:201
float x
Definition vec4.h:93
Nebula's universal string class.
Definition string.h:50
static String FromVec3(const Math::vec3 &v)
construct a string from vec3
Definition string.h:985
static String FromUInt(uint i)
construct a string from a uint
Definition string.h:896
static String FromBool(bool b)
construct a string from a bool
Definition string.h:962
static String FromByte(byte i)
construct a string from a byte
Definition string.h:841
void AppendFloat(float val)
append float value
Definition string.h:1131
static String FromQuat(const Math::quat &q)
construct a string from quat
Definition string.h:1040
static String FromDouble(double f)
construct a string from a double
Definition string.h:951
void AppendBool(bool val)
append bool value
Definition string.h:1140
static String FromTransform44(const Math::transform44 &m)
construct a string from transform44
Definition string.h:1062
static String FromInt(int i)
construct a string from an int
Definition string.h:885
static String FromFloat(float f)
construct a string from a float
Definition string.h:940
static String FromVec4(const Math::vec4 &v)
construct a string from vec4
Definition string.h:996
void Append(const String &str)
append string
Definition string.h:615
static String FromMat4(const Math::mat4 &m)
construct a string from mat4
Definition string.h:1051
static String FromBlob(const Util::Blob &b)
create from blob
Definition string.cc:1185
static String FromShort(short i)
construct a string from a short
Definition string.h:863
static String FromUShort(ushort i)
construct a string from a ushort
Definition string.h:874
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:540
void AppendInt(int val)
append int value
Definition string.h:1104
static String FromVec2(const Math::vec2 &v)
construct a string from vec2
Definition string.h:974
uint8_t uint8
Definition types.h:42
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
unsigned short ushort
Definition types.h:32
uint64_t uint64
Definition types.h:36
uint16_t uint16
Definition types.h:40
uint32_t uint32
Definition types.h:38
int IndexT
Definition types.h:48