Variant.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Core
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2011, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeCore/Base.h"
16 #include "CeeCore/Vec3d.h"
17 #include "CeeCore/Color3f.h"
18 #include "CeeCore/Str.h"
19 
20 #include <vector>
21 
22 namespace cee {
23 
24 
25 //==================================================================================================
26 //
27 //
28 //
29 //==================================================================================================
30 class CEE_CORE_EXPORT Variant
31 {
32 public:
33  enum DataType
34  {
36  INT,
44  ARRAY
45  };
46 
47 public:
48  Variant();
49  Variant(const Variant& other);
50  ~Variant();
51 
52  Variant(int val);
53  Variant(unsigned int val);
54  Variant(double val);
55  Variant(float val);
56  Variant(bool val);
57  Variant(const Vec3d& val);
58  Variant(const Color3f& val);
59  Variant(const Str& val);
60  Variant(const char* val);
61  Variant(const std::vector<Variant>& arr);
62 
63  Variant& operator=(const Variant& rhs);
64  bool operator==(const Variant& rhs) const;
65  bool operator!=(const Variant& rhs) const;
66 
67  DataType type() const;
68  bool isValid() const;
69 
70  int getInt() const;
71  unsigned int getUInt() const;
72  double getDouble() const;
73  float getFloat() const;
74  bool getBool() const;
75  Vec3d getVec3d() const;
76  Color3f getColor3f() const;
77  Str getString() const;
78  std::vector<Variant> getArray() const;
79 
80 private:
81  CEE_PRIVATE_IMPL(Variant);
82 };
83 
84 } // namespace cee
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppComponent.cpp:26
Unsigned integer data type (unsigned int)
Definition: Variant.h:37
Vector data type (cee::Vec3d)
Definition: Variant.h:41
A general unicode based string class.
Definition: Str.h:28
DataType
List of variant data types.
Definition: Variant.h:33
bool operator!=(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are different.
Definition: PtrRef.h:58
bool operator==(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are equal.
Definition: PtrRef.h:57
String data type (cee::Str)
Definition: Variant.h:43
Boolean data type (bool)
Definition: Variant.h:40
Class for storing an RGB color triplet.
Definition: Color3f.h:25
Floating point data type (float)
Definition: Variant.h:39
Double precision data type (double)
Definition: Variant.h:38
The Variant class acts like a union for the most common data types.
Definition: Variant.h:30
Integer data type (int)
Definition: Variant.h:36
Vector class for a 3D double vector.
Definition: Vec3d.h:26
Invalid.
Definition: Variant.h:35
Color data type (cee::Color3f)
Definition: Variant.h:42