summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/core/Variant.h
blob: b9efd6452f0601ff5f6a05760190c23002152192 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#ifndef VARIANT_H
#define VARIANT_H

#include <godot/godot_variant.h>

#include "Defs.h"

#include "Basis.h"
#include "Color.h"
#include "Image.h"
#include "InputEvent.h"
#include "NodePath.h"
#include "Plane.h"
#include "PoolArrays.h"
#include "Quat.h"
#include "Rect2.h"
#include "Rect3.h"
#include "RID.h"
#include "String.h"
#include "Transform.h"
#include "Transform2D.h"
#include "Vector2.h"
#include "Vector3.h"

#include <iostream>

namespace godot {

class Dictionary;

class Array;

class Variant {
	godot_variant _godot_variant;
public:
	enum Type {

		NIL,

		// atomic types
		BOOL,
		INT,
		REAL,
		STRING,

		// math types

		VECTOR2,		// 5
		RECT2,
		VECTOR3,
		TRANSFORM2D,
		PLANE,
		QUAT,			// 10
		RECT3, //sorry naming convention fail :( not like it's used often
		BASIS,
		TRANSFORM,

		// misc types
		COLOR,
		IMAGE,			// 15
		NODE_PATH,
		_RID,
		OBJECT,
		INPUT_EVENT,
		DICTIONARY,		// 20
		ARRAY,

		// arrays
		POOL_BYTE_ARRAY,
		POOL_INT_ARRAY,
		POOL_REAL_ARRAY,
		POOL_STRING_ARRAY,	// 25
		POOL_VECTOR2_ARRAY,
		POOL_VECTOR3_ARRAY,
		POOL_COLOR_ARRAY,

		VARIANT_MAX

	};

	Variant();

	Variant(const Variant& v);

	Variant(bool p_bool);

	Variant(signed int p_int);

	Variant(unsigned int p_int);

	Variant(signed short p_short);

	inline Variant(unsigned short p_short) : Variant((unsigned int) p_short) {}

	inline Variant(signed char p_char) : Variant((signed int) p_char) {}

	inline Variant(unsigned char p_char) : Variant((unsigned int) p_char) {}
	Variant(int64_t p_char);

	Variant(uint64_t p_char);

	Variant(float p_float);

	Variant(double p_double);

	Variant(const String& p_string);

	Variant(const char * const p_cstring);

	Variant(const wchar_t * p_wstring);

	Variant(const Vector2& p_vector2);

	Variant(const Rect2& p_rect2);

	Variant(const Vector3& p_vector3);

	Variant(const Plane& p_plane);


	Variant(const Rect3& p_aabb);

	Variant(const Quat& p_quat);

	Variant(const Basis& p_transform);

	Variant(const Transform2D& p_transform);

	Variant(const Transform& p_transform);

	Variant(const Color& p_color);

	Variant(const Image& p_image);

	Variant(const NodePath& p_path);

	Variant(const RID& p_rid);

	Variant(const Object* p_object);

	Variant(const InputEvent& p_input_event);

	Variant(const Dictionary& p_dictionary);

	Variant(const Array& p_array);

	Variant(const PoolByteArray& p_raw_array);

	Variant(const PoolIntArray& p_int_array);

	Variant(const PoolRealArray& p_real_array);

	Variant(const PoolStringArray& p_string_array);

	Variant(const PoolVector2Array& p_vector2_array);

	Variant(const PoolVector3Array& p_vector3_array);

	Variant(const PoolColorArray& p_color_array);


	Variant &operator =(const Variant& v);


	operator bool() const;
	operator signed int() const;
	operator unsigned int() const ;
	operator signed short() const;
	operator unsigned short() const;
	operator signed char() const;
	operator unsigned char() const;
	operator int64_t() const;
	operator uint64_t() const;


	operator wchar_t() const;

	operator float() const;

	operator double() const;
	operator String() const;
	operator Vector2() const;
	operator Rect2() const;
	operator Vector3() const;
	operator Plane() const;
	operator Rect3() const;
	operator Quat() const;
	operator Basis() const;
	operator Transform() const;
	operator Transform2D() const;

	operator Color() const;

	operator Image() const;
	operator NodePath() const;
	operator RID() const;
	operator InputEvent() const;
	operator Object() const;

	operator Dictionary() const;
	operator Array() const;

	operator PoolByteArray() const;
	operator PoolIntArray() const;
	operator PoolRealArray() const;
	operator PoolStringArray() const;
	operator PoolVector2Array() const;
	operator PoolVector3Array() const;
	operator PoolColorArray() const;

	Type get_type() const;


	Variant call(const String& method, const Variant **args, const int arg_count);

	bool has_method(const String& method);

	bool operator ==(const Variant& b) const;

	bool operator !=(const Variant& b) const;

	bool operator <(const Variant& b) const;

	bool operator <=(const Variant& b) const;

	bool operator >(const Variant& b) const;

	bool operator >=(const Variant& b) const;

	bool hash_compare(const Variant& b) const;

	bool booleanize(bool &valid) const;

	~Variant();


};

}

#endif // VARIANT_H