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#include "util/color.h"
26#include "io/filetime.h"
27
28//------------------------------------------------------------------------------
29namespace Util
30{
32{
33public:
72
74 Variant();
76 Variant(byte rhs);
78 Variant(short rhs);
80 Variant(ushort rhs);
82 Variant(int rhs);
84 Variant(uint rhs);
86 Variant(int64_t rhs);
88 Variant(uint64_t rhs);
90 Variant(float rhs);
92 Variant(double rhs);
94 Variant(bool rhs);
96 Variant(const Math::vec2& v);
98 Variant(const Math::vec3& v);
100 Variant(const Math::vec4& v);
102 Variant(const Math::quat& q);
104 Variant(const Math::mat4& m);
108 Variant(const Util::String& rhs);
110 Variant(const Util::Blob& blob);
112 Variant(const Util::Guid& guid);
114 Variant(const char* chrPtr);
118 Variant(void* ptr);
120 Variant(std::nullptr_t);
122 Variant(const Util::Array<int>& rhs);
124 Variant(const Util::Array<float>& rhs);
126 Variant(const Util::Array<bool>& rhs);
142 Variant(const IO::FileTime& rhs);
144 Variant(const Variant& rhs);
145
147 ~Variant();
149 void SetType(Type t);
151 Type GetType() const;
153 void Clear();
154
156 void operator=(const Variant& rhs);
158 void operator=(byte val);
160 void operator=(short val);
162 void operator=(ushort val);
164 void operator=(int val);
166 void operator=(uint val);
168 void operator=(int64_t val);
170 void operator=(uint64_t val);
172 void operator=(float val);
174 void operator=(double val);
176 void operator=(bool val);
178 void operator=(const Math::vec2& val);
180 void operator=(const Math::vec3& val);
182 void operator=(const Math::vec4& val);
184 void operator=(const Math::quat& val);
186 void operator=(const Math::mat4& val);
188 void operator=(const Math::transform44& val);
190 void operator=(const Util::String& s);
192 void operator=(const Util::Blob& val);
194 void operator=(const Util::Guid& val);
196 void operator=(const char* chrPtr);
198 void operator=(Core::RefCounted* ptr);
200 void operator=(void* ptr);
202 void operator=(const Util::Array<int>& rhs);
204 void operator=(const Util::Array<float>& rhs);
206 void operator=(const Util::Array<bool>& rhs);
208 void operator=(const Util::Array<Math::vec2>& rhs);
210 void operator=(const Util::Array<Math::vec3>& rhs);
212 void operator=(const Util::Array<Math::vec4>& rhs);
214 void operator=(const Util::Array<Math::mat4>& rhs);
216 void operator=(const Util::Array<Util::String>& rhs);
218 void operator=(const Util::Array<Util::Blob>& rhs);
220 void operator=(const Util::Array<Util::Guid>& rhs);
222 void operator=(const IO::FileTime& rhs);
223
225 bool operator==(const Variant& rhs) const;
227 bool operator==(byte rhs) const;
229 bool operator==(short rhs) const;
231 bool operator==(ushort rhs) const;
233 bool operator==(int rhs) const;
235 bool operator==(uint rhs) const;
237 bool operator==(int64_t rhs) const;
239 bool operator==(uint64_t rhs) const;
241 bool operator==(float rhs) const;
243 bool operator==(double rhs) const;
245 bool operator==(bool rhs) const;
247 bool operator==(const Math::vec2& rhs) const;
249 bool operator==(const Math::vec4& rhs) const;
251 bool operator==(const Math::quat& rhs) const;
253 bool operator==(const Util::String& rhs) const;
255 bool operator==(const Util::Guid& rhs) const;
257 bool operator==(const char* chrPtr) const;
259 bool operator==(const IO::FileTime& rhs) const;
261 bool operator==(Core::RefCounted* ptr) const;
263 bool operator==(void* ptr) const;
264
266 bool operator!=(const Variant& rhs) const;
268 bool operator!=(byte rhs) const;
270 bool operator!=(short rhs) const;
272 bool operator!=(ushort rhs) const;
274 bool operator!=(int rhs) const;
276 bool operator!=(uint rhs) const;
278 bool operator!=(int64_t rhs) const;
280 bool operator!=(uint64_t rhs) const;
282 bool operator!=(float rhs) const;
284 bool operator!=(double rhs) const;
286 bool operator!=(bool rhs) const;
288 bool operator!=(const Math::vec2& rhs) const;
290 bool operator!=(const Math::vec4& rhs) const;
292 bool operator!=(const Math::quat& rhs) const;
294 bool operator!=(const Util::String& rhs) const;
296 bool operator!=(const Util::Guid& rhs) const;
298 bool operator!=(const char* chrPtr) const;
300 bool operator!=(const IO::FileTime& rhs) const;
302 bool operator!=(Core::RefCounted* ptr) const;
304 bool operator!=(void* ptr) const;
305
307 bool operator>(const Variant& rhs) const;
309 bool operator<(const Variant& rhs) const;
311 bool operator>=(const Variant& rhs) const;
313 bool operator<=(const Variant& rhs) const;
314
316 void SetByte(byte val);
318 byte GetByte() const;
320 void SetShort(short val);
322 short GetShort() const;
324 void SetUShort(ushort val);
326 ushort GetUShort() const;
328 void SetInt(int val);
330 int GetInt() const;
332 void SetUInt(uint val);
334 uint GetUInt() const;
336 void SetInt64(int64_t val);
338 int64_t GetInt64() const;
340 void SetUInt64(uint64_t val);
342 uint64_t GetUInt64() const;
344 void SetFloat(float val);
346 float GetFloat() const;
348 void SetDouble(double val);
350 double GetDouble() const;
352 void SetBool(bool val);
354 bool GetBool() const;
356 void SetString(const Util::String& val);
358 const Util::String& GetString() const;
360 void SetVec2(const Math::vec2& val);
362 Math::vec2 GetVec2() const;
364 void SetVec3(const Math::vec3& val);
366 Math::vec3 GetVec3() const;
368 void SetVec4(const Math::vec4& val);
370 Math::vec4 GetVec4() const;
372 void SetQuat(const Math::quat& val);
374 Math::quat GetQuat() const;
376 void SetMat4(const Math::mat4& val);
378 const Math::mat4& GetMat4() const;
380 void SetTransform44(const Math::transform44& val);
382 const Math::transform44& GetTransform44() const;
384 void SetBlob(const Util::Blob& val);
386 const Util::Blob& GetBlob() const;
388 void SetGuid(const Util::Guid& val);
390 const Util::Guid& GetGuid() const;
392 void SetObject(Core::RefCounted* ptr);
396 void SetVoidPtr(void* ptr);
398 void* GetVoidPtr() const;
400 void SetIntArray(const Util::Array<int>& val);
402 const Util::Array<int>& GetIntArray() const;
404 void SetFloatArray(const Util::Array<float>& val);
406 const Util::Array<float>& GetFloatArray() const;
408 void SetBoolArray(const Util::Array<bool>& val);
410 const Util::Array<bool>& GetBoolArray() const;
412 void SetVec2Array(const Util::Array<Math::vec2>& val);
416 void SetVec3Array(const Util::Array<Math::vec3>& val);
420 void SetVec4Array(const Util::Array<Math::vec4>& val);
424 void SetMat4Array(const Util::Array<Math::mat4>& val);
432 void SetGuidArray(const Util::Array<Util::Guid>& val);
436 void SetBlobArray(const Util::Array<Util::Blob>& val);
440 void SetFileTime(const IO::FileTime& val);
442 IO::FileTime GetFileTime() const;
443
445 template <typename TYPE>
446 TYPE Get() const;
447
449 Util::String ToString() const;
451 bool SetParseString(const Util::String& string);
452
454 const SizeT Size() const;
456 const void* AsVoidPtr() const;
457
459 static Variant FromString(const Util::String& string);
463 static Type StringToType(const Util::String& str);
464
465private:
467 void Delete();
469 void Copy(const Variant& rhs);
470
472 union
473 {
474 byte i8;
475 short i16;
477 int i;
479 int64_t i64;
480 uint64_t u64;
481 bool b;
482 double d;
483 float f[4];
487 Util::Guid* guid;
489 void* voidPtr;
501 };
502};
503
504//------------------------------------------------------------------------------
507inline
509 type(Void),
510 string(0)
511{
512 // empty
513}
514
515//------------------------------------------------------------------------------
518inline void
520{
521 if (String == this->type)
522 {
523 n_assert(this->string);
524 delete this->string;
525 this->string = 0;
526 }
527 else if (Mat4 == this->type)
528 {
529 n_assert(this->m);
530 delete this->m;
531 this->m = 0;
532 }
533 else if (Guid == this->type)
534 {
535 n_assert(this->guid);
536 delete this->guid;
537 this->guid = 0;
538 }
539 else if (Blob == this->type)
540 {
541 n_assert(this->blob);
542 delete this->blob;
543 this->blob = 0;
544 }
545 else if (Object == this->type)
546 {
547 if (this->object)
548 {
549 this->object->Release();
550 this->object = 0;
551 }
552 }
553 else if (VoidPtr == this->type)
554 {
555 this->voidPtr = 0;
556 }
557 else if (IntArray == this->type)
558 {
559 n_assert(this->intArray);
560 delete this->intArray;
561 this->intArray = 0;
562 }
563 else if (FloatArray == this->type)
564 {
565 n_assert(this->floatArray);
566 delete this->floatArray;
567 this->floatArray = 0;
568 }
569 else if (BoolArray == this->type)
570 {
571 n_assert(this->boolArray);
572 delete this->boolArray;
573 this->boolArray = 0;
574 }
575 else if (Vec2Array == this->type)
576 {
577 n_assert(this->vec2Array);
578 delete this->vec2Array;
579 this->vec2Array = 0;
580 }
581 else if (Vec3Array == this->type)
582 {
583 n_assert(this->float3Array);
584 delete this->float3Array;
585 this->float3Array = 0;
586 }
587 else if (Vec4Array == this->type)
588 {
589 n_assert(this->vec4Array);
590 delete this->vec4Array;
591 this->vec4Array = 0;
592 }
593 else if (Mat4Array == this->type)
594 {
595 n_assert(this->mat4Array);
596 delete this->mat4Array;
597 this->mat4Array = 0;
598 }
599 else if (StringArray == this->type)
600 {
601 n_assert(this->stringArray);
602 delete this->stringArray;
603 this->stringArray = 0;
604 }
605 else if (GuidArray == this->type)
606 {
607 n_assert(this->guidArray);
608 delete this->guidArray;
609 this->guidArray = 0;
610 }
611 else if (BlobArray == this->type)
612 {
613 n_assert(this->blobArray);
614 delete this->blobArray;
615 this->blobArray = 0;
616 }
617 this->type = Void;
618}
619
620//------------------------------------------------------------------------------
623inline void
625{
626 this->Delete();
627}
628
629//------------------------------------------------------------------------------
632inline void
634{
635 n_assert(Void == this->type);
636 this->type = rhs.type;
637 switch (rhs.type)
638 {
639 case Void:
640 break;
641 case Byte:
642 this->i8 = rhs.i8;
643 break;
644 case Short:
645 this->i16 = rhs.i16;
646 break;
647 case UShort:
648 this->ui16 = rhs.ui16;
649 break;
650 case Int:
651 this->i = rhs.i;
652 break;
653 case UInt:
654 this->u = rhs.u;
655 break;
656 case Int64:
657 this->i64 = rhs.i64;
658 break;
659 case UInt64:
660 this->u64 = rhs.u64;
661 break;
662 case Float:
663 this->f[0] = rhs.f[0];
664 break;
665 case Double:
666 this->d = rhs.d;
667 break;
668 case Bool:
669 this->b = rhs.b;
670 break;
671 case Vec2:
672 this->f[0] = rhs.f[0];
673 this->f[1] = rhs.f[1];
674 break;
675 case Vec3:
676 this->f[0] = rhs.f[0];
677 this->f[1] = rhs.f[1];
678 this->f[2] = rhs.f[2];
679 break;
680 case Vec4:
681 this->f[0] = rhs.f[0];
682 this->f[1] = rhs.f[1];
683 this->f[2] = rhs.f[2];
684 this->f[3] = rhs.f[3];
685 break;
686 case Quaternion:
687 this->f[0] = rhs.f[0];
688 this->f[1] = rhs.f[1];
689 this->f[2] = rhs.f[2];
690 this->f[3] = rhs.f[3];
691 break;
692 case String:
693 this->string = new Util::String(*rhs.string);
694 break;
695 case Mat4:
696 this->m = new Math::mat4(*rhs.m);
697 break;
698 case Transform44:
699 this->t = new Math::transform44(*rhs.t);
700 break;
701 case Blob:
702 this->blob = new Util::Blob(*rhs.blob);
703 break;
704 case Guid:
705 this->guid = new Util::Guid(*rhs.guid);
706 break;
707 case Object:
708 this->object = rhs.object;
709 if (this->object)
710 {
711 this->object->AddRef();
712 }
713 break;
714 case VoidPtr:
715 this->voidPtr = rhs.voidPtr;
716 break;
717 case IntArray:
718 this->intArray = new Util::Array<int>(*rhs.intArray);
719 break;
720 case FloatArray:
721 this->floatArray = new Util::Array<float>(*rhs.floatArray);
722 break;
723 case BoolArray:
724 this->boolArray = new Util::Array<bool>(*rhs.boolArray);
725 break;
726 case Vec2Array:
728 break;
729 case Vec3Array:
731 break;
732 case Vec4Array:
734 break;
735 case Mat4Array:
737 break;
738 case StringArray:
740 break;
741 case GuidArray:
743 break;
744 case BlobArray:
746 break;
747 case FileTime:
748 this->i64 = rhs.i64;
749 break;
750 default:
751 n_error("Variant::Copy(): invalid type!");
752 break;
753 }
754}
755
756//------------------------------------------------------------------------------
759inline
761 type(Void)
762{
763 this->Copy(rhs);
764}
765
766//------------------------------------------------------------------------------
769inline
771 type(Byte),
772 i8(rhs)
773{
774 // empty
775}
776
777//------------------------------------------------------------------------------
780inline
782 type(Short),
783 i16(rhs)
784{
785 // empty
786}
787
788//------------------------------------------------------------------------------
791inline
793 type(UShort),
794 ui16(rhs)
795{
796 // empty
797}
798
799//------------------------------------------------------------------------------
802inline
804 type(Int),
805 i(rhs)
806{
807 // empty
808}
809
810//------------------------------------------------------------------------------
813inline
815type(UInt),
816 u(rhs)
817{
818 // empty
819}
820
821//------------------------------------------------------------------------------
824inline
825Variant::Variant(int64_t rhs) :
826 type(Int64),
827 i64(rhs)
828{
829 // empty
830}
831
832//------------------------------------------------------------------------------
835inline
836Variant::Variant(uint64_t rhs) :
837 type(UInt64),
838 u64(rhs)
839{
840 // empty
841}
842//------------------------------------------------------------------------------
845inline
847 type(Float)
848{
849 this->f[0] = rhs;
850}
851
852//------------------------------------------------------------------------------
855inline
856Variant::Variant(double rhs) :
857 type(Double),
858 d(rhs)
859{
860 // empty
861}
862
863//------------------------------------------------------------------------------
866inline
868 type(Bool),
869 b(rhs)
870{
871 // empty
872}
873
874
875//------------------------------------------------------------------------------
878inline
880 type(Vec2)
881{
882 this->f[0] = rhs.x;
883 this->f[1] = rhs.y;
884}
885
886//------------------------------------------------------------------------------
889inline
891 type(Vec3)
892{
893 rhs.storeu(this->f);
894}
895
896//------------------------------------------------------------------------------
899inline
901 type(Vec4)
902{
903 rhs.storeu(this->f);
904}
905
906//------------------------------------------------------------------------------
909inline
912{
913 rhs.storeu(this->f);
914}
915
916//------------------------------------------------------------------------------
919inline
921 type(String)
922{
923 this->string = new Util::String(rhs);
924}
925
926//------------------------------------------------------------------------------
929inline
930Variant::Variant(const char* chrPtr) :
931 type(String)
932{
933 this->string = new Util::String(chrPtr);
934}
935
936//------------------------------------------------------------------------------
939inline
941 type(Object)
942{
943 this->object = ptr;
944 if (this->object)
945 {
946 this->object->AddRef();
947 }
948}
949
950//------------------------------------------------------------------------------
953inline
956{
957 this->voidPtr = ptr;
958}
959
960//------------------------------------------------------------------------------
963inline
964Variant::Variant(std::nullptr_t) :
966{
967 this->voidPtr = nullptr;
968}
969
970//------------------------------------------------------------------------------
973inline
975 type(Mat4)
976{
977 this->m = new Math::mat4(rhs);
978}
979
980//------------------------------------------------------------------------------
983inline
986{
987 this->t = new Math::transform44(rhs);
988}
989
990//------------------------------------------------------------------------------
993inline
995 type(Blob)
996{
997 this->blob = new Util::Blob(rhs);
998}
999
1000//------------------------------------------------------------------------------
1003inline
1004Variant::Variant(const Util::Guid& rhs) :
1005 type(Guid)
1006{
1007 this->guid = new Util::Guid(rhs);
1008}
1009
1010//------------------------------------------------------------------------------
1013inline
1015 type(IntArray)
1016{
1017 this->intArray = new Util::Array<int>(rhs);
1018}
1019
1020//------------------------------------------------------------------------------
1023inline
1026{
1027 this->floatArray = new Util::Array<float>(rhs);
1028}
1029
1030//------------------------------------------------------------------------------
1033inline
1036{
1037 this->boolArray = new Util::Array<bool>(rhs);
1038}
1039
1040//------------------------------------------------------------------------------
1043inline
1045 type(Vec2Array)
1046{
1047 this->vec2Array = new Util::Array<Math::vec2>(rhs);
1048}
1049
1050//------------------------------------------------------------------------------
1053inline
1056{
1057 this->float3Array = new Util::Array<Math::vec3>(rhs);
1058}
1059
1060//------------------------------------------------------------------------------
1063inline
1066{
1067 this->vec4Array = new Util::Array<Math::vec4>(rhs);
1068}
1069
1070//------------------------------------------------------------------------------
1073inline
1076{
1077 this->mat4Array = new Util::Array<Math::mat4>(rhs);
1078}
1079
1080//------------------------------------------------------------------------------
1083inline
1089
1090//------------------------------------------------------------------------------
1093inline
1096{
1097 this->guidArray = new Util::Array<Util::Guid>(rhs);
1098}
1099
1100//------------------------------------------------------------------------------
1103inline
1106{
1107 this->blobArray = new Util::Array<Util::Blob>(rhs);
1108}
1109
1110//------------------------------------------------------------------------------
1113inline
1114Variant::Variant(const IO::FileTime& rhs) :
1115 type(FileTime)
1116{
1117 this->i64 = rhs.AsEpochTime();
1118}
1119
1120//------------------------------------------------------------------------------
1123inline
1125{
1126 this->Delete();
1127}
1128
1129//------------------------------------------------------------------------------
1132inline void
1134{
1135 this->Delete();
1136 this->type = t;
1137 switch (t)
1138 {
1139 case String:
1140 this->string = new Util::String;
1141 break;
1142 case Mat4:
1143 this->m = new Math::mat4;
1144 break;
1145 case Transform44:
1146 this->t = new Math::transform44;
1147 break;
1148 case Blob:
1149 this->blob = new Util::Blob;
1150 break;
1151 case Guid:
1152 this->guid = new Util::Guid;
1153 break;
1154 case Object:
1155 this->object = 0;
1156 break;
1157 case VoidPtr:
1158 this->voidPtr = 0;
1159 break;
1160 case IntArray:
1161 this->intArray = new Util::Array<int>;
1162 break;
1163 case FloatArray:
1164 this->floatArray = new Util::Array<float>;
1165 break;
1166 case BoolArray:
1167 this->boolArray = new Util::Array<bool>;
1168 break;
1169 case Vec2Array:
1171 break;
1172 case Vec3Array:
1174 break;
1175 case Vec4Array:
1177 break;
1178 case Mat4Array:
1180 break;
1181 case StringArray:
1183 break;
1184 case GuidArray:
1186 break;
1187 case BlobArray:
1189 break;
1190 case FileTime:
1191 this->i64 = 0;
1192 break;
1193 default:
1194 break;
1195 }
1196}
1197
1198//------------------------------------------------------------------------------
1201inline Variant::Type
1203{
1204 return this->type;
1205}
1206
1207//------------------------------------------------------------------------------
1210inline void
1212{
1213 this->Delete();
1214 this->Copy(rhs);
1215}
1216
1217//------------------------------------------------------------------------------
1220inline void
1222{
1223 this->Delete();
1224 this->type = Byte;
1225 this->i8 = val;
1226}
1227
1228//------------------------------------------------------------------------------
1231inline void
1233{
1234 this->Delete();
1235 this->type = Short;
1236 this->i16 = val;
1237}
1238
1239//------------------------------------------------------------------------------
1242inline void
1244{
1245 this->Delete();
1246 this->type = UShort;
1247 this->ui16 = val;
1248}
1249
1250//------------------------------------------------------------------------------
1253inline void
1255{
1256 this->Delete();
1257 this->type = Int;
1258 this->i = val;
1259}
1260
1261//------------------------------------------------------------------------------
1264inline void
1266{
1267 this->Delete();
1268 this->type = UInt;
1269 this->u = val;
1270}
1271
1272//------------------------------------------------------------------------------
1275inline void
1277{
1278 this->Delete();
1279 this->type = Int64;
1280 this->i64 = val;
1281}
1282
1283//------------------------------------------------------------------------------
1286inline void
1288{
1289 this->Delete();
1290 this->type = UInt64;
1291 this->u64 = val;
1292}
1293
1294//------------------------------------------------------------------------------
1297inline void
1299{
1300 this->Delete();
1301 this->type = Float;
1302 this->f[0] = val;
1303}
1304
1305//------------------------------------------------------------------------------
1308inline void
1310{
1311 this->Delete();
1312 this->type = Double;
1313 this->d = val;
1314}
1315
1316//------------------------------------------------------------------------------
1319inline void
1321{
1322 this->Delete();
1323 this->type = Bool;
1324 this->b = val;
1325}
1326
1327//------------------------------------------------------------------------------
1330inline void
1332{
1333 this->Delete();
1334 this->type = Vec2;
1335 this->f[0] = val.x;
1336 this->f[1] = val.y;
1337}
1338
1339//------------------------------------------------------------------------------
1342inline void
1344{
1345 this->Delete();
1346 this->type = Vec3;
1347 val.storeu(this->f);
1348}
1349
1350//------------------------------------------------------------------------------
1353inline void
1355{
1356 this->Delete();
1357 this->type = Vec4;
1358 val.storeu(this->f);
1359}
1360
1361//------------------------------------------------------------------------------
1364inline void
1366{
1367 this->Delete();
1368 this->type = Quaternion;
1369 val.storeu(this->f);
1370}
1371
1372//------------------------------------------------------------------------------
1375inline void
1377{
1378 if (String == this->type)
1379 {
1380 *this->string = s;
1381 }
1382 else
1383 {
1384 this->Delete();
1385 this->string = new Util::String(s);
1386 }
1387 this->type = String;
1388}
1389
1390//------------------------------------------------------------------------------
1393inline void
1394Variant::operator=(const char* chrPtr)
1395{
1396 *this = Util::String(chrPtr);
1397}
1398
1399//------------------------------------------------------------------------------
1402inline void
1404{
1405 if (Mat4 == this->type)
1406 {
1407 *this->m = val;
1408 }
1409 else
1410 {
1411 this->Delete();
1412 this->m = new Math::mat4(val);
1413 }
1414 this->type = Mat4;
1415}
1416
1417//------------------------------------------------------------------------------
1420inline void
1422{
1423 if (Transform44 == this->type)
1424 {
1425 *this->t = val;
1426 }
1427 else
1428 {
1429 this->Delete();
1430 this->t = new Math::transform44(val);
1431 }
1432 this->type = Transform44;
1433}
1434//------------------------------------------------------------------------------
1437inline void
1438Variant::operator=(const Util::Guid& val)
1439{
1440 if (Guid == this->type)
1441 {
1442 *this->guid = val;
1443 }
1444 else
1445 {
1446 this->Delete();
1447 this->guid = new Util::Guid(val);
1448 }
1449 this->type = Guid;
1450}
1451
1452//------------------------------------------------------------------------------
1455inline void
1457{
1458 if (Blob == this->type)
1459 {
1460 *this->blob = val;
1461 }
1462 else
1463 {
1464 this->Delete();
1465 this->blob = new Util::Blob(val);
1466 }
1467 this->type = Blob;
1468}
1469
1470//------------------------------------------------------------------------------
1473inline void
1475{
1476 this->Delete();
1477 this->type = Object;
1478 this->object = ptr;
1479 if (this->object)
1480 {
1481 this->object->AddRef();
1482 }
1483}
1484
1485//------------------------------------------------------------------------------
1488inline void
1490{
1491 this->Delete();
1492 this->type = VoidPtr;
1493 this->voidPtr = ptr;
1494}
1495
1496//------------------------------------------------------------------------------
1499inline void
1501{
1502 if (IntArray == this->type)
1503 {
1504 *this->intArray = val;
1505 }
1506 else
1507 {
1508 this->Delete();
1509 this->intArray = new Util::Array<int>(val);
1510 }
1511 this->type = IntArray;
1512}
1513
1514//------------------------------------------------------------------------------
1517inline void
1519{
1520 if (FloatArray == this->type)
1521 {
1522 *this->floatArray = val;
1523 }
1524 else
1525 {
1526 this->Delete();
1527 this->floatArray = new Util::Array<float>(val);
1528 }
1529 this->type = FloatArray;
1530}
1531
1532//------------------------------------------------------------------------------
1535inline void
1537{
1538 if (BoolArray == this->type)
1539 {
1540 *this->boolArray = val;
1541 }
1542 else
1543 {
1544 this->Delete();
1545 this->boolArray = new Util::Array<bool>(val);
1546 }
1547 this->type = BoolArray;
1548}
1549
1550
1551//------------------------------------------------------------------------------
1554inline void
1556{
1557 if (Vec2Array == this->type)
1558 {
1559 *this->vec2Array = rhs;
1560 }
1561 else
1562 {
1563 this->Delete();
1564 this->vec2Array = new Util::Array<Math::vec2>(rhs);
1565 }
1566 this->type = Vec2Array;
1567}
1568
1569//------------------------------------------------------------------------------
1572inline void
1574{
1575 if (Vec3Array == this->type)
1576 {
1577 *this->float3Array = val;
1578 }
1579 else
1580 {
1581 this->Delete();
1582 this->float3Array = new Util::Array<Math::vec3>(val);
1583 }
1584 this->type = Vec3Array;
1585}
1586
1587//------------------------------------------------------------------------------
1590inline void
1592{
1593 if (Vec4Array == this->type)
1594 {
1595 *this->vec4Array = val;
1596 }
1597 else
1598 {
1599 this->Delete();
1600 this->vec4Array = new Util::Array<Math::vec4>(val);
1601 }
1602 this->type = Vec4Array;
1603}
1604
1605//------------------------------------------------------------------------------
1608inline void
1610{
1611 if (Mat4Array == this->type)
1612 {
1613 *this->mat4Array = val;
1614 }
1615 else
1616 {
1617 this->Delete();
1618 this->mat4Array = new Util::Array<Math::mat4>(val);
1619 }
1620 this->type = Mat4Array;
1621}
1622
1623//------------------------------------------------------------------------------
1626inline void
1628{
1629 if (StringArray == this->type)
1630 {
1631 *this->stringArray = val;
1632 }
1633 else
1634 {
1635 this->Delete();
1636 this->stringArray = new Util::Array<Util::String>(val);
1637 }
1638 this->type = StringArray;
1639}
1640
1641//------------------------------------------------------------------------------
1644inline void
1646{
1647 if (GuidArray == this->type)
1648 {
1649 *this->guidArray = val;
1650 }
1651 else
1652 {
1653 this->Delete();
1654 this->guidArray = new Util::Array<Util::Guid>(val);
1655 }
1656 this->type = GuidArray;
1657}
1658
1659//------------------------------------------------------------------------------
1662inline void
1664{
1665 if (BlobArray == this->type)
1666 {
1667 *this->blobArray = val;
1668 }
1669 else
1670 {
1671 this->Delete();
1672 this->blobArray = new Util::Array<Util::Blob>(val);
1673 }
1674 this->type = BlobArray;
1675}
1676
1677//------------------------------------------------------------------------------
1678/***/
1679inline void
1680Variant::operator=(const IO::FileTime& val)
1681{
1682 this->Delete();
1683 this->type = FileTime;
1684 this->i64 = val.AsEpochTime();
1685}
1686
1687//------------------------------------------------------------------------------
1690inline bool
1692{
1693 if (rhs.type == this->type)
1694 {
1695 switch (rhs.type)
1696 {
1697 case Void:
1698 return true;
1699 case Byte:
1700 return (this->i8 == rhs.i8);
1701 case Short:
1702 return (this->i16 == rhs.i16);
1703 case UShort:
1704 return (this->ui16 == rhs.ui16);
1705 case Int:
1706 return (this->i == rhs.i);
1707 case UInt:
1708 return (this->u == rhs.u);
1709 case Int64:
1710 return (this->i64 == rhs.i64);
1711 case UInt64:
1712 return (this->u64 == rhs.u64);
1713 case Bool:
1714 return (this->b == rhs.b);
1715 case Float:
1716 return (this->f[0] == rhs.f[0]);
1717 case Double:
1718 return (this->d == rhs.d);
1719 case String:
1720 return ((*this->string) == (*rhs.string));
1721 case Vec2:
1722 return ((this->f[0] == rhs.f[0]) && (this->f[1] == rhs.f[1]));
1723 case Vec4:
1724 return ((this->f[0] == rhs.f[0]) &&
1725 (this->f[1] == rhs.f[1]) &&
1726 (this->f[2] == rhs.f[2]) &&
1727 (this->f[3] == rhs.f[3]));
1728 case Quaternion:
1729 return ((this->f[0] == rhs.f[0]) &&
1730 (this->f[1] == rhs.f[1]) &&
1731 (this->f[2] == rhs.f[2]) &&
1732 (this->f[3] == rhs.f[3]));
1733 case Guid:
1734 return ((*this->guid) == (*rhs.guid));
1735 case Blob:
1736 return ((*this->blob) == (*rhs.blob));
1737 case Object:
1738 return (this->object == rhs.object);
1739 case VoidPtr:
1740 return (this->voidPtr == rhs.voidPtr);
1741 case Mat4:
1742 return ((*this->m) == (*rhs.m));
1743 case Transform44:
1744 return ((*this->t) == (*rhs.t));
1745 case FileTime:
1746 return (this->i64 == rhs.i64);
1747 default:
1748 n_error("Variant::operator==(): invalid variant type!");
1749 return false;
1750 }
1751 }
1752 return false;
1753}
1754
1755//------------------------------------------------------------------------------
1758inline bool
1760{
1761 if (rhs.type == this->type)
1762 {
1763 switch (rhs.type)
1764 {
1765 case Void:
1766 return true;
1767 case Byte:
1768 return (this->i8 > rhs.i8);
1769 case Short:
1770 return (this->i16 > rhs.i16);
1771 case UShort:
1772 return (this->ui16 > rhs.ui16);
1773 case Int:
1774 return (this->i > rhs.i);
1775 case UInt:
1776 return (this->u > rhs.u);
1777 case Int64:
1778 return (this->i64 > rhs.i64);
1779 case UInt64:
1780 return (this->u64 > rhs.u64);
1781 case Bool:
1782 return (this->b > rhs.b);
1783 case Float:
1784 return (this->f[0] > rhs.f[0]);
1785 case Double:
1786 return (this->d > rhs.d);
1787 case String:
1788 return ((*this->string) > (*rhs.string));
1789 case Vec2:
1790 return ((this->f[0] > rhs.f[0]) && (this->f[1] > rhs.f[1]));
1791 case Vec4:
1792 return ((this->f[0] > rhs.f[0]) &&
1793 (this->f[1] > rhs.f[1]) &&
1794 (this->f[2] > rhs.f[2]) &&
1795 (this->f[3] > rhs.f[3]));
1796 case Quaternion:
1797 return ((this->f[0] > rhs.f[0]) &&
1798 (this->f[1] > rhs.f[1]) &&
1799 (this->f[2] > rhs.f[2]) &&
1800 (this->f[3] > rhs.f[3]));
1801 case Guid:
1802 return ((*this->guid) > (*rhs.guid));
1803 case Blob:
1804 return ((*this->blob) > (*rhs.blob));
1805 case Object:
1806 return (this->object > rhs.object);
1807 case VoidPtr:
1808 return (this->voidPtr > rhs.voidPtr);
1809 case FileTime:
1810 return (this->i64 > rhs.i64);
1811 default:
1812 n_error("Variant::operator>(): invalid variant type!");
1813 return false;
1814 }
1815 }
1816 return false;
1817}
1818
1819//------------------------------------------------------------------------------
1822inline bool
1823Variant::operator<(const Variant& rhs) const
1824{
1825 if (rhs.type == this->type)
1826 {
1827 switch (rhs.type)
1828 {
1829 case Void:
1830 return true;
1831 case Byte:
1832 return (this->i8 < rhs.i8);
1833 case Short:
1834 return (this->i16 < rhs.i16);
1835 case UShort:
1836 return (this->ui16 < rhs.ui16);
1837 case Int:
1838 return (this->i < rhs.i);
1839 case UInt:
1840 return (this->u < rhs.u);
1841 case Int64:
1842 return (this->i64 < rhs.i64);
1843 case UInt64:
1844 return (this->u64 < rhs.u64);
1845 case Bool:
1846 return (this->b < rhs.b);
1847 case Float:
1848 return (this->f[0] < rhs.f[0]);
1849 case Double:
1850 return (this->d > rhs.d);
1851 case String:
1852 return ((*this->string) < (*rhs.string));
1853 case Vec2:
1854 return ((this->f[0] < rhs.f[0]) && (this->f[1] < rhs.f[1]));
1855 case Vec4:
1856 return ((this->f[0] < rhs.f[0]) &&
1857 (this->f[1] < rhs.f[1]) &&
1858 (this->f[2] < rhs.f[2]) &&
1859 (this->f[3] < rhs.f[3]));
1860 case Quaternion:
1861 return ((this->f[0] < rhs.f[0]) &&
1862 (this->f[1] < rhs.f[1]) &&
1863 (this->f[2] < rhs.f[2]) &&
1864 (this->f[3] < rhs.f[3]));
1865 case Guid:
1866 return ((*this->guid) < (*rhs.guid));
1867 case Blob:
1868 return ((*this->blob) < (*rhs.blob));
1869 case Object:
1870 return (this->object < rhs.object);
1871 case VoidPtr:
1872 return (this->voidPtr < rhs.voidPtr);
1873 case FileTime:
1874 return (this->i64 < rhs.i64);
1875 default:
1876 n_error("Variant::operator<(): invalid variant type!");
1877 return false;
1878 }
1879 }
1880 return false;
1881}
1882
1883
1884//------------------------------------------------------------------------------
1887inline bool
1889{
1890 if (rhs.type == this->type)
1891 {
1892 switch (rhs.type)
1893 {
1894 case Void:
1895 return true;
1896 case Byte:
1897 return (this->i8 >= rhs.i8);
1898 case Short:
1899 return (this->i16 >= rhs.i16);
1900 case UShort:
1901 return (this->ui16 >= rhs.ui16);
1902 case Int:
1903 return (this->i >= rhs.i);
1904 case UInt:
1905 return (this->u >= rhs.u);
1906 case Int64:
1907 return (this->i64 >= rhs.i64);
1908 case UInt64:
1909 return (this->u64 >= rhs.u64);
1910 case Bool:
1911 return (this->b >= rhs.b);
1912 case Float:
1913 return (this->f[0] >= rhs.f[0]);
1914 case Double:
1915 return (this->d >= rhs.d);
1916 case String:
1917 return ((*this->string) >= (*rhs.string));
1918 case Vec2:
1919 return ((this->f[0] >= rhs.f[0]) && (this->f[1] >= rhs.f[1]));
1920 case Vec4:
1921 return ((this->f[0] >= rhs.f[0]) &&
1922 (this->f[1] >= rhs.f[1]) &&
1923 (this->f[2] >= rhs.f[2]) &&
1924 (this->f[3] >= rhs.f[3]));
1925 case Quaternion:
1926 return ((this->f[0] >= rhs.f[0]) &&
1927 (this->f[1] >= rhs.f[1]) &&
1928 (this->f[2] >= rhs.f[2]) &&
1929 (this->f[3] >= rhs.f[3]));
1930 case Guid:
1931 return ((*this->guid) >= (*rhs.guid));
1932 case Blob:
1933 return ((*this->blob) >= (*rhs.blob));
1934 case Object:
1935 return (this->object >= rhs.object);
1936 case VoidPtr:
1937 return (this->voidPtr >= rhs.voidPtr);
1938 case FileTime:
1939 return (this->i64 >= rhs.i64);
1940 default:
1941 n_error("Variant::operator>(): invalid variant type!");
1942 return false;
1943 }
1944 }
1945 return false;
1946}
1947
1948//------------------------------------------------------------------------------
1951inline bool
1952Variant::operator<=(const Variant& rhs) const
1953{
1954 if (rhs.type == this->type)
1955 {
1956 switch (rhs.type)
1957 {
1958 case Void:
1959 return true;
1960 case Byte:
1961 return (this->i8 <= rhs.i8);
1962 case Short:
1963 return (this->i16 <= rhs.i16);
1964 case UShort:
1965 return (this->ui16 <= rhs.ui16);
1966 case Int:
1967 return (this->i <= rhs.i);
1968 case UInt:
1969 return (this->u <= rhs.u);
1970 case Int64:
1971 return (this->i64 <= rhs.i64);
1972 case UInt64:
1973 return (this->u64 <= rhs.u64);
1974 case Bool:
1975 return (this->b <= rhs.b);
1976 case Float:
1977 return (this->f[0] <= rhs.f[0]);
1978 case Double:
1979 return (this->d >= rhs.d);
1980 case String:
1981 return ((*this->string) <= (*rhs.string));
1982 case Vec2:
1983 return ((this->f[0] <= rhs.f[0]) && (this->f[1] <= rhs.f[1]));
1984 case Vec4:
1985 return ((this->f[0] <= rhs.f[0]) &&
1986 (this->f[1] <= rhs.f[1]) &&
1987 (this->f[2] <= rhs.f[2]) &&
1988 (this->f[3] <= rhs.f[3]));
1989 case Quaternion:
1990 return ((this->f[0] <= rhs.f[0]) &&
1991 (this->f[1] <= rhs.f[1]) &&
1992 (this->f[2] <= rhs.f[2]) &&
1993 (this->f[3] <= rhs.f[3]));
1994 case Guid:
1995 return ((*this->guid) <= (*rhs.guid));
1996 case Blob:
1997 return ((*this->blob) <= (*rhs.blob));
1998 case Object:
1999 return (this->object <= rhs.object);
2000 case VoidPtr:
2001 return (this->voidPtr <= rhs.voidPtr);
2002 case FileTime:
2003 return (this->i64 <= rhs.i64);
2004 default:
2005 n_error("Variant::operator<(): invalid variant type!");
2006 return false;
2007 }
2008 }
2009 return false;
2010}
2011
2012//------------------------------------------------------------------------------
2015inline bool
2017{
2018 return !(*this == rhs);
2019}
2020
2021//------------------------------------------------------------------------------
2024inline bool
2025Variant::operator==(byte rhs) const
2026{
2027 n_assert(Byte == this->type);
2028 return (this->i8 == rhs);
2029}
2030
2031//------------------------------------------------------------------------------
2034inline bool
2035Variant::operator==(short rhs) const
2036{
2037 n_assert(Short == this->type);
2038 return (this->i16 == rhs);
2039}
2040
2041//------------------------------------------------------------------------------
2044inline bool
2046{
2047 n_assert(UShort == this->type);
2048 return (this->ui16 == rhs);
2049}
2050
2051//------------------------------------------------------------------------------
2054inline bool
2056{
2057 n_assert(Int == this->type);
2058 return (this->i == rhs);
2059}
2060
2061//------------------------------------------------------------------------------
2064inline bool
2066{
2067 n_assert(UInt == this->type);
2068 return (this->u == rhs);
2069}
2070
2071//------------------------------------------------------------------------------
2074inline bool
2075Variant::operator==(int64_t rhs) const
2076{
2077 n_assert(Int64 == this->type);
2078 return (this->i64 == rhs);
2079}
2080
2081//------------------------------------------------------------------------------
2084inline bool
2085Variant::operator==(uint64_t rhs) const
2086{
2087 n_assert(UInt64 == this->type);
2088 return (this->u64 == rhs);
2089}
2090
2091//------------------------------------------------------------------------------
2094inline bool
2095Variant::operator==(float rhs) const
2096{
2097 n_assert(Float == this->type);
2098 return (this->f[0] == rhs);
2099}
2100
2101//------------------------------------------------------------------------------
2104inline bool
2105Variant::operator==(double rhs) const
2106{
2107 n_assert(Double == this->type);
2108 return (this->d == rhs);
2109}
2110
2111//------------------------------------------------------------------------------
2114inline bool
2115Variant::operator==(bool rhs) const
2116{
2117 n_assert(Bool == this->type);
2118 return (this->b == rhs);
2119}
2120
2121//------------------------------------------------------------------------------
2124inline bool
2126{
2127 n_assert(String == this->type);
2128 return ((*this->string) == rhs);
2129}
2130
2131//------------------------------------------------------------------------------
2134inline bool
2135Variant::operator==(const char* chrPtr) const
2136{
2137 return *this == Util::String(chrPtr);
2138}
2139
2140
2141//------------------------------------------------------------------------------
2144inline bool
2146{
2147 n_assert(Vec2 == this->type);
2148 return (this->f[0] == rhs.x && this->f[1] == rhs.y);
2149}
2150
2151//------------------------------------------------------------------------------
2154inline bool
2156{
2157 n_assert(Vec4 == this->type);
2158 return ((this->f[0] == rhs.x) &&
2159 (this->f[1] == rhs.y) &&
2160 (this->f[2] == rhs.z) &&
2161 (this->f[3] == rhs.w));
2162}
2163
2164//------------------------------------------------------------------------------
2167inline bool
2169{
2170 n_assert(Quaternion == this->type);
2171 return ((this->f[0] == rhs.x) &&
2172 (this->f[1] == rhs.y) &&
2173 (this->f[2] == rhs.z) &&
2174 (this->f[3] == rhs.w));
2175}
2176
2177//------------------------------------------------------------------------------
2180inline bool
2181Variant::operator==(const Util::Guid& rhs) const
2182{
2183 n_assert(Guid == this->type);
2184 return (*this->guid) == rhs;
2185}
2186
2187//------------------------------------------------------------------------------
2190inline bool
2192{
2193 n_assert(Object == this->type);
2194 return this->object == ptr;
2195}
2196
2197//------------------------------------------------------------------------------
2200inline bool
2201Variant::operator==(void* ptr) const
2202{
2203 n_assert(VoidPtr == this->type);
2204 return this->voidPtr == ptr;
2205}
2206
2207//------------------------------------------------------------------------------
2208/**/
2209inline bool
2210Variant::operator==(const IO::FileTime& rhs) const
2211{ return (this->i64 == rhs.AsEpochTime());
2212}
2213
2214//------------------------------------------------------------------------------
2217inline bool
2218Variant::operator!=(byte rhs) const
2219{
2220 n_assert(Byte == this->type);
2221 return (this->i8 != rhs);
2222}
2223
2224//------------------------------------------------------------------------------
2227inline bool
2228Variant::operator!=(short rhs) const
2229{
2230 n_assert(Short == this->type);
2231 return (this->i16 != rhs);
2232}
2233
2234//------------------------------------------------------------------------------
2237inline bool
2239{
2240 n_assert(UShort == this->type);
2241 return (this->ui16 != rhs);
2242}
2243
2244//------------------------------------------------------------------------------
2247inline bool
2249{
2250 n_assert(Int == this->type);
2251 return (this->i != rhs);
2252}
2253
2254//------------------------------------------------------------------------------
2257inline bool
2259{
2260 n_assert(UInt == this->type);
2261 return (this->u != rhs);
2262}
2263
2264//------------------------------------------------------------------------------
2267inline bool
2268Variant::operator!=(int64_t rhs) const
2269{
2270 n_assert(Int64 == this->type);
2271 return (this->i64 != rhs);
2272}
2273
2274//------------------------------------------------------------------------------
2277inline bool
2278Variant::operator!=(uint64_t rhs) const
2279{
2280 n_assert(UInt64 == this->type);
2281 return (this->u64 != rhs);
2282}
2283
2284//------------------------------------------------------------------------------
2287inline bool
2288Variant::operator!=(float rhs) const
2289{
2290 n_assert(Float == this->type);
2291 return (this->f[0] != rhs);
2292}
2293
2294//------------------------------------------------------------------------------
2297inline bool
2298Variant::operator!=(double rhs) const
2299{
2300 n_assert(Double == this->type);
2301 return (this->d != rhs);
2302}
2303
2304//------------------------------------------------------------------------------
2307inline bool
2308Variant::operator!=(bool rhs) const
2309{
2310 n_assert(Bool == this->type);
2311 return (this->b != rhs);
2312}
2313
2314//------------------------------------------------------------------------------
2317inline bool
2319{
2320 n_assert(String == this->type);
2321 return (*this->string) != rhs;
2322}
2323
2324//------------------------------------------------------------------------------
2327inline bool
2328Variant::operator!=(const char* chrPtr) const
2329{
2330 return *this != Util::String(chrPtr);
2331}
2332
2333
2334//------------------------------------------------------------------------------
2337inline bool
2339{
2340 n_assert(Vec2 == this->type);
2341 return (this->f[0] != rhs.x || this->f[1] != rhs.y);
2342}
2343
2344//------------------------------------------------------------------------------
2347inline bool
2349{
2350 n_assert(Vec4 == this->type);
2351 return ((this->f[0] != rhs.x) ||
2352 (this->f[1] != rhs.y) ||
2353 (this->f[2] != rhs.z) ||
2354 (this->f[3] != rhs.w));
2355}
2356
2357//------------------------------------------------------------------------------
2360inline bool
2362{
2363 n_assert(Quaternion == this->type);
2364 return ((this->f[0] != rhs.x) ||
2365 (this->f[1] != rhs.y) ||
2366 (this->f[2] != rhs.z) ||
2367 (this->f[3] != rhs.w));
2368}
2369
2370//------------------------------------------------------------------------------
2373inline bool
2374Variant::operator!=(const Util::Guid& rhs) const
2375{
2376 n_assert(Guid == this->type);
2377 return (*this->guid) != rhs;
2378}
2379
2380//------------------------------------------------------------------------------
2383inline bool
2385{
2386 n_assert(Object == this->type);
2387 return (this->object == ptr);
2388}
2389
2390//------------------------------------------------------------------------------
2393inline bool
2394Variant::operator!=(void* ptr) const
2395{
2396 n_assert(VoidPtr == this->type);
2397 return (this->voidPtr == ptr);
2398}
2399
2400//------------------------------------------------------------------------------
2401/*
2402*/
2403inline bool
2404Variant::operator!=(const IO::FileTime& rhs) const
2405{
2406 return (this->i64 != rhs.AsEpochTime());
2407}
2408
2409//------------------------------------------------------------------------------
2412inline void
2414{
2415 *this = val;
2416}
2417
2418//------------------------------------------------------------------------------
2421inline byte
2423{
2424 n_assert(Byte == this->type);
2425 return this->i8;
2426}
2427
2428//------------------------------------------------------------------------------
2431inline void
2433{
2434 *this = val;
2435}
2436
2437//------------------------------------------------------------------------------
2440inline void
2442{
2443 *this = val;
2444}
2445
2446//------------------------------------------------------------------------------
2449inline short
2451{
2452 n_assert(Short == this->type);
2453 return this->i16;
2454}
2455
2456//------------------------------------------------------------------------------
2459inline ushort
2461{
2462 n_assert(UShort == this->type);
2463 return this->ui16;
2464}
2465
2466//------------------------------------------------------------------------------
2469inline void
2471{
2472 *this = val;
2473}
2474
2475//------------------------------------------------------------------------------
2478inline void
2480{
2481 *this = val;
2482}
2483
2484//------------------------------------------------------------------------------
2487inline int
2489{
2490 n_assert(Int == this->type);
2491 return this->i;
2492}
2493
2494//------------------------------------------------------------------------------
2497inline uint
2499{
2500 n_assert(UInt == this->type);
2501 return this->u;
2502}
2503
2504//------------------------------------------------------------------------------
2507inline void
2509{
2510 n_assert(Int64 == this->type);
2511 this->i64 = val;
2512}
2513
2514//------------------------------------------------------------------------------
2517inline int64_t
2519{
2520 n_assert(Int64 == this->type);
2521 return this->i64;
2522}
2523
2524//------------------------------------------------------------------------------
2527inline void
2529{
2530 n_assert(UInt64 == this->type);
2531 this->u64 = val;
2532}
2533
2534//------------------------------------------------------------------------------
2537inline uint64_t
2539{
2540 n_assert(UInt64 == this->type);
2541 return this->u64;
2542}
2543
2544//------------------------------------------------------------------------------
2547inline void
2549{
2550 *this = val;
2551}
2552
2553//------------------------------------------------------------------------------
2556inline float
2558{
2559 n_assert(Float == this->type);
2560 return this->f[0];
2561}
2562
2563//------------------------------------------------------------------------------
2566inline void
2568{
2569 *this = val;
2570}
2571
2572//------------------------------------------------------------------------------
2575inline double
2577{
2578 n_assert(Double == this->type);
2579 return this->d;
2580}
2581
2582//------------------------------------------------------------------------------
2585inline void
2587{
2588 *this = val;
2589}
2590
2591//------------------------------------------------------------------------------
2594inline bool
2596{
2597 n_assert(Bool == this->type);
2598 return this->b;
2599}
2600
2601//------------------------------------------------------------------------------
2604inline void
2606{
2607 *this = val;
2608}
2609
2610//------------------------------------------------------------------------------
2613inline const Util::String&
2615{
2616 n_assert(String == this->type);
2617 return *(this->string);
2618}
2619
2620//------------------------------------------------------------------------------
2623inline void
2625{
2626 *this = val;
2627}
2628
2629//------------------------------------------------------------------------------
2632inline Math::vec2
2634{
2635 n_assert(Vec2 == this->type);
2636 return Math::vec2(this->f[0], this->f[1]);
2637}
2638
2639//------------------------------------------------------------------------------
2642inline void
2644{
2645 *this = val;
2646}
2647
2648//------------------------------------------------------------------------------
2651inline Math::vec3
2653{
2654 return Math::vec3();
2655}
2656
2657//------------------------------------------------------------------------------
2660inline void
2662{
2663 *this = val;
2664}
2665
2666//------------------------------------------------------------------------------
2669inline Math::vec4
2671{
2672 n_assert(Vec4 == this->type);
2673 return Math::vec4(this->f[0], this->f[1], this->f[2], this->f[3]);
2674}
2675
2676//------------------------------------------------------------------------------
2679inline void
2681{
2682 *this = val;
2683}
2684
2685//------------------------------------------------------------------------------
2688inline Math::quat
2690{
2691 n_assert(Quaternion == this->type);
2692 return Math::quat(this->f[0], this->f[1], this->f[2], this->f[3]);
2693}
2694
2695//------------------------------------------------------------------------------
2698inline void
2700{
2701 *this = val;
2702}
2703
2704//------------------------------------------------------------------------------
2707inline const Math::mat4&
2709{
2710 n_assert(Mat4 == this->type);
2711 return *(this->m);
2712}
2713
2714//------------------------------------------------------------------------------
2717inline void
2719{
2720 *this = val;
2721}
2722
2723//------------------------------------------------------------------------------
2726inline const Math::transform44&
2728{
2729 n_assert(Transform44 == this->type);
2730 return *(this->t);
2731}
2732
2733//------------------------------------------------------------------------------
2736inline void
2737Variant::SetGuid(const Util::Guid& val)
2738{
2739 *this = val;
2740}
2741
2742//------------------------------------------------------------------------------
2745inline const Util::Guid&
2747{
2748 n_assert(Guid == this->type);
2749 return *(this->guid);
2750}
2751
2752//------------------------------------------------------------------------------
2755inline void
2757{
2758 *this = val;
2759}
2760
2761//------------------------------------------------------------------------------
2764inline const Util::Blob&
2766{
2767 n_assert(Blob == this->type);
2768 return *(this->blob);
2769}
2770
2771//------------------------------------------------------------------------------
2774inline void
2776{
2777 *this = ptr;
2778}
2779
2780//------------------------------------------------------------------------------
2783inline Core::RefCounted*
2785{
2786 n_assert(Object == this->type);
2787 return this->object;
2788}
2789
2790//------------------------------------------------------------------------------
2793inline void
2795{
2796 *this = ptr;
2797}
2798
2799//------------------------------------------------------------------------------
2802inline void*
2804{
2805 n_assert(VoidPtr == this->type);
2806 return this->voidPtr;
2807}
2808
2809//------------------------------------------------------------------------------
2812inline void
2814{
2815 *this = val;
2816}
2817
2818//------------------------------------------------------------------------------
2821inline const Util::Array<int>&
2823{
2824 n_assert(IntArray == this->type);
2825 return *(this->intArray);
2826}
2827
2828//------------------------------------------------------------------------------
2831inline void
2833{
2834 *this = val;
2835}
2836
2837//------------------------------------------------------------------------------
2840inline const Util::Array<float>&
2842{
2843 n_assert(FloatArray == this->type);
2844 return *(this->floatArray);
2845}
2846
2847//------------------------------------------------------------------------------
2850inline void
2852{
2853 *this = val;
2854}
2855
2856//------------------------------------------------------------------------------
2859inline const Util::Array<bool>&
2861{
2862 n_assert(BoolArray == this->type);
2863 return *(this->boolArray);
2864}
2865
2866//------------------------------------------------------------------------------
2869inline void
2871{
2872 *this = val;
2873}
2874
2875//------------------------------------------------------------------------------
2878inline const Util::Array<Math::vec2>&
2880{
2881 n_assert(Vec2Array == this->type);
2882 return *(this->vec2Array);
2883}
2884
2885//------------------------------------------------------------------------------
2888inline void
2890{
2891 *this = val;
2892}
2893
2894//------------------------------------------------------------------------------
2897inline const Util::Array<Math::vec3>&
2899{
2900 n_assert(Vec3Array == this->type);
2901 return *(this->float3Array);
2902}
2903
2904//------------------------------------------------------------------------------
2907inline void
2909{
2910 *this = val;
2911}
2912
2913//------------------------------------------------------------------------------
2916inline const Util::Array<Math::vec4>&
2918{
2919 n_assert(Vec4Array == this->type);
2920 return *(this->vec4Array);
2921}
2922
2923//------------------------------------------------------------------------------
2926inline void
2928{
2929 *this = val;
2930}
2931
2932//------------------------------------------------------------------------------
2935inline const Util::Array<Math::mat4>&
2937{
2938 n_assert(Mat4Array == this->type);
2939 return *(this->mat4Array);
2940}
2941
2942//------------------------------------------------------------------------------
2945inline void
2947{
2948 *this = val;
2949}
2950
2951//------------------------------------------------------------------------------
2954inline const Util::Array<Util::String>&
2956{
2957 n_assert(StringArray == this->type);
2958 return *(this->stringArray);
2959}
2960
2961//------------------------------------------------------------------------------
2964inline void
2966{
2967 *this = val;
2968}
2969
2970//------------------------------------------------------------------------------
2973inline const Util::Array<Util::Guid>&
2975{
2976 n_assert(GuidArray == this->type);
2977 return *(this->guidArray);
2978}
2979
2980//------------------------------------------------------------------------------
2983inline void
2985{
2986 *this = val;
2987}
2988
2989//------------------------------------------------------------------------------
2992inline void
2993Variant::SetFileTime(const IO::FileTime& val)
2994{
2995 *this = val;
2996}
2997
2998//------------------------------------------------------------------------------
3001inline IO::FileTime
3003{
3004 n_assert(FileTime == this->type);
3005 IO::FileTime fileTime(this->i64);
3006 return fileTime;
3007}
3008
3009//------------------------------------------------------------------------------
3012inline const Util::Array<Util::Blob>&
3014{
3015 n_assert(BlobArray == this->type);
3016 return *(this->blobArray);
3017}
3018
3019//------------------------------------------------------------------------------
3022template <typename TYPE>
3023inline TYPE
3025{
3026 static_assert(true, "Get method for TYPE is not implemented!");
3027 TYPE ret;
3028 return ret;
3029}
3030
3031//------------------------------------------------------------------------------
3034template <>
3035inline byte
3037{
3038 return this->GetByte();
3039}
3040
3041//------------------------------------------------------------------------------
3044template <>
3045inline short
3047{
3048 return this->GetShort();
3049}
3050
3051//------------------------------------------------------------------------------
3054template <>
3055inline int
3057{
3058 return this->GetInt();
3059}
3060
3061//------------------------------------------------------------------------------
3064template <>
3065inline uint
3067{
3068 return this->GetUInt();
3069}
3070
3071//------------------------------------------------------------------------------
3074template <>
3075inline int64_t
3077{
3078 return this->GetInt64();
3079}
3080
3081//------------------------------------------------------------------------------
3084template <>
3085inline uint64_t
3087{
3088 return this->GetUInt64();
3089}
3090
3091//------------------------------------------------------------------------------
3094template <>
3095inline bool
3097{
3098 return this->GetBool();
3099}
3100
3101//------------------------------------------------------------------------------
3104template <>
3105inline double
3107{
3108 return this->GetDouble();
3109}
3110
3111//------------------------------------------------------------------------------
3114template <>
3115inline float
3117{
3118 return this->GetFloat();
3119}
3120
3121//------------------------------------------------------------------------------
3124template <>
3125inline Math::vec2
3127{
3128 return this->GetVec2();
3129}
3130
3131//------------------------------------------------------------------------------
3134template <>
3135inline Math::vec3
3137{
3138 return this->GetVec3();
3139}
3140
3141//------------------------------------------------------------------------------
3144template <>
3145inline Math::vec4
3147{
3148 return this->GetVec4();
3149}
3150
3151//------------------------------------------------------------------------------
3154template <>
3155inline Math::quat
3157{
3158 return this->GetQuat();
3159}
3160
3161//------------------------------------------------------------------------------
3164template <>
3165inline Math::mat4
3167{
3168 return this->GetMat4();
3169}
3170
3171//------------------------------------------------------------------------------
3174template <>
3175inline Math::transform44
3177{
3178 return this->GetTransform44();
3179}
3180
3181//------------------------------------------------------------------------------
3184template <>
3185inline Util::String
3187{
3188 return this->GetString();
3189}
3190
3191//------------------------------------------------------------------------------
3194template <>
3195inline Util::Guid
3197{
3198 return this->GetGuid();
3199}
3200
3201//------------------------------------------------------------------------------
3204template <>
3205inline Util::Blob
3207{
3208 return this->GetBlob();
3209}
3210
3211//------------------------------------------------------------------------------
3214template <>
3215inline Util::Array<int>
3217{
3218 return this->GetIntArray();
3219}
3220
3221//------------------------------------------------------------------------------
3224template <>
3225inline Util::Array<float>
3227{
3228 return this->GetFloatArray();
3229}
3230
3231//------------------------------------------------------------------------------
3234template <>
3235inline Util::Array<bool>
3237{
3238 return this->GetBoolArray();
3239}
3240
3241//------------------------------------------------------------------------------
3244template <>
3247{
3248 return this->GetVec2Array();
3249}
3250
3251//------------------------------------------------------------------------------
3254template <>
3257{
3258 return this->GetVec3Array();
3259}
3260
3261//------------------------------------------------------------------------------
3264template <>
3267{
3268 return this->GetVec4Array();
3269}
3270
3271//------------------------------------------------------------------------------
3274template <>
3277{
3278 return this->GetMat4Array();
3279}
3280
3281//------------------------------------------------------------------------------
3284template <>
3287{
3288 return this->GetStringArray();
3289}
3290
3291//------------------------------------------------------------------------------
3294template <>
3297{
3298 return this->GetGuidArray();
3299}
3300
3301//------------------------------------------------------------------------------
3304template <>
3307{
3308 return this->GetBlobArray();
3309}
3310
3311//------------------------------------------------------------------------------
3314template <>
3315inline IO::FileTime
3317{
3318 return this->GetFileTime();
3319}
3320//------------------------------------------------------------------------------
3323inline Util::String
3325{
3326 Util::String retval = "";
3327 switch (this->type)
3328 {
3329 case Void: break;
3330 case Byte: { retval = Util::String::FromByte(this->GetByte()); break; }
3331 case Short: { retval = Util::String::FromShort(this->GetShort()); break; }
3332 case UShort: { retval = Util::String::FromUShort(this->GetUShort()); break; }
3333 case Int: { retval = Util::String::FromInt(this->GetInt()); break; }
3334 case UInt: { retval = Util::String::FromUInt(this->GetUInt()); break; }
3335 case Float: { retval = Util::String::FromFloat(this->GetFloat()); break; }
3336 case Double: { retval = Util::String::FromDouble(this->GetDouble()); break; }
3337 case Bool: { retval = Util::String::FromBool(this->GetBool()); break; }
3338 case Vec2: { retval = Util::String::FromVec2(this->GetVec2()); break; }
3339 case Vec3: { retval = Util::String::FromVec3(this->GetVec3()); break; }
3340 case Vec4: { retval = Util::String::FromVec4(this->GetVec4()); break; }
3341 case Quaternion: { retval = Util::String::FromQuat(this->GetQuat()); break; }
3342 case String: { retval = this->GetString(); break; }
3343 case Mat4: { retval = Util::String::FromMat4(this->GetMat4()); break; }
3344 case Transform44: { retval = Util::String::FromTransform44(this->GetTransform44()); break; }
3345 case Blob: { retval = Util::String::FromBlob(this->GetBlob()); break; }
3346 case Guid: { retval = this->GetGuid().AsString(); break; }
3347 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; }
3348 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; }
3349 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; }
3350 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; }
3351 default:
3352 n_error("Variant::ToString(): invalid type enum '%d'", this->type);
3353
3354 }
3355 return retval;
3356}
3357
3358//------------------------------------------------------------------------------
3363inline bool
3365{
3366 bool retval = false;
3367 switch (this->type)
3368 {
3369 case Int:
3370 case UInt: { if(string.IsValidInt()) { this->SetUInt(string.AsInt()); retval = true; } break; };
3371 case Float: { if(string.IsValidFloat()) { this->SetFloat(string.AsFloat()); retval = true; } break; }
3372 case Bool: { if(string.IsValidBool()) { this->SetBool(string.AsBool()); retval = true; } break; }
3373 case Vec2: { if(string.IsValidVec2()) { this->SetVec2(string.AsVec2()); retval = true; } break; }
3374 case Vec4: { if(string.IsValidVec4()) { this->SetVec4(string.AsVec4()); retval = true; } break; }
3375 case String: { this->SetString(string); retval = true; break; }
3376 case Mat4: { if(string.IsValidMat4()) { this->SetMat4(string.AsMat4()); retval = true; } break; }
3377 case Transform44: { if (string.IsValidTransform44()) { this->SetTransform44(string.AsTransform44()); retval = true; } break; }
3378
3379 case IntArray:
3380 {
3381 Util::Array<Util::String> tokens = string.Tokenize(",");
3382 Util::Array<int> result;
3383 IndexT i;
3384 for (i = 0; i < tokens.Size(); i++)
3385 {
3386 if (tokens[i].IsValidInt())
3387 {
3388 result.Append(tokens[i].AsInt());
3389 }
3390 }
3391 this->SetIntArray(result);
3392 retval = true;
3393 break;
3394 }
3395 case FloatArray:
3396 {
3397 Util::Array<Util::String> tokens = string.Tokenize(",");
3398 Util::Array<float> result;
3399 IndexT i;
3400 for (i = 0; i < tokens.Size(); i++)
3401 {
3402 if (tokens[i].IsValidFloat())
3403 {
3404 result.Append(tokens[i].AsFloat());
3405 }
3406 }
3407 this->SetFloatArray(result);
3408 retval = true;
3409 break;
3410 }
3411 case BoolArray:
3412 {
3413 Util::Array<Util::String> tokens = string.Tokenize(",");
3414 Util::Array<bool> result;
3415 IndexT i;
3416 for (i = 0; i < tokens.Size(); i++)
3417 {
3418 if (tokens[i].IsValidBool())
3419 {
3420 result.Append(tokens[i].AsBool());
3421 }
3422 }
3423 this->SetBoolArray(result);
3424 retval = true;
3425 break;
3426 }
3427 case StringArray:
3428 {
3429 Util::Array<Util::String> tokens = string.Tokenize(",");
3430 this->SetStringArray(tokens);
3431 retval = true;
3432 break;
3433 }
3434 default:
3435 break;
3436 }
3437 return retval;
3438}
3439
3440//------------------------------------------------------------------------------
3443inline
3444const SizeT
3446{
3447 switch (this->type)
3448 {
3449 case Void: return 0;
3450 case Byte: return sizeof(uint8_t);
3451 case Short: return sizeof(uint16_t);
3452 case UShort: return sizeof(uint16_t);
3453 case Int: return sizeof(uint32_t);
3454 case UInt: return sizeof(uint32_t);
3455 case Int64: return sizeof(uint64_t);
3456 case UInt64: return sizeof(uint64_t);
3457 case Float: return sizeof(float);
3458 case Double: return sizeof(double);
3459 case Bool: return sizeof(bool);
3460 case Vec2: return sizeof(float) * 2;
3461 case Vec4: return sizeof(float) * 4;
3462 case Quaternion: return sizeof(float) * 4;
3463 case String: return sizeof(Util::String);
3464 case Mat4: return sizeof(Math::mat4);
3465 case Transform44: return sizeof(Math::transform44);
3466 case Blob: return sizeof(Util::Blob);
3467 case Guid: return sizeof(Util::Guid);
3468 case Object: return sizeof(Core::RefCounted*);
3469 case VoidPtr: return sizeof(void*);
3470 case IntArray: return sizeof(Util::Array<int>);
3471 case FloatArray: return sizeof(Util::Array<float>);
3472 case BoolArray: return sizeof(Util::Array<bool>);
3473 case Vec2Array: return sizeof(Util::Array<Math::vec2>);
3474 case Vec4Array: return sizeof(Util::Array<Math::vec4>);
3475 case Mat4Array: return sizeof(Util::Array<Math::mat4>);
3476 case StringArray: return sizeof(Util::Array<Util::String>);
3477 case GuidArray: return sizeof(Util::Array<Util::Guid>);
3478 case BlobArray: return sizeof(Util::Array<Util::Blob>);
3479 default:
3480 n_error("Variant::Size(): invalid type enum '%d'!", this->type);
3481 return 0;
3482 }
3483}
3484
3485//------------------------------------------------------------------------------
3488inline
3489const void*
3491{
3492 switch (this->type)
3493 {
3494 case Void:
3495 return nullptr;
3496 case Byte:
3497 case Short:
3498 case UShort:
3499 case Int:
3500 case UInt:
3501 case Int64:
3502 case UInt64:
3503 case Float:
3504 case Double:
3505 case Bool:
3506 case Vec2:
3507 case Vec4:
3508 case Quaternion:
3509 case Object: // object and void ptr will be returned as pointers, not "as content"
3510 case VoidPtr:
3511 return &this->i8;
3512 case String:
3513 case Mat4:
3514 case Transform44:
3515 case Blob:
3516 case Guid:
3517 case IntArray:
3518 case FloatArray:
3519 case BoolArray:
3520 case Vec2Array:
3521 case Vec4Array:
3522 case Mat4Array:
3523 case StringArray:
3524 case GuidArray:
3525 case BlobArray:
3526 return this->voidPtr;
3527 default:
3528 n_error("Variant::AsVoidPtr(): invalid type enum '%d'!", this->type);
3529 return nullptr;
3530 }
3531}
3532
3533//------------------------------------------------------------------------------
3537inline Variant
3539{
3540 Variant val;
3541 if (string.IsValidInt()) val.SetInt(string.AsInt());
3542 else if (string.IsValidFloat()) val.SetFloat(string.AsFloat());
3543 else if (string.IsValidVec2()) val.SetVec2(string.AsVec2());
3544 else if (string.IsValidVec4()) val.SetVec4(string.AsVec4());
3545 else if (string.IsValidBool()) val.SetBool(string.AsBool());
3546 else if (string.IsValidMat4()) val.SetMat4(string.AsMat4());
3547 else val.SetString(string); // raw string
3548 return val;
3549}
3550
3551//------------------------------------------------------------------------------
3554inline Util::String
3556{
3557 switch (t)
3558 {
3559 case Void: return "void";
3560 case Byte: return "byte";
3561 case Short: return "short";
3562 case UShort: return "ushort";
3563 case Int: return "int";
3564 case UInt: return "uint";
3565 case Int64: return "int64";
3566 case UInt64: return "uint64_t";
3567 case Float: return "float";
3568 case Double: return "double";
3569 case Bool: return "bool";
3570 case Vec2: return "vec2";
3571 case Vec4: return "vec4";
3572 case Quaternion: return "quaternion";
3573 case String: return "string";
3574 case Mat4: return "mat4";
3575 case Transform44: return "transform44";
3576 case Blob: return "blob";
3577 case Guid: return "guid";
3578 case Object: return "object";
3579 case VoidPtr: return "voidptr";
3580 case IntArray: return "intarray";
3581 case FloatArray: return "floatarray";
3582 case BoolArray: return "boolarray";
3583 case Vec2Array: return "vec2array";
3584 case Vec4Array: return "vec4array";
3585 case Mat4Array: return "mat4array";
3586 case StringArray: return "stringarray";
3587 case GuidArray: return "guidarray";
3588 case BlobArray: return "blobarray";
3589 default:
3590 n_error("Variant::TypeToString(): invalid type enum '%d'!", t);
3591 return 0;
3592 }
3593}
3594
3595//------------------------------------------------------------------------------
3598inline Variant::Type
3600{
3601 if ("void" == str) return Void;
3602 else if ("byte" == str) return Byte;
3603 else if ("short" == str) return Short;
3604 else if ("ushort" == str) return UShort;
3605 else if ("int" == str) return Int;
3606 else if ("uint" == str) return UInt;
3607 else if ("int64" == str) return Int64;
3608 else if ("uint64_t" == str) return UInt64;
3609 else if ("float" == str) return Float;
3610 else if ("double" == str) return Double;
3611 else if ("bool" == str) return Bool;
3612 else if ("vec2" == str) return Vec2;
3613 else if ("vec4" == str) return Vec4;
3614 else if ("color" == str) return Vec4; // NOT A BUG!
3615 else if ("quaternion" == str) return Quaternion;
3616 else if ("string" == str) return String;
3617 else if ("mat4" == str) return Mat4;
3618 else if ("transform44" == str) return Transform44;
3619 else if ("blob" == str) return Blob;
3620 else if ("guid" == str) return Guid;
3621 else if ("object" == str) return Object;
3622 else if ("voidptr" == str) return VoidPtr;
3623 else if ("intarray" == str) return IntArray;
3624 else if ("floatarray" == str) return FloatArray;
3625 else if ("boolarray" == str) return BoolArray;
3626 else if ("vec2array" == str) return Vec2Array;
3627 else if ("vec4array" == str) return Vec4Array;
3628 else if ("mat4array" == str) return Mat4Array;
3629 else if ("stringarray" == str) return StringArray;
3630 else if ("guidarray" == str) return GuidArray;
3631 else if ("blobarray" == str) return BlobArray;
3632 else
3633 {
3634 n_error("Variant::StringToType(): invalid type string '%s'!", str.AsCharPtr());
3635 return Void;
3636 }
3637}
3638
3639
3640} // namespace Util
3641//------------------------------------------------------------------------------
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:1334
const SizeT Size() const
get number of elements in array
Definition array.h:880
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
An "any type" variable.
Definition variant.h:32
void SetDouble(double val)
set double content
Definition variant.h:2567
Util::Array< Math::mat4 > * mat4Array
Definition variant.h:497
const Util::Array< Util::String > & GetStringArray() const
get string array content
Definition variant.h:2955
void SetBlob(const Util::Blob &val)
set blob
Definition variant.h:2756
int64_t GetInt64() const
get integer content
Definition variant.h:2518
Core::RefCounted * object
Definition variant.h:490
const Math::mat4 & GetMat4() const
get mat4 content
Definition variant.h:2708
Math::quat GetQuat() const
get quaternion content
Definition variant.h:2689
Type
variant types
Definition variant.h:36
@ Short
Definition variant.h:39
@ BlobArray
Definition variant.h:67
@ UInt64
Definition variant.h:44
@ Int
Definition variant.h:41
@ Vec4Array
Definition variant.h:64
@ Quaternion
Definition variant.h:51
@ Blob
Definition variant.h:55
@ Vec3Array
Definition variant.h:63
@ Transform44
Definition variant.h:54
@ Float
Definition variant.h:45
@ Bool
Definition variant.h:47
@ FloatArray
Definition variant.h:60
@ Vec2
Definition variant.h:48
@ GuidArray
Definition variant.h:68
@ String
Definition variant.h:52
@ Object
Definition variant.h:57
@ StringArray
Definition variant.h:65
@ FileTime
Definition variant.h:69
@ Void
Definition variant.h:37
@ NumTypes
Definition variant.h:70
@ UInt
Definition variant.h:42
@ IntArray
Definition variant.h:59
@ Mat4Array
Definition variant.h:66
@ Vec3
Definition variant.h:49
@ Guid
Definition variant.h:56
@ Double
Definition variant.h:46
@ Mat4
Definition variant.h:53
@ VoidPtr
Definition variant.h:58
@ Vec2Array
Definition variant.h:62
@ Int64
Definition variant.h:43
@ Byte
Definition variant.h:38
@ Vec4
Definition variant.h:50
@ UShort
Definition variant.h:40
@ BoolArray
Definition variant.h:61
const Util::Array< Math::mat4 > & GetMat4Array() const
get mat4 array content
Definition variant.h:2936
Math::vec4 GetVec4() const
get vec4 content
Definition variant.h:2670
int GetInt() const
get integer content
Definition variant.h:2488
double d
Definition variant.h:482
const Util::String & GetString() const
get string content
Definition variant.h:2614
bool operator>=(const Variant &rhs) const
greater equal operator
Definition variant.h:1888
void * voidPtr
Definition variant.h:489
bool b
Definition variant.h:481
void SetFloat(float val)
set float content
Definition variant.h:2548
Util::Guid * guid
Definition variant.h:487
uint GetUInt() const
get unsigned integer content
Definition variant.h:2498
void SetBool(bool val)
set bool content
Definition variant.h:2586
Math::transform44 * t
Definition variant.h:485
bool GetBool() const
get bool content
Definition variant.h:2595
void Clear()
clear content, resets type to void
Definition variant.h:624
static Variant FromString(const Util::String &string)
create from string
Definition variant.h:3538
Util::Blob * blob
Definition variant.h:488
void SetShort(short val)
set short content
Definition variant.h:2432
IO::FileTime GetFileTime() const
get filetime content
Definition variant.h:3002
bool operator!=(const Variant &rhs) const
inequality operator
Definition variant.h:2016
void SetBoolArray(const Util::Array< bool > &val)
set bool array content
Definition variant.h:2851
void operator=(const Variant &rhs)
assignment operator
Definition variant.h:1211
const Util::Array< Math::vec3 > & GetVec3Array() const
get vec4 array content
Definition variant.h:2898
void SetByte(byte val)
set byte content
Definition variant.h:2413
void SetFileTime(const IO::FileTime &val)
set filetime content
Definition variant.h:2993
Util::Array< bool > * boolArray
Definition variant.h:493
ushort ui16
Definition variant.h:476
void SetBlobArray(const Util::Array< Util::Blob > &val)
set blob array content
Definition variant.h:2984
void SetVec3Array(const Util::Array< Math::vec3 > &val)
set vec4 array content
Definition variant.h:2889
Variant()
default constructor
Definition variant.h:508
Util::Array< Util::Guid > * guidArray
Definition variant.h:499
Type GetType() const
get type
Definition variant.h:1202
void SetGuid(const Util::Guid &val)
set guid content
Definition variant.h:2737
void SetString(const Util::String &val)
set string content
Definition variant.h:2605
Util::Array< Util::Blob > * blobArray
Definition variant.h:500
const Util::Array< float > & GetFloatArray() const
get float array content
Definition variant.h:2841
void SetFloatArray(const Util::Array< float > &val)
set float array content
Definition variant.h:2832
void SetType(Type t)
set type of attribute
Definition variant.h:1133
void SetInt64(int64_t val)
set integer content
Definition variant.h:2508
TYPE Get() const
Templated get method.
Definition variant.h:3024
void SetMat4Array(const Util::Array< Math::mat4 > &val)
set mat4 array content
Definition variant.h:2927
void SetVec4Array(const Util::Array< Math::vec4 > &val)
set vec4 array content
Definition variant.h:2908
const Util::Array< Util::Blob > & GetBlobArray() const
get blob array content
Definition variant.h:3013
bool operator==(const Variant &rhs) const
equality operator
Definition variant.h:1691
const Util::Guid & GetGuid() const
get guid content
Definition variant.h:2746
void SetVec2(const Math::vec2 &val)
set vec2 content
Definition variant.h:2624
float GetFloat() const
get float content
Definition variant.h:2557
void SetUInt64(uint64_t val)
set unsigned integer content
Definition variant.h:2528
void SetVoidPtr(void *ptr)
set opaque void pointer
Definition variant.h:2794
uint64_t GetUInt64() const
get unsigned integer content
Definition variant.h:2538
void SetVec2Array(const Util::Array< Math::vec2 > &val)
set vec2 array content
Definition variant.h:2870
void SetStringArray(const Util::Array< Util::String > &val)
set string array content
Definition variant.h:2946
const Util::Array< Util::Guid > & GetGuidArray() const
get guid array content
Definition variant.h:2974
Math::vec3 GetVec3() const
get vec4 content
Definition variant.h:2652
Util::Array< Math::vec4 > * vec4Array
Definition variant.h:496
const void * AsVoidPtr() const
get pointer to data
Definition variant.h:3490
static Type StringToType(const Util::String &str)
convert string to type
Definition variant.h:3599
void Delete()
delete current content
Definition variant.h:519
void SetIntArray(const Util::Array< int > &val)
set int array content
Definition variant.h:2813
Type type
Definition variant.h:471
const Math::transform44 & GetTransform44() const
get transform44 content
Definition variant.h:2727
Core::RefCounted * GetObject() const
get object pointer
Definition variant.h:2784
void SetQuat(const Math::quat &val)
set quaternion content
Definition variant.h:2680
Math::mat4 * m
Definition variant.h:484
bool operator<(const Variant &rhs) const
less operator
Definition variant.h:1823
const Util::Blob & GetBlob() const
get blob
Definition variant.h:2765
static Util::String TypeToString(Type t)
convert type to string
Definition variant.h:3555
short i16
Definition variant.h:475
Util::Array< float > * floatArray
Definition variant.h:492
int i
Definition variant.h:477
void SetVec3(const Math::vec3 &val)
set vec4 content
Definition variant.h:2643
int64_t i64
Definition variant.h:479
double GetDouble() const
get double content
Definition variant.h:2576
float f[4]
Definition variant.h:483
short GetShort() const
get short content
Definition variant.h:2450
Util::String * string
Definition variant.h:486
byte i8
Definition variant.h:474
const Util::Array< Math::vec4 > & GetVec4Array() const
get vec4 array content
Definition variant.h:2917
bool SetParseString(const Util::String &string)
set value from string, if type doesn't match, returns false
Definition variant.h:3364
bool operator<=(const Variant &rhs) const
less equal operator
Definition variant.h:1952
bool operator>(const Variant &rhs) const
greater operator
Definition variant.h:1759
void * GetVoidPtr() const
get void pointer
Definition variant.h:2803
uint64_t u64
Definition variant.h:480
const SizeT Size() const
get size of data
Definition variant.h:3445
void SetInt(int val)
set integer content
Definition variant.h:2470
const Util::Array< Math::vec2 > & GetVec2Array() const
get vec2 array content
Definition variant.h:2879
Util::Array< int > * intArray
Definition variant.h:491
void SetObject(Core::RefCounted *ptr)
set object pointer
Definition variant.h:2775
~Variant()
destructor
Definition variant.h:1124
void Copy(const Variant &rhs)
copy current content
Definition variant.h:633
Util::Array< Math::vec2 > * vec2Array
Definition variant.h:494
void SetUInt(uint val)
set unsigned integer content
Definition variant.h:2479
void SetTransform44(const Math::transform44 &val)
set transform44 content
Definition variant.h:2718
Util::Array< Math::vec3 > * float3Array
Definition variant.h:495
void SetMat4(const Math::mat4 &val)
set mat4 content
Definition variant.h:2699
ushort GetUShort() const
get short content
Definition variant.h:2460
Math::vec2 GetVec2() const
get vec2 content
Definition variant.h:2633
Util::Array< Util::String > * stringArray
Definition variant.h:498
const Util::Array< int > & GetIntArray() const
get int array content
Definition variant.h:2822
void SetGuidArray(const Util::Array< Util::Guid > &val)
set guid array content
Definition variant.h:2965
Util::String ToString() const
convert value to string
Definition variant.h:3324
uint u
Definition variant.h:478
void SetUShort(ushort val)
set ushort content
Definition variant.h:2441
void SetVec4(const Math::vec4 &val)
set vec4 content
Definition variant.h:2661
const Util::Array< bool > & GetBoolArray() const
get bool array content
Definition variant.h:2860
byte GetByte() const
get byte content
Definition variant.h:2422
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 quad tree designed to return regions of free 2D space.
Definition String.cs:6
A 4x4 single point precision float matrix.
Definition mat4.h:49
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:184
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:88
scalar y
Definition vec2.h:89
A 3D vector.
Definition vec3.h:37
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition vec3.h:198
A 4D vector.
Definition vec4.h:24
float y
Definition vec4.h:95
float z
Definition vec4.h:95
float w
Definition vec4.h:95
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition vec4.h:203
float x
Definition vec4.h:95
Nebula's universal string class.
Definition String.cs:8
static String FromFloat(float f)
construct a string from a float
Definition string.h:1000
static String FromShort(short i)
construct a string from a short
Definition string.h:901
static String FromVec3(const Math::vec3 &v)
construct a string from vec3
Definition string.h:1045
static String FromVec4(const Math::vec4 &v)
construct a string from vec4
Definition string.h:1056
static String FromVec2(const Math::vec2 &v)
construct a string from vec2
Definition string.h:1034
static String FromUInt(uint i)
construct a string from a uint
Definition string.h:934
static String FromBlob(const Util::Blob &b)
create from blob
Definition string.cc:1220
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:558
void AppendBool(bool val)
append bool value
Definition string.h:1200
static String FromQuat(const Math::quat &q)
construct a string from quat
Definition string.h:1100
static String FromInt(int i)
construct a string from an int
Definition string.h:923
static String FromUShort(ushort i)
construct a string from a ushort
Definition string.h:912
static String FromDouble(double f)
construct a string from a double
Definition string.h:1011
static String FromByte(byte i)
construct a string from a byte
Definition string.h:879
void Append(const String &str)
append string
Definition string.h:633
static String FromBool(bool b)
construct a string from a bool
Definition string.h:1022
static String FromTransform44(const Math::transform44 &m)
construct a string from transform44
Definition string.h:1122
void AppendFloat(float val)
append float value
Definition string.h:1191
static String FromMat4(const Math::mat4 &m)
construct a string from mat4
Definition string.h:1111
void AppendInt(int val)
append int value
Definition string.h:1164
int SizeT
Definition types.h:42
unsigned int uint
Definition types.h:33
unsigned short ushort
Definition types.h:34
int IndexT
Definition types.h:41