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
27//------------------------------------------------------------------------------
28namespace Util
29{
31{
32public:
70
72 Variant();
74 Variant(byte rhs);
76 Variant(short rhs);
78 Variant(ushort rhs);
80 Variant(int rhs);
82 Variant(uint rhs);
84 Variant(int64_t rhs);
86 Variant(uint64_t rhs);
88 Variant(float rhs);
90 Variant(double rhs);
92 Variant(bool rhs);
94 Variant(const Math::vec2& v);
96 Variant(const Math::vec3& v);
98 Variant(const Math::vec4& v);
100 Variant(const Math::quat& q);
102 Variant(const Math::mat4& m);
106 Variant(const Util::String& rhs);
108 Variant(const Util::Blob& blob);
110 Variant(const Util::Guid& guid);
112 Variant(const char* chrPtr);
116 Variant(void* ptr);
118 Variant(std::nullptr_t);
120 Variant(const Util::Array<int>& rhs);
122 Variant(const Util::Array<float>& rhs);
124 Variant(const Util::Array<bool>& rhs);
140 Variant(const Variant& rhs);
141
143 ~Variant();
145 void SetType(Type t);
147 Type GetType() const;
149 void Clear();
150
152 void operator=(const Variant& rhs);
154 void operator=(byte val);
156 void operator=(short val);
158 void operator=(ushort val);
160 void operator=(int val);
162 void operator=(uint val);
164 void operator=(int64_t val);
166 void operator=(uint64_t val);
168 void operator=(float val);
170 void operator=(double val);
172 void operator=(bool val);
174 void operator=(const Math::vec2& val);
176 void operator=(const Math::vec3& val);
178 void operator=(const Math::vec4& val);
180 void operator=(const Math::quat& val);
182 void operator=(const Math::mat4& val);
184 void operator=(const Math::transform44& val);
186 void operator=(const Util::String& s);
188 void operator=(const Util::Blob& val);
190 void operator=(const Util::Guid& val);
192 void operator=(const char* chrPtr);
194 void operator=(Core::RefCounted* ptr);
196 void operator=(void* ptr);
198 void operator=(const Util::Array<int>& rhs);
200 void operator=(const Util::Array<float>& rhs);
202 void operator=(const Util::Array<bool>& rhs);
204 void operator=(const Util::Array<Math::vec2>& rhs);
206 void operator=(const Util::Array<Math::vec3>& rhs);
208 void operator=(const Util::Array<Math::vec4>& rhs);
210 void operator=(const Util::Array<Math::mat4>& rhs);
212 void operator=(const Util::Array<Util::String>& rhs);
214 void operator=(const Util::Array<Util::Blob>& rhs);
216 void operator=(const Util::Array<Util::Guid>& rhs);
217
219 bool operator==(const Variant& rhs) const;
221 bool operator==(byte rhs) const;
223 bool operator==(short rhs) const;
225 bool operator==(ushort rhs) const;
227 bool operator==(int rhs) const;
229 bool operator==(uint rhs) const;
231 bool operator==(int64_t rhs) const;
233 bool operator==(uint64_t rhs) const;
235 bool operator==(float rhs) const;
237 bool operator==(double rhs) const;
239 bool operator==(bool rhs) const;
241 bool operator==(const Math::vec2& rhs) const;
243 bool operator==(const Math::vec4& rhs) const;
245 bool operator==(const Math::quat& rhs) const;
247 bool operator==(const Util::String& rhs) const;
249 bool operator==(const Util::Guid& rhs) const;
251 bool operator==(const char* chrPtr) const;
253 bool operator==(Core::RefCounted* ptr) const;
255 bool operator==(void* ptr) const;
256
258 bool operator!=(const Variant& rhs) const;
260 bool operator!=(byte rhs) const;
262 bool operator!=(short rhs) const;
264 bool operator!=(ushort rhs) const;
266 bool operator!=(int rhs) const;
268 bool operator!=(uint rhs) const;
270 bool operator!=(int64_t rhs) const;
272 bool operator!=(uint64_t rhs) const;
274 bool operator!=(float rhs) const;
276 bool operator!=(double rhs) const;
278 bool operator!=(bool rhs) const;
280 bool operator!=(const Math::vec2& rhs) const;
282 bool operator!=(const Math::vec4& rhs) const;
284 bool operator!=(const Math::quat& rhs) const;
286 bool operator!=(const Util::String& rhs) const;
288 bool operator!=(const Util::Guid& rhs) const;
290 bool operator!=(const char* chrPtr) const;
292 bool operator!=(Core::RefCounted* ptr) const;
294 bool operator!=(void* ptr) const;
295
297 bool operator>(const Variant& rhs) const;
299 bool operator<(const Variant& rhs) const;
301 bool operator>=(const Variant& rhs) const;
303 bool operator<=(const Variant& rhs) const;
304
306 void SetByte(byte val);
308 byte GetByte() const;
310 void SetShort(short val);
312 short GetShort() const;
314 void SetUShort(ushort val);
316 ushort GetUShort() const;
318 void SetInt(int val);
320 int GetInt() const;
322 void SetUInt(uint val);
324 uint GetUInt() const;
326 void SetInt64(int64_t val);
328 int64_t GetInt64() const;
330 void SetUInt64(uint64_t val);
332 uint64_t GetUInt64() const;
334 void SetFloat(float val);
336 float GetFloat() const;
338 void SetDouble(double val);
340 double GetDouble() const;
342 void SetBool(bool val);
344 bool GetBool() const;
346 void SetString(const Util::String& val);
348 const Util::String& GetString() const;
350 void SetVec2(const Math::vec2& val);
352 Math::vec2 GetVec2() const;
354 void SetVec3(const Math::vec3& val);
356 Math::vec3 GetVec3() const;
358 void SetVec4(const Math::vec4& val);
360 Math::vec4 GetVec4() const;
362 void SetQuat(const Math::quat& val);
364 Math::quat GetQuat() const;
366 void SetMat4(const Math::mat4& val);
368 const Math::mat4& GetMat4() const;
370 void SetTransform44(const Math::transform44& val);
372 const Math::transform44& GetTransform44() const;
374 void SetBlob(const Util::Blob& val);
376 const Util::Blob& GetBlob() const;
378 void SetGuid(const Util::Guid& val);
380 const Util::Guid& GetGuid() const;
382 void SetObject(Core::RefCounted* ptr);
386 void SetVoidPtr(void* ptr);
388 void* GetVoidPtr() const;
390 void SetIntArray(const Util::Array<int>& val);
392 const Util::Array<int>& GetIntArray() const;
394 void SetFloatArray(const Util::Array<float>& val);
396 const Util::Array<float>& GetFloatArray() const;
398 void SetBoolArray(const Util::Array<bool>& val);
400 const Util::Array<bool>& GetBoolArray() const;
402 void SetVec2Array(const Util::Array<Math::vec2>& val);
406 void SetVec3Array(const Util::Array<Math::vec3>& val);
410 void SetVec4Array(const Util::Array<Math::vec4>& val);
414 void SetMat4Array(const Util::Array<Math::mat4>& val);
422 void SetGuidArray(const Util::Array<Util::Guid>& val);
426 void SetBlobArray(const Util::Array<Util::Blob>& val);
429
431 template <typename TYPE>
432 TYPE Get() const;
433
435 Util::String ToString() const;
437 bool SetParseString(const Util::String& string);
438
440 const SizeT Size() const;
442 const void* AsVoidPtr() const;
443
445 static Variant FromString(const Util::String& string);
449 static Type StringToType(const Util::String& str);
450
451private:
453 void Delete();
455 void Copy(const Variant& rhs);
456
458 union
459 {
460 byte i8;
461 short i16;
463 int i;
465 int64_t i64;
466 uint64_t u64;
467 bool b;
468 double d;
469 float f[4];
475 void* voidPtr;
487 };
488};
489
490//------------------------------------------------------------------------------
493inline
495 type(Void),
496 string(0)
497{
498 // empty
499}
500
501//------------------------------------------------------------------------------
504inline void
506{
507 if (String == this->type)
508 {
509 n_assert(this->string);
510 delete this->string;
511 this->string = 0;
512 }
513 else if (Mat4 == this->type)
514 {
515 n_assert(this->m);
516 delete this->m;
517 this->m = 0;
518 }
519 else if (Guid == this->type)
520 {
521 n_assert(this->guid);
522 delete this->guid;
523 this->guid = 0;
524 }
525 else if (Blob == this->type)
526 {
527 n_assert(this->blob);
528 delete this->blob;
529 this->blob = 0;
530 }
531 else if (Object == this->type)
532 {
533 if (this->object)
534 {
535 this->object->Release();
536 this->object = 0;
537 }
538 }
539 else if (VoidPtr == this->type)
540 {
541 this->voidPtr = 0;
542 }
543 else if (IntArray == this->type)
544 {
545 n_assert(this->intArray);
546 delete this->intArray;
547 this->intArray = 0;
548 }
549 else if (FloatArray == this->type)
550 {
551 n_assert(this->floatArray);
552 delete this->floatArray;
553 this->floatArray = 0;
554 }
555 else if (BoolArray == this->type)
556 {
557 n_assert(this->boolArray);
558 delete this->boolArray;
559 this->boolArray = 0;
560 }
561 else if (Vec2Array == this->type)
562 {
563 n_assert(this->vec2Array);
564 delete this->vec2Array;
565 this->vec2Array = 0;
566 }
567 else if (Vec3Array == this->type)
568 {
569 n_assert(this->float3Array);
570 delete this->float3Array;
571 this->float3Array = 0;
572 }
573 else if (Vec4Array == this->type)
574 {
575 n_assert(this->vec4Array);
576 delete this->vec4Array;
577 this->vec4Array = 0;
578 }
579 else if (Mat4Array == this->type)
580 {
581 n_assert(this->mat4Array);
582 delete this->mat4Array;
583 this->mat4Array = 0;
584 }
585 else if (StringArray == this->type)
586 {
587 n_assert(this->stringArray);
588 delete this->stringArray;
589 this->stringArray = 0;
590 }
591 else if (GuidArray == this->type)
592 {
593 n_assert(this->guidArray);
594 delete this->guidArray;
595 this->guidArray = 0;
596 }
597 else if (BlobArray == this->type)
598 {
599 n_assert(this->blobArray);
600 delete this->blobArray;
601 this->blobArray = 0;
602 }
603 this->type = Void;
604}
605
606//------------------------------------------------------------------------------
609inline void
611{
612 this->Delete();
613}
614
615//------------------------------------------------------------------------------
618inline void
620{
621 n_assert(Void == this->type);
622 this->type = rhs.type;
623 switch (rhs.type)
624 {
625 case Void:
626 break;
627 case Byte:
628 this->i8 = rhs.i8;
629 break;
630 case Short:
631 this->i16 = rhs.i16;
632 break;
633 case UShort:
634 this->ui16 = rhs.ui16;
635 break;
636 case Int:
637 this->i = rhs.i;
638 break;
639 case UInt:
640 this->u = rhs.u;
641 break;
642 case Int64:
643 this->i64 = rhs.i64;
644 break;
645 case UInt64:
646 this->u64 = rhs.u64;
647 break;
648 case Float:
649 this->f[0] = rhs.f[0];
650 break;
651 case Double:
652 this->d = rhs.d;
653 break;
654 case Bool:
655 this->b = rhs.b;
656 break;
657 case Vec2:
658 this->f[0] = rhs.f[0];
659 this->f[1] = rhs.f[1];
660 break;
661 case Vec3:
662 this->f[0] = rhs.f[0];
663 this->f[1] = rhs.f[1];
664 this->f[2] = rhs.f[2];
665 break;
666 case Vec4:
667 this->f[0] = rhs.f[0];
668 this->f[1] = rhs.f[1];
669 this->f[2] = rhs.f[2];
670 this->f[3] = rhs.f[3];
671 break;
672 case Quaternion:
673 this->f[0] = rhs.f[0];
674 this->f[1] = rhs.f[1];
675 this->f[2] = rhs.f[2];
676 this->f[3] = rhs.f[3];
677 break;
678 case String:
679 this->string = new Util::String(*rhs.string);
680 break;
681 case Mat4:
682 this->m = new Math::mat4(*rhs.m);
683 break;
684 case Transform44:
685 this->t = new Math::transform44(*rhs.t);
686 break;
687 case Blob:
688 this->blob = new Util::Blob(*rhs.blob);
689 break;
690 case Guid:
691 this->guid = new Util::Guid(*rhs.guid);
692 break;
693 case Object:
694 this->object = rhs.object;
695 if (this->object)
696 {
697 this->object->AddRef();
698 }
699 break;
700 case VoidPtr:
701 this->voidPtr = rhs.voidPtr;
702 break;
703 case IntArray:
704 this->intArray = new Util::Array<int>(*rhs.intArray);
705 break;
706 case FloatArray:
707 this->floatArray = new Util::Array<float>(*rhs.floatArray);
708 break;
709 case BoolArray:
710 this->boolArray = new Util::Array<bool>(*rhs.boolArray);
711 break;
712 case Vec2Array:
714 break;
715 case Vec3Array:
717 break;
718 case Vec4Array:
720 break;
721 case Mat4Array:
723 break;
724 case StringArray:
726 break;
727 case GuidArray:
729 break;
730 case BlobArray:
732 break;
733 default:
734 n_error("Variant::Copy(): invalid type!");
735 break;
736 }
737}
738
739//------------------------------------------------------------------------------
742inline
744 type(Void)
745{
746 this->Copy(rhs);
747}
748
749//------------------------------------------------------------------------------
752inline
754 type(Byte),
755 i8(rhs)
756{
757 // empty
758}
759
760//------------------------------------------------------------------------------
763inline
765 type(Short),
766 i16(rhs)
767{
768 // empty
769}
770
771//------------------------------------------------------------------------------
774inline
776 type(UShort),
777 ui16(rhs)
778{
779 // empty
780}
781
782//------------------------------------------------------------------------------
785inline
787 type(Int),
788 i(rhs)
789{
790 // empty
791}
792
793//------------------------------------------------------------------------------
796inline
798type(UInt),
799 u(rhs)
800{
801 // empty
802}
803
804//------------------------------------------------------------------------------
807inline
808Variant::Variant(int64_t rhs) :
809 type(Int64),
810 i64(rhs)
811{
812 // empty
813}
814
815//------------------------------------------------------------------------------
818inline
819Variant::Variant(uint64_t rhs) :
820 type(UInt64),
821 u64(rhs)
822{
823 // empty
824}
825//------------------------------------------------------------------------------
828inline
830 type(Float)
831{
832 this->f[0] = rhs;
833}
834
835//------------------------------------------------------------------------------
838inline
839Variant::Variant(double rhs) :
840 type(Double),
841 d(rhs)
842{
843 // empty
844}
845
846//------------------------------------------------------------------------------
849inline
851 type(Bool),
852 b(rhs)
853{
854 // empty
855}
856
857
858//------------------------------------------------------------------------------
861inline
863 type(Vec2)
864{
865 this->f[0] = rhs.x;
866 this->f[1] = rhs.y;
867}
868
869//------------------------------------------------------------------------------
872inline
874 type(Vec3)
875{
876 rhs.storeu(this->f);
877}
878
879//------------------------------------------------------------------------------
882inline
884 type(Vec4)
885{
886 rhs.storeu(this->f);
887}
888
889//------------------------------------------------------------------------------
892inline
894 type(Quaternion)
895{
896 rhs.storeu(this->f);
897}
898
899//------------------------------------------------------------------------------
902inline
904 type(String)
905{
906 this->string = new Util::String(rhs);
907}
908
909//------------------------------------------------------------------------------
912inline
913Variant::Variant(const char* chrPtr) :
914 type(String)
915{
916 this->string = new Util::String(chrPtr);
917}
918
919//------------------------------------------------------------------------------
922inline
924 type(Object)
925{
926 this->object = ptr;
927 if (this->object)
928 {
929 this->object->AddRef();
930 }
931}
932
933//------------------------------------------------------------------------------
936inline
938 type(VoidPtr)
939{
940 this->voidPtr = ptr;
941}
942
943//------------------------------------------------------------------------------
946inline
947Variant::Variant(std::nullptr_t) :
948 type(VoidPtr)
949{
950 this->voidPtr = nullptr;
951}
952
953//------------------------------------------------------------------------------
956inline
958 type(Mat4)
959{
960 this->m = new Math::mat4(rhs);
961}
962
963//------------------------------------------------------------------------------
966inline
968 type(Transform44)
969{
970 this->t = new Math::transform44(rhs);
971}
972
973//------------------------------------------------------------------------------
976inline
978 type(Blob)
979{
980 this->blob = new Util::Blob(rhs);
981}
982
983//------------------------------------------------------------------------------
986inline
988 type(Guid)
989{
990 this->guid = new Util::Guid(rhs);
991}
992
993//------------------------------------------------------------------------------
996inline
998 type(IntArray)
999{
1000 this->intArray = new Util::Array<int>(rhs);
1001}
1002
1003//------------------------------------------------------------------------------
1006inline
1008 type(FloatArray)
1009{
1010 this->floatArray = new Util::Array<float>(rhs);
1011}
1012
1013//------------------------------------------------------------------------------
1016inline
1018 type(BoolArray)
1019{
1020 this->boolArray = new Util::Array<bool>(rhs);
1021}
1022
1023//------------------------------------------------------------------------------
1026inline
1028 type(Vec2Array)
1029{
1030 this->vec2Array = new Util::Array<Math::vec2>(rhs);
1031}
1032
1033//------------------------------------------------------------------------------
1036inline
1038 type(Vec3Array)
1039{
1040 this->float3Array = new Util::Array<Math::vec3>(rhs);
1041}
1042
1043//------------------------------------------------------------------------------
1046inline
1048 type(Vec4Array)
1049{
1050 this->vec4Array = new Util::Array<Math::vec4>(rhs);
1051}
1052
1053//------------------------------------------------------------------------------
1056inline
1058 type(Mat4Array)
1059{
1060 this->mat4Array = new Util::Array<Math::mat4>(rhs);
1061}
1062
1063//------------------------------------------------------------------------------
1066inline
1068 type(StringArray)
1069{
1070 this->stringArray = new Util::Array<Util::String>(rhs);
1071}
1072
1073//------------------------------------------------------------------------------
1076inline
1078 type(GuidArray)
1079{
1080 this->guidArray = new Util::Array<Util::Guid>(rhs);
1081}
1082
1083//------------------------------------------------------------------------------
1086inline
1088 type(BlobArray)
1089{
1090 this->blobArray = new Util::Array<Util::Blob>(rhs);
1091}
1092
1093//------------------------------------------------------------------------------
1096inline
1098{
1099 this->Delete();
1100}
1101
1102//------------------------------------------------------------------------------
1105inline void
1107{
1108 this->Delete();
1109 this->type = t;
1110 switch (t)
1111 {
1112 case String:
1113 this->string = new Util::String;
1114 break;
1115 case Mat4:
1116 this->m = new Math::mat4;
1117 break;
1118 case Transform44:
1119 this->t = new Math::transform44;
1120 break;
1121 case Blob:
1122 this->blob = new Util::Blob;
1123 break;
1124 case Guid:
1125 this->guid = new Util::Guid;
1126 break;
1127 case Object:
1128 this->object = 0;
1129 break;
1130 case VoidPtr:
1131 this->voidPtr = 0;
1132 break;
1133 case IntArray:
1134 this->intArray = new Util::Array<int>;
1135 break;
1136 case FloatArray:
1137 this->floatArray = new Util::Array<float>;
1138 break;
1139 case BoolArray:
1140 this->boolArray = new Util::Array<bool>;
1141 break;
1142 case Vec2Array:
1144 break;
1145 case Vec3Array:
1147 break;
1148 case Vec4Array:
1150 break;
1151 case Mat4Array:
1153 break;
1154 case StringArray:
1156 break;
1157 case GuidArray:
1159 break;
1160 case BlobArray:
1162 break;
1163 default:
1164 break;
1165 }
1166}
1167
1168//------------------------------------------------------------------------------
1171inline Variant::Type
1173{
1174 return this->type;
1175}
1176
1177//------------------------------------------------------------------------------
1180inline void
1182{
1183 this->Delete();
1184 this->Copy(rhs);
1185}
1186
1187//------------------------------------------------------------------------------
1190inline void
1192{
1193 this->Delete();
1194 this->type = Byte;
1195 this->i8 = val;
1196}
1197
1198//------------------------------------------------------------------------------
1201inline void
1203{
1204 this->Delete();
1205 this->type = Short;
1206 this->i16 = val;
1207}
1208
1209//------------------------------------------------------------------------------
1212inline void
1214{
1215 this->Delete();
1216 this->type = UShort;
1217 this->ui16 = val;
1218}
1219
1220//------------------------------------------------------------------------------
1223inline void
1225{
1226 this->Delete();
1227 this->type = Int;
1228 this->i = val;
1229}
1230
1231//------------------------------------------------------------------------------
1234inline void
1236{
1237 this->Delete();
1238 this->type = UInt;
1239 this->u = val;
1240}
1241
1242//------------------------------------------------------------------------------
1245inline void
1247{
1248 this->Delete();
1249 this->type = Int64;
1250 this->i64 = val;
1251}
1252
1253//------------------------------------------------------------------------------
1256inline void
1258{
1259 this->Delete();
1260 this->type = UInt64;
1261 this->u64 = val;
1262}
1263
1264//------------------------------------------------------------------------------
1267inline void
1269{
1270 this->Delete();
1271 this->type = Float;
1272 this->f[0] = val;
1273}
1274
1275//------------------------------------------------------------------------------
1278inline void
1280{
1281 this->Delete();
1282 this->type = Double;
1283 this->d = val;
1284}
1285
1286//------------------------------------------------------------------------------
1289inline void
1291{
1292 this->Delete();
1293 this->type = Bool;
1294 this->b = val;
1295}
1296
1297//------------------------------------------------------------------------------
1300inline void
1302{
1303 this->Delete();
1304 this->type = Vec2;
1305 this->f[0] = val.x;
1306 this->f[1] = val.y;
1307}
1308
1309//------------------------------------------------------------------------------
1312inline void
1314{
1315 this->Delete();
1316 this->type = Vec3;
1317 val.storeu(this->f);
1318}
1319
1320//------------------------------------------------------------------------------
1323inline void
1325{
1326 this->Delete();
1327 this->type = Vec4;
1328 val.storeu(this->f);
1329}
1330
1331//------------------------------------------------------------------------------
1334inline void
1336{
1337 this->Delete();
1338 this->type = Quaternion;
1339 val.storeu(this->f);
1340}
1341
1342//------------------------------------------------------------------------------
1345inline void
1347{
1348 if (String == this->type)
1349 {
1350 *this->string = s;
1351 }
1352 else
1353 {
1354 this->Delete();
1355 this->string = new Util::String(s);
1356 }
1357 this->type = String;
1358}
1359
1360//------------------------------------------------------------------------------
1363inline void
1364Variant::operator=(const char* chrPtr)
1365{
1366 *this = Util::String(chrPtr);
1367}
1368
1369//------------------------------------------------------------------------------
1372inline void
1374{
1375 if (Mat4 == this->type)
1376 {
1377 *this->m = val;
1378 }
1379 else
1380 {
1381 this->Delete();
1382 this->m = new Math::mat4(val);
1383 }
1384 this->type = Mat4;
1385}
1386
1387//------------------------------------------------------------------------------
1390inline void
1392{
1393 if (Transform44 == this->type)
1394 {
1395 *this->t = val;
1396 }
1397 else
1398 {
1399 this->Delete();
1400 this->t = new Math::transform44(val);
1401 }
1402 this->type = Transform44;
1403}
1404//------------------------------------------------------------------------------
1407inline void
1409{
1410 if (Guid == this->type)
1411 {
1412 *this->guid = val;
1413 }
1414 else
1415 {
1416 this->Delete();
1417 this->guid = new Util::Guid(val);
1418 }
1419 this->type = Guid;
1420}
1421
1422//------------------------------------------------------------------------------
1425inline void
1427{
1428 if (Blob == this->type)
1429 {
1430 *this->blob = val;
1431 }
1432 else
1433 {
1434 this->Delete();
1435 this->blob = new Util::Blob(val);
1436 }
1437 this->type = Blob;
1438}
1439
1440//------------------------------------------------------------------------------
1443inline void
1445{
1446 this->Delete();
1447 this->type = Object;
1448 this->object = ptr;
1449 if (this->object)
1450 {
1451 this->object->AddRef();
1452 }
1453}
1454
1455//------------------------------------------------------------------------------
1458inline void
1460{
1461 this->Delete();
1462 this->type = VoidPtr;
1463 this->voidPtr = ptr;
1464}
1465
1466//------------------------------------------------------------------------------
1469inline void
1471{
1472 if (IntArray == this->type)
1473 {
1474 *this->intArray = val;
1475 }
1476 else
1477 {
1478 this->Delete();
1479 this->intArray = new Util::Array<int>(val);
1480 }
1481 this->type = IntArray;
1482}
1483
1484//------------------------------------------------------------------------------
1487inline void
1489{
1490 if (FloatArray == this->type)
1491 {
1492 *this->floatArray = val;
1493 }
1494 else
1495 {
1496 this->Delete();
1497 this->floatArray = new Util::Array<float>(val);
1498 }
1499 this->type = FloatArray;
1500}
1501
1502//------------------------------------------------------------------------------
1505inline void
1507{
1508 if (BoolArray == this->type)
1509 {
1510 *this->boolArray = val;
1511 }
1512 else
1513 {
1514 this->Delete();
1515 this->boolArray = new Util::Array<bool>(val);
1516 }
1517 this->type = BoolArray;
1518}
1519
1520
1521//------------------------------------------------------------------------------
1524inline void
1526{
1527 if (Vec2Array == this->type)
1528 {
1529 *this->vec2Array = rhs;
1530 }
1531 else
1532 {
1533 this->Delete();
1534 this->vec2Array = new Util::Array<Math::vec2>(rhs);
1535 }
1536 this->type = Vec2Array;
1537}
1538
1539//------------------------------------------------------------------------------
1542inline void
1544{
1545 if (Vec3Array == this->type)
1546 {
1547 *this->float3Array = val;
1548 }
1549 else
1550 {
1551 this->Delete();
1552 this->float3Array = new Util::Array<Math::vec3>(val);
1553 }
1554 this->type = Vec3Array;
1555}
1556
1557//------------------------------------------------------------------------------
1560inline void
1562{
1563 if (Vec4Array == this->type)
1564 {
1565 *this->vec4Array = val;
1566 }
1567 else
1568 {
1569 this->Delete();
1570 this->vec4Array = new Util::Array<Math::vec4>(val);
1571 }
1572 this->type = Vec4Array;
1573}
1574
1575//------------------------------------------------------------------------------
1578inline void
1580{
1581 if (Mat4Array == this->type)
1582 {
1583 *this->mat4Array = val;
1584 }
1585 else
1586 {
1587 this->Delete();
1588 this->mat4Array = new Util::Array<Math::mat4>(val);
1589 }
1590 this->type = Mat4Array;
1591}
1592
1593//------------------------------------------------------------------------------
1596inline void
1598{
1599 if (StringArray == this->type)
1600 {
1601 *this->stringArray = val;
1602 }
1603 else
1604 {
1605 this->Delete();
1606 this->stringArray = new Util::Array<Util::String>(val);
1607 }
1608 this->type = StringArray;
1609}
1610
1611//------------------------------------------------------------------------------
1614inline void
1616{
1617 if (GuidArray == this->type)
1618 {
1619 *this->guidArray = val;
1620 }
1621 else
1622 {
1623 this->Delete();
1624 this->guidArray = new Util::Array<Util::Guid>(val);
1625 }
1626 this->type = GuidArray;
1627}
1628
1629//------------------------------------------------------------------------------
1632inline void
1634{
1635 if (BlobArray == this->type)
1636 {
1637 *this->blobArray = val;
1638 }
1639 else
1640 {
1641 this->Delete();
1642 this->blobArray = new Util::Array<Util::Blob>(val);
1643 }
1644 this->type = BlobArray;
1645}
1646
1647//------------------------------------------------------------------------------
1650inline bool
1652{
1653 if (rhs.type == this->type)
1654 {
1655 switch (rhs.type)
1656 {
1657 case Void:
1658 return true;
1659 case Byte:
1660 return (this->i8 == rhs.i8);
1661 case Short:
1662 return (this->i16 == rhs.i16);
1663 case UShort:
1664 return (this->ui16 == rhs.ui16);
1665 case Int:
1666 return (this->i == rhs.i);
1667 case UInt:
1668 return (this->u == rhs.u);
1669 case Int64:
1670 return (this->i64 == rhs.i64);
1671 case UInt64:
1672 return (this->u64 == rhs.u64);
1673 case Bool:
1674 return (this->b == rhs.b);
1675 case Float:
1676 return (this->f[0] == rhs.f[0]);
1677 case Double:
1678 return (this->d == rhs.d);
1679 case String:
1680 return ((*this->string) == (*rhs.string));
1681 case Vec2:
1682 return ((this->f[0] == rhs.f[0]) && (this->f[1] == rhs.f[1]));
1683 case Vec4:
1684 return ((this->f[0] == rhs.f[0]) &&
1685 (this->f[1] == rhs.f[1]) &&
1686 (this->f[2] == rhs.f[2]) &&
1687 (this->f[3] == rhs.f[3]));
1688 case Quaternion:
1689 return ((this->f[0] == rhs.f[0]) &&
1690 (this->f[1] == rhs.f[1]) &&
1691 (this->f[2] == rhs.f[2]) &&
1692 (this->f[3] == rhs.f[3]));
1693 case Guid:
1694 return ((*this->guid) == (*rhs.guid));
1695 case Blob:
1696 return ((*this->blob) == (*rhs.blob));
1697 case Object:
1698 return (this->object == rhs.object);
1699 case VoidPtr:
1700 return (this->voidPtr == rhs.voidPtr);
1701 case Mat4:
1702 return ((*this->m) == (*rhs.m));
1703 case Transform44:
1704 return ((*this->t) == (*rhs.t));
1705 default:
1706 n_error("Variant::operator==(): invalid variant type!");
1707 return false;
1708 }
1709 }
1710 return false;
1711}
1712
1713//------------------------------------------------------------------------------
1716inline bool
1718{
1719 if (rhs.type == this->type)
1720 {
1721 switch (rhs.type)
1722 {
1723 case Void:
1724 return true;
1725 case Byte:
1726 return (this->i8 > rhs.i8);
1727 case Short:
1728 return (this->i16 > rhs.i16);
1729 case UShort:
1730 return (this->ui16 > rhs.ui16);
1731 case Int:
1732 return (this->i > rhs.i);
1733 case UInt:
1734 return (this->u > rhs.u);
1735 case Int64:
1736 return (this->i64 > rhs.i64);
1737 case UInt64:
1738 return (this->u64 > rhs.u64);
1739 case Bool:
1740 return (this->b > rhs.b);
1741 case Float:
1742 return (this->f[0] > rhs.f[0]);
1743 case Double:
1744 return (this->d > rhs.d);
1745 case String:
1746 return ((*this->string) > (*rhs.string));
1747 case Vec2:
1748 return ((this->f[0] > rhs.f[0]) && (this->f[1] > rhs.f[1]));
1749 case Vec4:
1750 return ((this->f[0] > rhs.f[0]) &&
1751 (this->f[1] > rhs.f[1]) &&
1752 (this->f[2] > rhs.f[2]) &&
1753 (this->f[3] > rhs.f[3]));
1754 case Quaternion:
1755 return ((this->f[0] > rhs.f[0]) &&
1756 (this->f[1] > rhs.f[1]) &&
1757 (this->f[2] > rhs.f[2]) &&
1758 (this->f[3] > rhs.f[3]));
1759 case Guid:
1760 return ((*this->guid) > (*rhs.guid));
1761 case Blob:
1762 return ((*this->blob) > (*rhs.blob));
1763 case Object:
1764 return (this->object > rhs.object);
1765 case VoidPtr:
1766 return (this->voidPtr > rhs.voidPtr);
1767 default:
1768 n_error("Variant::operator>(): invalid variant type!");
1769 return false;
1770 }
1771 }
1772 return false;
1773}
1774
1775//------------------------------------------------------------------------------
1778inline bool
1779Variant::operator<(const Variant& rhs) const
1780{
1781 if (rhs.type == this->type)
1782 {
1783 switch (rhs.type)
1784 {
1785 case Void:
1786 return true;
1787 case Byte:
1788 return (this->i8 < rhs.i8);
1789 case Short:
1790 return (this->i16 < rhs.i16);
1791 case UShort:
1792 return (this->ui16 < rhs.ui16);
1793 case Int:
1794 return (this->i < rhs.i);
1795 case UInt:
1796 return (this->u < rhs.u);
1797 case Int64:
1798 return (this->i64 < rhs.i64);
1799 case UInt64:
1800 return (this->u64 < rhs.u64);
1801 case Bool:
1802 return (this->b < rhs.b);
1803 case Float:
1804 return (this->f[0] < rhs.f[0]);
1805 case Double:
1806 return (this->d > rhs.d);
1807 case String:
1808 return ((*this->string) < (*rhs.string));
1809 case Vec2:
1810 return ((this->f[0] < rhs.f[0]) && (this->f[1] < rhs.f[1]));
1811 case Vec4:
1812 return ((this->f[0] < rhs.f[0]) &&
1813 (this->f[1] < rhs.f[1]) &&
1814 (this->f[2] < rhs.f[2]) &&
1815 (this->f[3] < rhs.f[3]));
1816 case Quaternion:
1817 return ((this->f[0] < rhs.f[0]) &&
1818 (this->f[1] < rhs.f[1]) &&
1819 (this->f[2] < rhs.f[2]) &&
1820 (this->f[3] < rhs.f[3]));
1821 case Guid:
1822 return ((*this->guid) < (*rhs.guid));
1823 case Blob:
1824 return ((*this->blob) < (*rhs.blob));
1825 case Object:
1826 return (this->object < rhs.object);
1827 case VoidPtr:
1828 return (this->voidPtr < rhs.voidPtr);
1829 default:
1830 n_error("Variant::operator<(): invalid variant type!");
1831 return false;
1832 }
1833 }
1834 return false;
1835}
1836
1837
1838//------------------------------------------------------------------------------
1841inline bool
1843{
1844 if (rhs.type == this->type)
1845 {
1846 switch (rhs.type)
1847 {
1848 case Void:
1849 return true;
1850 case Byte:
1851 return (this->i8 >= rhs.i8);
1852 case Short:
1853 return (this->i16 >= rhs.i16);
1854 case UShort:
1855 return (this->ui16 >= rhs.ui16);
1856 case Int:
1857 return (this->i >= rhs.i);
1858 case UInt:
1859 return (this->u >= rhs.u);
1860 case Int64:
1861 return (this->i64 >= rhs.i64);
1862 case UInt64:
1863 return (this->u64 >= rhs.u64);
1864 case Bool:
1865 return (this->b >= rhs.b);
1866 case Float:
1867 return (this->f[0] >= rhs.f[0]);
1868 case Double:
1869 return (this->d >= rhs.d);
1870 case String:
1871 return ((*this->string) >= (*rhs.string));
1872 case Vec2:
1873 return ((this->f[0] >= rhs.f[0]) && (this->f[1] >= rhs.f[1]));
1874 case Vec4:
1875 return ((this->f[0] >= rhs.f[0]) &&
1876 (this->f[1] >= rhs.f[1]) &&
1877 (this->f[2] >= rhs.f[2]) &&
1878 (this->f[3] >= rhs.f[3]));
1879 case Quaternion:
1880 return ((this->f[0] >= rhs.f[0]) &&
1881 (this->f[1] >= rhs.f[1]) &&
1882 (this->f[2] >= rhs.f[2]) &&
1883 (this->f[3] >= rhs.f[3]));
1884 case Guid:
1885 return ((*this->guid) >= (*rhs.guid));
1886 case Blob:
1887 return ((*this->blob) >= (*rhs.blob));
1888 case Object:
1889 return (this->object >= rhs.object);
1890 case VoidPtr:
1891 return (this->voidPtr >= rhs.voidPtr);
1892 default:
1893 n_error("Variant::operator>(): invalid variant type!");
1894 return false;
1895 }
1896 }
1897 return false;
1898}
1899
1900//------------------------------------------------------------------------------
1903inline bool
1904Variant::operator<=(const Variant& rhs) const
1905{
1906 if (rhs.type == this->type)
1907 {
1908 switch (rhs.type)
1909 {
1910 case Void:
1911 return true;
1912 case Byte:
1913 return (this->i8 <= rhs.i8);
1914 case Short:
1915 return (this->i16 <= rhs.i16);
1916 case UShort:
1917 return (this->ui16 <= rhs.ui16);
1918 case Int:
1919 return (this->i <= rhs.i);
1920 case UInt:
1921 return (this->u <= rhs.u);
1922 case Int64:
1923 return (this->i64 <= rhs.i64);
1924 case UInt64:
1925 return (this->u64 <= rhs.u64);
1926 case Bool:
1927 return (this->b <= rhs.b);
1928 case Float:
1929 return (this->f[0] <= rhs.f[0]);
1930 case Double:
1931 return (this->d >= rhs.d);
1932 case String:
1933 return ((*this->string) <= (*rhs.string));
1934 case Vec2:
1935 return ((this->f[0] <= rhs.f[0]) && (this->f[1] <= rhs.f[1]));
1936 case Vec4:
1937 return ((this->f[0] <= rhs.f[0]) &&
1938 (this->f[1] <= rhs.f[1]) &&
1939 (this->f[2] <= rhs.f[2]) &&
1940 (this->f[3] <= rhs.f[3]));
1941 case Quaternion:
1942 return ((this->f[0] <= rhs.f[0]) &&
1943 (this->f[1] <= rhs.f[1]) &&
1944 (this->f[2] <= rhs.f[2]) &&
1945 (this->f[3] <= rhs.f[3]));
1946 case Guid:
1947 return ((*this->guid) <= (*rhs.guid));
1948 case Blob:
1949 return ((*this->blob) <= (*rhs.blob));
1950 case Object:
1951 return (this->object <= rhs.object);
1952 case VoidPtr:
1953 return (this->voidPtr <= rhs.voidPtr);
1954 default:
1955 n_error("Variant::operator<(): invalid variant type!");
1956 return false;
1957 }
1958 }
1959 return false;
1960}
1961
1962//------------------------------------------------------------------------------
1965inline bool
1967{
1968 return !(*this == rhs);
1969}
1970
1971//------------------------------------------------------------------------------
1974inline bool
1975Variant::operator==(byte rhs) const
1976{
1977 n_assert(Byte == this->type);
1978 return (this->i8 == rhs);
1979}
1980
1981//------------------------------------------------------------------------------
1984inline bool
1985Variant::operator==(short rhs) const
1986{
1987 n_assert(Short == this->type);
1988 return (this->i16 == rhs);
1989}
1990
1991//------------------------------------------------------------------------------
1994inline bool
1996{
1997 n_assert(UShort == this->type);
1998 return (this->ui16 == rhs);
1999}
2000
2001//------------------------------------------------------------------------------
2004inline bool
2006{
2007 n_assert(Int == this->type);
2008 return (this->i == rhs);
2009}
2010
2011//------------------------------------------------------------------------------
2014inline bool
2016{
2017 n_assert(UInt == this->type);
2018 return (this->u == rhs);
2019}
2020
2021//------------------------------------------------------------------------------
2024inline bool
2025Variant::operator==(int64_t rhs) const
2026{
2027 n_assert(Int64 == this->type);
2028 return (this->i64 == rhs);
2029}
2030
2031//------------------------------------------------------------------------------
2034inline bool
2035Variant::operator==(uint64_t rhs) const
2036{
2037 n_assert(UInt64 == this->type);
2038 return (this->u64 == rhs);
2039}
2040
2041//------------------------------------------------------------------------------
2044inline bool
2045Variant::operator==(float rhs) const
2046{
2047 n_assert(Float == this->type);
2048 return (this->f[0] == rhs);
2049}
2050
2051//------------------------------------------------------------------------------
2054inline bool
2055Variant::operator==(double rhs) const
2056{
2057 n_assert(Double == this->type);
2058 return (this->d == rhs);
2059}
2060
2061//------------------------------------------------------------------------------
2064inline bool
2065Variant::operator==(bool rhs) const
2066{
2067 n_assert(Bool == this->type);
2068 return (this->b == rhs);
2069}
2070
2071//------------------------------------------------------------------------------
2074inline bool
2076{
2077 n_assert(String == this->type);
2078 return ((*this->string) == rhs);
2079}
2080
2081//------------------------------------------------------------------------------
2084inline bool
2085Variant::operator==(const char* chrPtr) const
2086{
2087 return *this == Util::String(chrPtr);
2088}
2089
2090
2091//------------------------------------------------------------------------------
2094inline bool
2096{
2097 n_assert(Vec2 == this->type);
2098 return (this->f[0] == rhs.x && this->f[1] == rhs.y);
2099}
2100
2101//------------------------------------------------------------------------------
2104inline bool
2106{
2107 n_assert(Vec4 == this->type);
2108 return ((this->f[0] == rhs.x) &&
2109 (this->f[1] == rhs.y) &&
2110 (this->f[2] == rhs.z) &&
2111 (this->f[3] == rhs.w));
2112}
2113
2114//------------------------------------------------------------------------------
2117inline bool
2119{
2120 n_assert(Quaternion == this->type);
2121 return ((this->f[0] == rhs.x) &&
2122 (this->f[1] == rhs.y) &&
2123 (this->f[2] == rhs.z) &&
2124 (this->f[3] == rhs.w));
2125}
2126
2127//------------------------------------------------------------------------------
2130inline bool
2132{
2133 n_assert(Guid == this->type);
2134 return (*this->guid) == rhs;
2135}
2136
2137//------------------------------------------------------------------------------
2140inline bool
2142{
2143 n_assert(Object == this->type);
2144 return this->object == ptr;
2145}
2146
2147//------------------------------------------------------------------------------
2150inline bool
2151Variant::operator==(void* ptr) const
2152{
2153 n_assert(VoidPtr == this->type);
2154 return this->voidPtr == ptr;
2155}
2156
2157//------------------------------------------------------------------------------
2160inline bool
2161Variant::operator!=(byte rhs) const
2162{
2163 n_assert(Byte == this->type);
2164 return (this->i8 != rhs);
2165}
2166
2167//------------------------------------------------------------------------------
2170inline bool
2171Variant::operator!=(short rhs) const
2172{
2173 n_assert(Short == this->type);
2174 return (this->i16 != rhs);
2175}
2176
2177//------------------------------------------------------------------------------
2180inline bool
2182{
2183 n_assert(UShort == this->type);
2184 return (this->ui16 != rhs);
2185}
2186
2187//------------------------------------------------------------------------------
2190inline bool
2192{
2193 n_assert(Int == this->type);
2194 return (this->i != rhs);
2195}
2196
2197//------------------------------------------------------------------------------
2200inline bool
2202{
2203 n_assert(UInt == this->type);
2204 return (this->u != rhs);
2205}
2206
2207//------------------------------------------------------------------------------
2210inline bool
2211Variant::operator!=(int64_t rhs) const
2212{
2213 n_assert(Int64 == this->type);
2214 return (this->i64 != rhs);
2215}
2216
2217//------------------------------------------------------------------------------
2220inline bool
2221Variant::operator!=(uint64_t rhs) const
2222{
2223 n_assert(UInt64 == this->type);
2224 return (this->u64 != rhs);
2225}
2226
2227//------------------------------------------------------------------------------
2230inline bool
2231Variant::operator!=(float rhs) const
2232{
2233 n_assert(Float == this->type);
2234 return (this->f[0] != rhs);
2235}
2236
2237//------------------------------------------------------------------------------
2240inline bool
2241Variant::operator!=(double rhs) const
2242{
2243 n_assert(Double == this->type);
2244 return (this->d != rhs);
2245}
2246
2247//------------------------------------------------------------------------------
2250inline bool
2251Variant::operator!=(bool rhs) const
2252{
2253 n_assert(Bool == this->type);
2254 return (this->b != rhs);
2255}
2256
2257//------------------------------------------------------------------------------
2260inline bool
2262{
2263 n_assert(String == this->type);
2264 return (*this->string) != rhs;
2265}
2266
2267//------------------------------------------------------------------------------
2270inline bool
2271Variant::operator!=(const char* chrPtr) const
2272{
2273 return *this != Util::String(chrPtr);
2274}
2275
2276
2277//------------------------------------------------------------------------------
2280inline bool
2282{
2283 n_assert(Vec2 == this->type);
2284 return (this->f[0] != rhs.x || this->f[1] != rhs.y);
2285}
2286
2287//------------------------------------------------------------------------------
2290inline bool
2292{
2293 n_assert(Vec4 == this->type);
2294 return ((this->f[0] != rhs.x) ||
2295 (this->f[1] != rhs.y) ||
2296 (this->f[2] != rhs.z) ||
2297 (this->f[3] != rhs.w));
2298}
2299
2300//------------------------------------------------------------------------------
2303inline bool
2305{
2306 n_assert(Quaternion == this->type);
2307 return ((this->f[0] != rhs.x) ||
2308 (this->f[1] != rhs.y) ||
2309 (this->f[2] != rhs.z) ||
2310 (this->f[3] != rhs.w));
2311}
2312
2313//------------------------------------------------------------------------------
2316inline bool
2318{
2319 n_assert(Guid == this->type);
2320 return (*this->guid) != rhs;
2321}
2322
2323//------------------------------------------------------------------------------
2326inline bool
2328{
2329 n_assert(Object == this->type);
2330 return (this->object == ptr);
2331}
2332
2333//------------------------------------------------------------------------------
2336inline bool
2337Variant::operator!=(void* ptr) const
2338{
2339 n_assert(VoidPtr == this->type);
2340 return (this->voidPtr == ptr);
2341}
2342
2343//------------------------------------------------------------------------------
2346inline void
2348{
2349 *this = val;
2350}
2351
2352//------------------------------------------------------------------------------
2355inline byte
2357{
2358 n_assert(Byte == this->type);
2359 return this->i8;
2360}
2361
2362//------------------------------------------------------------------------------
2365inline void
2367{
2368 *this = val;
2369}
2370
2371//------------------------------------------------------------------------------
2374inline void
2376{
2377 *this = val;
2378}
2379
2380//------------------------------------------------------------------------------
2383inline short
2385{
2386 n_assert(Short == this->type);
2387 return this->i16;
2388}
2389
2390//------------------------------------------------------------------------------
2393inline ushort
2395{
2396 n_assert(UShort == this->type);
2397 return this->ui16;
2398}
2399
2400//------------------------------------------------------------------------------
2403inline void
2405{
2406 *this = val;
2407}
2408
2409//------------------------------------------------------------------------------
2412inline void
2414{
2415 *this = val;
2416}
2417
2418//------------------------------------------------------------------------------
2421inline int
2423{
2424 n_assert(Int == this->type);
2425 return this->i;
2426}
2427
2428//------------------------------------------------------------------------------
2431inline uint
2433{
2434 n_assert(UInt == this->type);
2435 return this->u;
2436}
2437
2438//------------------------------------------------------------------------------
2441inline void
2443{
2444 n_assert(Int64 == this->type);
2445 this->i64 = val;
2446}
2447
2448//------------------------------------------------------------------------------
2451inline int64_t
2453{
2454 n_assert(Int64 == this->type);
2455 return this->i64;
2456}
2457
2458//------------------------------------------------------------------------------
2461inline void
2463{
2464 n_assert(UInt64 == this->type);
2465 this->u64 = val;
2466}
2467
2468//------------------------------------------------------------------------------
2471inline uint64_t
2473{
2474 n_assert(UInt64 == this->type);
2475 return this->u64;
2476}
2477
2478//------------------------------------------------------------------------------
2481inline void
2483{
2484 *this = val;
2485}
2486
2487//------------------------------------------------------------------------------
2490inline float
2492{
2493 n_assert(Float == this->type);
2494 return this->f[0];
2495}
2496
2497//------------------------------------------------------------------------------
2500inline void
2502{
2503 *this = val;
2504}
2505
2506//------------------------------------------------------------------------------
2509inline double
2511{
2512 n_assert(Double == this->type);
2513 return this->d;
2514}
2515
2516//------------------------------------------------------------------------------
2519inline void
2521{
2522 *this = val;
2523}
2524
2525//------------------------------------------------------------------------------
2528inline bool
2530{
2531 n_assert(Bool == this->type);
2532 return this->b;
2533}
2534
2535//------------------------------------------------------------------------------
2538inline void
2540{
2541 *this = val;
2542}
2543
2544//------------------------------------------------------------------------------
2547inline const Util::String&
2549{
2550 n_assert(String == this->type);
2551 return *(this->string);
2552}
2553
2554//------------------------------------------------------------------------------
2557inline void
2559{
2560 *this = val;
2561}
2562
2563//------------------------------------------------------------------------------
2566inline Math::vec2
2568{
2569 n_assert(Vec2 == this->type);
2570 return Math::vec2(this->f[0], this->f[1]);
2571}
2572
2573//------------------------------------------------------------------------------
2576inline void
2578{
2579 *this = val;
2580}
2581
2582//------------------------------------------------------------------------------
2585inline Math::vec3
2587{
2588 return Math::vec3();
2589}
2590
2591//------------------------------------------------------------------------------
2594inline void
2596{
2597 *this = val;
2598}
2599
2600//------------------------------------------------------------------------------
2603inline Math::vec4
2605{
2606 n_assert(Vec4 == this->type);
2607 return Math::vec4(this->f[0], this->f[1], this->f[2], this->f[3]);
2608}
2609
2610//------------------------------------------------------------------------------
2613inline void
2615{
2616 *this = val;
2617}
2618
2619//------------------------------------------------------------------------------
2622inline Math::quat
2624{
2625 n_assert(Quaternion == this->type);
2626 return Math::quat(this->f[0], this->f[1], this->f[2], this->f[3]);
2627}
2628
2629//------------------------------------------------------------------------------
2632inline void
2634{
2635 *this = val;
2636}
2637
2638//------------------------------------------------------------------------------
2641inline const Math::mat4&
2643{
2644 n_assert(Mat4 == this->type);
2645 return *(this->m);
2646}
2647
2648//------------------------------------------------------------------------------
2651inline void
2653{
2654 *this = val;
2655}
2656
2657//------------------------------------------------------------------------------
2660inline const Math::transform44&
2662{
2663 n_assert(Transform44 == this->type);
2664 return *(this->t);
2665}
2666
2667//------------------------------------------------------------------------------
2670inline void
2672{
2673 *this = val;
2674}
2675
2676//------------------------------------------------------------------------------
2679inline const Util::Guid&
2681{
2682 n_assert(Guid == this->type);
2683 return *(this->guid);
2684}
2685
2686//------------------------------------------------------------------------------
2689inline void
2691{
2692 *this = val;
2693}
2694
2695//------------------------------------------------------------------------------
2698inline const Util::Blob&
2700{
2701 n_assert(Blob == this->type);
2702 return *(this->blob);
2703}
2704
2705//------------------------------------------------------------------------------
2708inline void
2710{
2711 *this = ptr;
2712}
2713
2714//------------------------------------------------------------------------------
2717inline Core::RefCounted*
2719{
2720 n_assert(Object == this->type);
2721 return this->object;
2722}
2723
2724//------------------------------------------------------------------------------
2727inline void
2729{
2730 *this = ptr;
2731}
2732
2733//------------------------------------------------------------------------------
2736inline void*
2738{
2739 n_assert(VoidPtr == this->type);
2740 return this->voidPtr;
2741}
2742
2743//------------------------------------------------------------------------------
2746inline void
2748{
2749 *this = val;
2750}
2751
2752//------------------------------------------------------------------------------
2755inline const Util::Array<int>&
2757{
2758 n_assert(IntArray == this->type);
2759 return *(this->intArray);
2760}
2761
2762//------------------------------------------------------------------------------
2765inline void
2767{
2768 *this = val;
2769}
2770
2771//------------------------------------------------------------------------------
2774inline const Util::Array<float>&
2776{
2777 n_assert(FloatArray == this->type);
2778 return *(this->floatArray);
2779}
2780
2781//------------------------------------------------------------------------------
2784inline void
2786{
2787 *this = val;
2788}
2789
2790//------------------------------------------------------------------------------
2793inline const Util::Array<bool>&
2795{
2796 n_assert(BoolArray == this->type);
2797 return *(this->boolArray);
2798}
2799
2800//------------------------------------------------------------------------------
2803inline void
2805{
2806 *this = val;
2807}
2808
2809//------------------------------------------------------------------------------
2812inline const Util::Array<Math::vec2>&
2814{
2815 n_assert(Vec2Array == this->type);
2816 return *(this->vec2Array);
2817}
2818
2819//------------------------------------------------------------------------------
2822inline void
2824{
2825 *this = val;
2826}
2827
2828//------------------------------------------------------------------------------
2831inline const Util::Array<Math::vec3>&
2833{
2834 n_assert(Vec3Array == this->type);
2835 return *(this->float3Array);
2836}
2837
2838//------------------------------------------------------------------------------
2841inline void
2843{
2844 *this = val;
2845}
2846
2847//------------------------------------------------------------------------------
2850inline const Util::Array<Math::vec4>&
2852{
2853 n_assert(Vec4Array == this->type);
2854 return *(this->vec4Array);
2855}
2856
2857//------------------------------------------------------------------------------
2860inline void
2862{
2863 *this = val;
2864}
2865
2866//------------------------------------------------------------------------------
2869inline const Util::Array<Math::mat4>&
2871{
2872 n_assert(Mat4Array == this->type);
2873 return *(this->mat4Array);
2874}
2875
2876//------------------------------------------------------------------------------
2879inline void
2881{
2882 *this = val;
2883}
2884
2885//------------------------------------------------------------------------------
2888inline const Util::Array<Util::String>&
2890{
2891 n_assert(StringArray == this->type);
2892 return *(this->stringArray);
2893}
2894
2895//------------------------------------------------------------------------------
2898inline void
2900{
2901 *this = val;
2902}
2903
2904//------------------------------------------------------------------------------
2907inline const Util::Array<Util::Guid>&
2909{
2910 n_assert(GuidArray == this->type);
2911 return *(this->guidArray);
2912}
2913
2914//------------------------------------------------------------------------------
2917inline void
2919{
2920 *this = val;
2921}
2922
2923//------------------------------------------------------------------------------
2926inline const Util::Array<Util::Blob>&
2928{
2929 n_assert(BlobArray == this->type);
2930 return *(this->blobArray);
2931}
2932
2933//------------------------------------------------------------------------------
2936template <typename TYPE>
2937inline TYPE
2939{
2940 static_assert(true, "Get method for TYPE is not implemented!");
2941 TYPE ret;
2942 return ret;
2943}
2944
2945//------------------------------------------------------------------------------
2948template <>
2949inline byte
2951{
2952 return this->GetByte();
2953}
2954
2955//------------------------------------------------------------------------------
2958template <>
2959inline short
2961{
2962 return this->GetShort();
2963}
2964
2965//------------------------------------------------------------------------------
2968template <>
2969inline int
2971{
2972 return this->GetInt();
2973}
2974
2975//------------------------------------------------------------------------------
2978template <>
2979inline uint
2981{
2982 return this->GetUInt();
2983}
2984
2985//------------------------------------------------------------------------------
2988template <>
2989inline int64_t
2991{
2992 return this->GetInt64();
2993}
2994
2995//------------------------------------------------------------------------------
2998template <>
2999inline uint64_t
3001{
3002 return this->GetUInt64();
3003}
3004
3005//------------------------------------------------------------------------------
3008template <>
3009inline bool
3011{
3012 return this->GetBool();
3013}
3014
3015//------------------------------------------------------------------------------
3018template <>
3019inline double
3021{
3022 return this->GetDouble();
3023}
3024
3025//------------------------------------------------------------------------------
3028template <>
3029inline float
3031{
3032 return this->GetFloat();
3033}
3034
3035//------------------------------------------------------------------------------
3038template <>
3039inline Math::vec2
3041{
3042 return this->GetVec2();
3043}
3044
3045//------------------------------------------------------------------------------
3048template <>
3049inline Math::vec3
3051{
3052 return this->GetVec3();
3053}
3054
3055//------------------------------------------------------------------------------
3058template <>
3059inline Math::vec4
3061{
3062 return this->GetVec4();
3063}
3064
3065//------------------------------------------------------------------------------
3068template <>
3069inline Math::quat
3071{
3072 return this->GetQuat();
3073}
3074
3075//------------------------------------------------------------------------------
3078template <>
3079inline Math::mat4
3081{
3082 return this->GetMat4();
3083}
3084
3085//------------------------------------------------------------------------------
3088template <>
3089inline Math::transform44
3091{
3092 return this->GetTransform44();
3093}
3094
3095//------------------------------------------------------------------------------
3098template <>
3099inline Util::String
3101{
3102 return this->GetString();
3103}
3104
3105//------------------------------------------------------------------------------
3108template <>
3109inline Util::Guid
3111{
3112 return this->GetGuid();
3113}
3114
3115//------------------------------------------------------------------------------
3118template <>
3119inline Util::Blob
3121{
3122 return this->GetBlob();
3123}
3124
3125//------------------------------------------------------------------------------
3128template <>
3129inline Util::Array<int>
3131{
3132 return this->GetIntArray();
3133}
3134
3135//------------------------------------------------------------------------------
3138template <>
3139inline Util::Array<float>
3141{
3142 return this->GetFloatArray();
3143}
3144
3145//------------------------------------------------------------------------------
3148template <>
3149inline Util::Array<bool>
3151{
3152 return this->GetBoolArray();
3153}
3154
3155//------------------------------------------------------------------------------
3158template <>
3161{
3162 return this->GetVec2Array();
3163}
3164
3165//------------------------------------------------------------------------------
3168template <>
3171{
3172 return this->GetVec3Array();
3173}
3174
3175//------------------------------------------------------------------------------
3178template <>
3181{
3182 return this->GetVec4Array();
3183}
3184
3185//------------------------------------------------------------------------------
3188template <>
3191{
3192 return this->GetMat4Array();
3193}
3194
3195//------------------------------------------------------------------------------
3198template <>
3201{
3202 return this->GetStringArray();
3203}
3204
3205//------------------------------------------------------------------------------
3208template <>
3211{
3212 return this->GetGuidArray();
3213}
3214
3215//------------------------------------------------------------------------------
3218template <>
3221{
3222 return this->GetBlobArray();
3223}
3224
3225//------------------------------------------------------------------------------
3228inline Util::String
3230{
3231 Util::String retval = "";
3232 switch (this->type)
3233 {
3234 case Void: break;
3235 case Byte: { retval = Util::String::FromByte(this->GetByte()); break; }
3236 case Short: { retval = Util::String::FromShort(this->GetShort()); break; }
3237 case UShort: { retval = Util::String::FromUShort(this->GetUShort()); break; }
3238 case Int: { retval = Util::String::FromInt(this->GetInt()); break; }
3239 case UInt: { retval = Util::String::FromUInt(this->GetUInt()); break; }
3240 case Float: { retval = Util::String::FromFloat(this->GetFloat()); break; }
3241 case Double: { retval = Util::String::FromDouble(this->GetDouble()); break; }
3242 case Bool: { retval = Util::String::FromBool(this->GetBool()); break; }
3243 case Vec2: { retval = Util::String::FromVec2(this->GetVec2()); break; }
3244 case Vec3: { retval = Util::String::FromVec3(this->GetVec3()); break; }
3245 case Vec4: { retval = Util::String::FromVec4(this->GetVec4()); break; }
3246 case Quaternion: { retval = Util::String::FromQuat(this->GetQuat()); break; }
3247 case String: { retval = this->GetString(); break; }
3248 case Mat4: { retval = Util::String::FromMat4(this->GetMat4()); break; }
3249 case Transform44: { retval = Util::String::FromTransform44(this->GetTransform44()); break; }
3250 case Blob: { retval = Util::String::FromBlob(this->GetBlob()); break; }
3251 case Guid: { retval = this->GetGuid().AsString(); break; }
3252 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; }
3253 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; }
3254 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; }
3255 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; }
3256 default:
3257 n_error("Variant::ToString(): invalid type enum '%d'", this->type);
3258
3259 }
3260 return retval;
3261}
3262
3263//------------------------------------------------------------------------------
3268inline bool
3270{
3271 bool retval = false;
3272 switch (this->type)
3273 {
3274 case Int:
3275 case UInt: { if(string.IsValidInt()) { this->SetUInt(string.AsInt()); retval = true; } break; };
3276 case Float: { if(string.IsValidFloat()) { this->SetFloat(string.AsFloat()); retval = true; } break; }
3277 case Bool: { if(string.IsValidBool()) { this->SetBool(string.AsBool()); retval = true; } break; }
3278 case Vec2: { if(string.IsValidVec2()) { this->SetVec2(string.AsVec2()); retval = true; } break; }
3279 case Vec4: { if(string.IsValidVec4()) { this->SetVec4(string.AsVec4()); retval = true; } break; }
3280 case String: { this->SetString(string); retval = true; break; }
3281 case Mat4: { if(string.IsValidMat4()) { this->SetMat4(string.AsMat4()); retval = true; } break; }
3282 case Transform44: { if (string.IsValidTransform44()) { this->SetTransform44(string.AsTransform44()); retval = true; } break; }
3283
3284 case IntArray:
3285 {
3286 Util::Array<Util::String> tokens = string.Tokenize(",");
3287 Util::Array<int> result;
3288 IndexT i;
3289 for (i = 0; i < tokens.Size(); i++)
3290 {
3291 if (tokens[i].IsValidInt())
3292 {
3293 result.Append(tokens[i].AsInt());
3294 }
3295 }
3296 this->SetIntArray(result);
3297 retval = true;
3298 break;
3299 }
3300 case FloatArray:
3301 {
3302 Util::Array<Util::String> tokens = string.Tokenize(",");
3303 Util::Array<float> result;
3304 IndexT i;
3305 for (i = 0; i < tokens.Size(); i++)
3306 {
3307 if (tokens[i].IsValidFloat())
3308 {
3309 result.Append(tokens[i].AsFloat());
3310 }
3311 }
3312 this->SetFloatArray(result);
3313 retval = true;
3314 break;
3315 }
3316 case BoolArray:
3317 {
3318 Util::Array<Util::String> tokens = string.Tokenize(",");
3319 Util::Array<bool> result;
3320 IndexT i;
3321 for (i = 0; i < tokens.Size(); i++)
3322 {
3323 if (tokens[i].IsValidBool())
3324 {
3325 result.Append(tokens[i].AsBool());
3326 }
3327 }
3328 this->SetBoolArray(result);
3329 retval = true;
3330 break;
3331 }
3332 case StringArray:
3333 {
3334 Util::Array<Util::String> tokens = string.Tokenize(",");
3335 this->SetStringArray(tokens);
3336 retval = true;
3337 break;
3338 }
3339 default:
3340 break;
3341 }
3342 return retval;
3343}
3344
3345//------------------------------------------------------------------------------
3348inline
3349const SizeT
3351{
3352 switch (this->type)
3353 {
3354 case Void: return 0;
3355 case Byte: return sizeof(uint8);
3356 case Short: return sizeof(uint16);
3357 case UShort: return sizeof(uint16);
3358 case Int: return sizeof(uint32);
3359 case UInt: return sizeof(uint32);
3360 case Int64: return sizeof(uint64);
3361 case UInt64: return sizeof(uint64);
3362 case Float: return sizeof(float);
3363 case Double: return sizeof(double);
3364 case Bool: return sizeof(bool);
3365 case Vec2: return sizeof(float) * 2;
3366 case Vec4: return sizeof(float) * 4;
3367 case Quaternion: return sizeof(float) * 4;
3368 case String: return sizeof(Util::String);
3369 case Mat4: return sizeof(Math::mat4);
3370 case Transform44: return sizeof(Math::transform44);
3371 case Blob: return sizeof(Util::Blob);
3372 case Guid: return sizeof(Util::Guid);
3373 case Object: return sizeof(Core::RefCounted*);
3374 case VoidPtr: return sizeof(void*);
3375 case IntArray: return sizeof(Util::Array<int>);
3376 case FloatArray: return sizeof(Util::Array<float>);
3377 case BoolArray: return sizeof(Util::Array<bool>);
3378 case Vec2Array: return sizeof(Util::Array<Math::vec2>);
3379 case Vec4Array: return sizeof(Util::Array<Math::vec4>);
3380 case Mat4Array: return sizeof(Util::Array<Math::mat4>);
3381 case StringArray: return sizeof(Util::Array<Util::String>);
3382 case GuidArray: return sizeof(Util::Array<Util::Guid>);
3383 case BlobArray: return sizeof(Util::Array<Util::Blob>);
3384 default:
3385 n_error("Variant::Size(): invalid type enum '%d'!", this->type);
3386 return 0;
3387 }
3388}
3389
3390//------------------------------------------------------------------------------
3393inline
3394const void*
3396{
3397 switch (this->type)
3398 {
3399 case Void:
3400 return nullptr;
3401 case Byte:
3402 case Short:
3403 case UShort:
3404 case Int:
3405 case UInt:
3406 case Int64:
3407 case UInt64:
3408 case Float:
3409 case Double:
3410 case Bool:
3411 case Vec2:
3412 case Vec4:
3413 case Quaternion:
3414 case Object: // object and void ptr will be returned as pointers, not "as content"
3415 case VoidPtr:
3416 return &this->i8;
3417 case String:
3418 case Mat4:
3419 case Transform44:
3420 case Blob:
3421 case Guid:
3422 case IntArray:
3423 case FloatArray:
3424 case BoolArray:
3425 case Vec2Array:
3426 case Vec4Array:
3427 case Mat4Array:
3428 case StringArray:
3429 case GuidArray:
3430 case BlobArray:
3431 return this->voidPtr;
3432 default:
3433 n_error("Variant::AsVoidPtr(): invalid type enum '%d'!", this->type);
3434 return nullptr;
3435 }
3436}
3437
3438//------------------------------------------------------------------------------
3442inline Variant
3444{
3445 Variant val;
3446 if (string.IsValidInt()) val.SetInt(string.AsInt());
3447 else if (string.IsValidFloat()) val.SetFloat(string.AsFloat());
3448 else if (string.IsValidVec2()) val.SetVec2(string.AsVec2());
3449 else if (string.IsValidVec4()) val.SetVec4(string.AsVec4());
3450 else if (string.IsValidBool()) val.SetBool(string.AsBool());
3451 else if (string.IsValidMat4()) val.SetMat4(string.AsMat4());
3452 else val.SetString(string); // raw string
3453 return val;
3454}
3455
3456//------------------------------------------------------------------------------
3459inline Util::String
3461{
3462 switch (t)
3463 {
3464 case Void: return "void";
3465 case Byte: return "byte";
3466 case Short: return "short";
3467 case UShort: return "ushort";
3468 case Int: return "int";
3469 case UInt: return "uint";
3470 case Int64: return "int64";
3471 case UInt64: return "uint64";
3472 case Float: return "float";
3473 case Double: return "double";
3474 case Bool: return "bool";
3475 case Vec2: return "vec2";
3476 case Vec4: return "vec4";
3477 case Quaternion: return "quaternion";
3478 case String: return "string";
3479 case Mat4: return "mat4";
3480 case Transform44: return "transform44";
3481 case Blob: return "blob";
3482 case Guid: return "guid";
3483 case Object: return "object";
3484 case VoidPtr: return "voidptr";
3485 case IntArray: return "intarray";
3486 case FloatArray: return "floatarray";
3487 case BoolArray: return "boolarray";
3488 case Vec2Array: return "vec2array";
3489 case Vec4Array: return "vec4array";
3490 case Mat4Array: return "mat4array";
3491 case StringArray: return "stringarray";
3492 case GuidArray: return "guidarray";
3493 case BlobArray: return "blobarray";
3494 default:
3495 n_error("Variant::TypeToString(): invalid type enum '%d'!", t);
3496 return 0;
3497 }
3498}
3499
3500//------------------------------------------------------------------------------
3503inline Variant::Type
3505{
3506 if ("void" == str) return Void;
3507 else if ("byte" == str) return Byte;
3508 else if ("short" == str) return Short;
3509 else if ("ushort" == str) return UShort;
3510 else if ("int" == str) return Int;
3511 else if ("uint" == str) return UInt;
3512 else if ("int64" == str) return Int64;
3513 else if ("uint64" == str) return UInt64;
3514 else if ("float" == str) return Float;
3515 else if ("double" == str) return Double;
3516 else if ("bool" == str) return Bool;
3517 else if ("vec2" == str) return Vec2;
3518 else if ("vec4" == str) return Vec4;
3519 else if ("color" == str) return Vec4; // NOT A BUG!
3520 else if ("quaternion" == str) return Quaternion;
3521 else if ("string" == str) return String;
3522 else if ("mat4" == str) return Mat4;
3523 else if ("transform44" == str) return Transform44;
3524 else if ("blob" == str) return Blob;
3525 else if ("guid" == str) return Guid;
3526 else if ("object" == str) return Object;
3527 else if ("voidptr" == str) return VoidPtr;
3528 else if ("intarray" == str) return IntArray;
3529 else if ("floatarray" == str) return FloatArray;
3530 else if ("boolarray" == str) return BoolArray;
3531 else if ("vec2array" == str) return Vec2Array;
3532 else if ("vec4array" == str) return Vec4Array;
3533 else if ("mat4array" == str) return Mat4Array;
3534 else if ("stringarray" == str) return StringArray;
3535 else if ("guidarray" == str) return GuidArray;
3536 else if ("blobarray" == str) return BlobArray;
3537 else
3538 {
3539 n_error("Variant::StringToType(): invalid type string '%s'!", str.AsCharPtr());
3540 return Void;
3541 }
3542}
3543
3544
3545} // namespace Util
3546//------------------------------------------------------------------------------
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
Implements a GUID.
An "any type" variable.
Definition variant.h:31
void SetDouble(double val)
set double content
Definition variant.h:2501
Util::Array< Math::mat4 > * mat4Array
Definition variant.h:483
const Util::Array< Util::String > & GetStringArray() const
get string array content
Definition variant.h:2889
void SetBlob(const Util::Blob &val)
set blob
Definition variant.h:2690
int64_t GetInt64() const
get integer content
Definition variant.h:2452
Core::RefCounted * object
Definition variant.h:476
const Math::mat4 & GetMat4() const
get mat4 content
Definition variant.h:2642
Math::quat GetQuat() const
get quaternion content
Definition variant.h:2623
Type
variant types
Definition variant.h:35
@ Short
Definition variant.h:38
@ BlobArray
Definition variant.h:66
@ UInt64
Definition variant.h:43
@ Int
Definition variant.h:40
@ Vec4Array
Definition variant.h:63
@ Quaternion
Definition variant.h:50
@ Blob
Definition variant.h:54
@ Vec3Array
Definition variant.h:62
@ Transform44
Definition variant.h:53
@ Float
Definition variant.h:44
@ Bool
Definition variant.h:46
@ FloatArray
Definition variant.h:59
@ Vec2
Definition variant.h:47
@ GuidArray
Definition variant.h:67
@ String
Definition variant.h:51
@ Object
Definition variant.h:56
@ StringArray
Definition variant.h:64
@ Void
Definition variant.h:36
@ NumTypes
Definition variant.h:68
@ UInt
Definition variant.h:41
@ IntArray
Definition variant.h:58
@ Mat4Array
Definition variant.h:65
@ Vec3
Definition variant.h:48
@ Guid
Definition variant.h:55
@ Double
Definition variant.h:45
@ Mat4
Definition variant.h:52
@ VoidPtr
Definition variant.h:57
@ Vec2Array
Definition variant.h:61
@ Int64
Definition variant.h:42
@ Byte
Definition variant.h:37
@ Vec4
Definition variant.h:49
@ UShort
Definition variant.h:39
@ BoolArray
Definition variant.h:60
const Util::Array< Math::mat4 > & GetMat4Array() const
get mat4 array content
Definition variant.h:2870
Math::vec4 GetVec4() const
get vec4 content
Definition variant.h:2604
int GetInt() const
get integer content
Definition variant.h:2422
double d
Definition variant.h:468
const Util::String & GetString() const
get string content
Definition variant.h:2548
bool operator>=(const Variant &rhs) const
greater equal operator
Definition variant.h:1842
void * voidPtr
Definition variant.h:475
bool b
Definition variant.h:467
void SetFloat(float val)
set float content
Definition variant.h:2482
Util::Guid * guid
Definition variant.h:473
uint GetUInt() const
get unsigned integer content
Definition variant.h:2432
void SetBool(bool val)
set bool content
Definition variant.h:2520
Math::transform44 * t
Definition variant.h:471
bool GetBool() const
get bool content
Definition variant.h:2529
void Clear()
clear content, resets type to void
Definition variant.h:610
static Variant FromString(const Util::String &string)
create from string
Definition variant.h:3443
Util::Blob * blob
Definition variant.h:474
void SetShort(short val)
set short content
Definition variant.h:2366
bool operator!=(const Variant &rhs) const
inequality operator
Definition variant.h:1966
void SetBoolArray(const Util::Array< bool > &val)
set bool array content
Definition variant.h:2785
void operator=(const Variant &rhs)
assignment operator
Definition variant.h:1181
const Util::Array< Math::vec3 > & GetVec3Array() const
get vec4 array content
Definition variant.h:2832
void SetByte(byte val)
set byte content
Definition variant.h:2347
Util::Array< bool > * boolArray
Definition variant.h:479
ushort ui16
Definition variant.h:462
void SetBlobArray(const Util::Array< Util::Blob > &val)
set blob array content
Definition variant.h:2918
void SetVec3Array(const Util::Array< Math::vec3 > &val)
set vec4 array content
Definition variant.h:2823
Variant()
default constructor
Definition variant.h:494
Util::Array< Util::Guid > * guidArray
Definition variant.h:485
Type GetType() const
get type
Definition variant.h:1172
void SetGuid(const Util::Guid &val)
set guid content
Definition variant.h:2671
void SetString(const Util::String &val)
set string content
Definition variant.h:2539
Util::Array< Util::Blob > * blobArray
Definition variant.h:486
const Util::Array< float > & GetFloatArray() const
get float array content
Definition variant.h:2775
void SetFloatArray(const Util::Array< float > &val)
set float array content
Definition variant.h:2766
void SetType(Type t)
set type of attribute
Definition variant.h:1106
void SetInt64(int64_t val)
set integer content
Definition variant.h:2442
TYPE Get() const
Templated get method.
Definition variant.h:2938
void SetMat4Array(const Util::Array< Math::mat4 > &val)
set mat4 array content
Definition variant.h:2861
void SetVec4Array(const Util::Array< Math::vec4 > &val)
set vec4 array content
Definition variant.h:2842
const Util::Array< Util::Blob > & GetBlobArray() const
get blob array content
Definition variant.h:2927
bool operator==(const Variant &rhs) const
equality operator
Definition variant.h:1651
const Util::Guid & GetGuid() const
get guid content
Definition variant.h:2680
void SetVec2(const Math::vec2 &val)
set vec2 content
Definition variant.h:2558
float GetFloat() const
get float content
Definition variant.h:2491
void SetUInt64(uint64_t val)
set unsigned integer content
Definition variant.h:2462
void SetVoidPtr(void *ptr)
set opaque void pointer
uint64_t GetUInt64() const
get unsigned integer content
Definition variant.h:2472
void SetVec2Array(const Util::Array< Math::vec2 > &val)
set vec2 array content
Definition variant.h:2804
void SetStringArray(const Util::Array< Util::String > &val)
set string array content
Definition variant.h:2880
const Util::Array< Util::Guid > & GetGuidArray() const
get guid array content
Definition variant.h:2908
Math::vec3 GetVec3() const
get vec4 content
Definition variant.h:2586
Util::Array< Math::vec4 > * vec4Array
Definition variant.h:482
const void * AsVoidPtr() const
get pointer to data
Definition variant.h:3395
static Type StringToType(const Util::String &str)
convert string to type
Definition variant.h:3504
void Delete()
delete current content
Definition variant.h:505
void SetIntArray(const Util::Array< int > &val)
set int array content
Definition variant.h:2747
Type type
Definition variant.h:457
const Math::transform44 & GetTransform44() const
get transform44 content
Definition variant.h:2661
Core::RefCounted * GetObject() const
get object pointer
Definition variant.h:2718
void SetQuat(const Math::quat &val)
set quaternion content
Definition variant.h:2614
Math::mat4 * m
Definition variant.h:470
bool operator<(const Variant &rhs) const
less operator
Definition variant.h:1779
const Util::Blob & GetBlob() const
get blob
Definition variant.h:2699
static Util::String TypeToString(Type t)
convert type to string
Definition variant.h:3460
short i16
Definition variant.h:461
Util::Array< float > * floatArray
Definition variant.h:478
int i
Definition variant.h:463
void SetVec3(const Math::vec3 &val)
set vec4 content
Definition variant.h:2577
int64_t i64
Definition variant.h:465
double GetDouble() const
get double content
Definition variant.h:2510
float f[4]
Definition variant.h:469
short GetShort() const
get short content
Definition variant.h:2384
Util::String * string
Definition variant.h:472
byte i8
Definition variant.h:460
const Util::Array< Math::vec4 > & GetVec4Array() const
get vec4 array content
Definition variant.h:2851
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:1904
bool operator>(const Variant &rhs) const
greater operator
Definition variant.h:1717
void * GetVoidPtr() const
get void pointer
uint64_t u64
Definition variant.h:466
const SizeT Size() const
get size of data
Definition variant.h:3350
void SetInt(int val)
set integer content
Definition variant.h:2404
const Util::Array< Math::vec2 > & GetVec2Array() const
get vec2 array content
Definition variant.h:2813
Util::Array< int > * intArray
Definition variant.h:477
void SetObject(Core::RefCounted *ptr)
set object pointer
Definition variant.h:2709
~Variant()
destructor
Definition variant.h:1097
void Copy(const Variant &rhs)
copy current content
Definition variant.h:619
Util::Array< Math::vec2 > * vec2Array
Definition variant.h:480
void SetUInt(uint val)
set unsigned integer content
Definition variant.h:2413
void SetTransform44(const Math::transform44 &val)
set transform44 content
Definition variant.h:2652
Util::Array< Math::vec3 > * float3Array
Definition variant.h:481
void SetMat4(const Math::mat4 &val)
set mat4 content
Definition variant.h:2633
ushort GetUShort() const
get short content
Definition variant.h:2394
Math::vec2 GetVec2() const
get vec2 content
Definition variant.h:2567
Util::Array< Util::String > * stringArray
Definition variant.h:484
const Util::Array< int > & GetIntArray() const
get int array content
Definition variant.h:2756
void SetGuidArray(const Util::Array< Util::Guid > &val)
set guid array content
Definition variant.h:2899
Util::String ToString() const
convert value to string
Definition variant.h:3229
uint u
Definition variant.h:464
void SetUShort(ushort val)
set ushort content
Definition variant.h:2375
void SetVec4(const Math::vec4 &val)
set vec4 content
Definition variant.h:2595
const Util::Array< bool > & GetBoolArray() const
get bool array content
Definition variant.h:2794
byte GetByte() const
get byte content
Definition variant.h:2356
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: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: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:40
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition vec3.h:196
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:987
static String FromUInt(uint i)
construct a string from a uint
Definition string.h:898
static String FromBool(bool b)
construct a string from a bool
Definition string.h:964
static String FromByte(byte i)
construct a string from a byte
Definition string.h:843
void AppendFloat(float val)
append float value
Definition string.h:1133
static String FromQuat(const Math::quat &q)
construct a string from quat
Definition string.h:1042
static String FromDouble(double f)
construct a string from a double
Definition string.h:953
void AppendBool(bool val)
append bool value
Definition string.h:1142
static String FromTransform44(const Math::transform44 &m)
construct a string from transform44
Definition string.h:1064
static String FromInt(int i)
construct a string from an int
Definition string.h:887
static String FromFloat(float f)
construct a string from a float
Definition string.h:942
static String FromVec4(const Math::vec4 &v)
construct a string from vec4
Definition string.h:998
void Append(const String &str)
append string
Definition string.h:617
static String FromMat4(const Math::mat4 &m)
construct a string from mat4
Definition string.h:1053
static String FromBlob(const Util::Blob &b)
create from blob
Definition string.cc:1206
static String FromShort(short i)
construct a string from a short
Definition string.h:865
static String FromUShort(ushort i)
construct a string from a ushort
Definition string.h:876
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:542
void AppendInt(int val)
append int value
Definition string.h:1106
static String FromVec2(const Math::vec2 &v)
construct a string from vec2
Definition string.h:976
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