178 Datum(int32_t value);
182 Datum(uint32_t value);
185 Datum(
const char* value);
186 Datum(
const std::string& value);
187 Datum(glm::vec2 value);
188 Datum(glm::vec3 value);
189 Datum(glm::vec4 value);
192 Datum(uint8_t value);
196 Datum(int16_t value);
204 for (uint32_t i = 0; i < arr.size(); ++i)
209 mForceScriptArray =
true;
217 for (uint32_t i = 0; i < arr.size(); ++i)
219 PushBack(arr[i].
Get());
222 mForceScriptArray =
true;
230 for (uint32_t i = 0; i < arr.size(); ++i)
232 PushBack(arr[i].
Get());
235 mForceScriptArray =
true;
239 operator int32_t()
const {
return GetInteger(); }
240 operator uint32_t()
const {
return (uint32_t)GetInteger(); }
242 operator bool()
const {
return GetBool(); }
243 operator const char*()
const {
return GetString().c_str(); }
244 operator std::string()
const {
return GetString(); }
245 operator glm::vec2()
const {
return (mType ==
DatumType::Color) ? glm::vec2(GetColor()) : GetVector2D(); }
246 operator glm::vec3()
const {
return (mType ==
DatumType::Color) ? glm::vec3(GetColor()) : GetVector(); }
247 operator glm::vec4()
const {
return GetColor(); }
248 operator Asset*()
const {
return GetAsset(); }
250 operator uint8_t()
const {
return (mType ==
DatumType::Integer) ? uint8_t(GetInteger()) : GetByte(); }
252 operator int16_t()
const {
return (mType ==
DatumType::Integer) ? int16_t(GetInteger()) : GetShort(); }
258 uint32_t GetCount()
const;
259 void SetCount(uint32_t count);
261 uint32_t GetDataTypeSize()
const;
262 uint32_t GetDataTypeSerializationSize(
bool net)
const;
264 bool IsExternal()
const;
265 bool IsValid()
const;
267 virtual void ReadStream(
Stream& stream, uint32_t version,
bool net,
bool external);
268 virtual void WriteStream(
Stream& stream,
bool net)
const;
269 virtual uint32_t GetSerializationSize(
bool net)
const;
271 void SetInteger(int32_t value, uint32_t index = 0);
272 void SetFloat(
float value, uint32_t index = 0);
273 void SetBool(
bool value, uint32_t index = 0);
274 void SetString(
const std::string& value, uint32_t index = 0);
275 void SetVector2D(
const glm::vec2& value, uint32_t index = 0);
276 void SetVector(
const glm::vec3& value, uint32_t index = 0);
277 void SetColor(
const glm::vec4& value, uint32_t index = 0);
278 void SetAsset(
const Asset* value, uint32_t index = 0);
279 void SetByte(uint8_t value, uint32_t index = 0);
280 void SetTableDatum(
const TableDatum& value, uint32_t index = 0);
281 void SetNode(
const WeakPtr<Node>& value, uint32_t index = 0);
282 void SetShort(int16_t value, uint32_t index = 0);
283 void SetFunction(
const ScriptFunc& value, uint32_t index = 0);
285 void SetValue(
const void* value, uint32_t index = 0, uint32_t count = 1);
286 void SetValueRaw(
const void* value, uint32_t index = 0);
288 void SetExternal(int32_t* data, uint32_t count = 1);
289 void SetExternal(
float* data, uint32_t count = 1);
290 void SetExternal(
bool* data, uint32_t count = 1);
291 void SetExternal(std::string* data, uint32_t count = 1);
292 void SetExternal(glm::vec2* data, uint32_t count = 1);
293 void SetExternal(glm::vec3* data, uint32_t count = 1);
294 void SetExternal(glm::vec4* data, uint32_t count = 1);
295 void SetExternal(
AssetRef* data, uint32_t count = 1);
296 void SetExternal(uint8_t* data, uint32_t count = 1);
297 void SetExternal(
TableDatum* data, uint32_t count = 1);
299 void SetExternal(int16_t* data, uint32_t count = 1);
300 void SetExternal(
ScriptFunc* data, uint32_t count = 1);
302 int32_t GetInteger(uint32_t index = 0)
const;
303 float GetFloat(uint32_t index = 0)
const;
304 bool GetBool(uint32_t index = 0)
const;
305 const std::string& GetString(uint32_t index = 0)
const;
306 const glm::vec2& GetVector2D(uint32_t index = 0)
const;
307 const glm::vec3& GetVector(uint32_t index = 0)
const;
308 const glm::vec4& GetColor(uint32_t index = 0)
const;
309 Asset* GetAsset(uint32_t index = 0)
const;
310 uint8_t GetByte(uint32_t index = 0)
const;
311 TableDatum& GetTableDatum(uint32_t index = 0);
312 const TableDatum& GetTableDatum(uint32_t index = 0)
const;
315 int16_t GetShort(uint32_t index = 0)
const;
316 const ScriptFunc& GetFunction(uint32_t index = 0)
const;
318 int32_t& GetIntegerRef(uint32_t index = 0);
319 float& GetFloatRef(uint32_t index = 0);
320 bool& GetBoolRef(uint32_t index = 0);
321 std::string& GetStringRef(uint32_t index = 0);
322 glm::vec2& GetVector2DRef(uint32_t index = 0);
323 glm::vec3& GetVectorRef(uint32_t index = 0);
324 glm::vec4& GetColorRef(uint32_t index = 0);
325 AssetRef& GetAssetRef(uint32_t index = 0);
326 uint8_t& GetByteRef(uint32_t index = 0);
328 int16_t& GetShortRef(uint32_t index = 0);
329 ScriptFunc& GetFunctionRef(uint32_t index = 0);
331 void PushBack(int32_t value);
332 void PushBack(
float value);
333 void PushBack(
bool value);
334 void PushBack(
const std::string& value);
335 void PushBack(
const char* value);
336 void PushBack(
const glm::vec2& value);
337 void PushBack(
const glm::vec3& value);
338 void PushBack(
const glm::vec4& value);
339 void PushBack(
Asset* value);
340 void PushBack(
const AssetRef& value);
341 void PushBack(uint8_t value);
345 void PushBack(
Node* node);
346 void PushBack(int16_t value);
349 void Erase(uint32_t index);
359 int32_t GetIntegerField(
const char* key);
360 float GetFloatField(
const char* key);
371 int32_t GetIntegerField(int32_t key);
372 float GetFloatField(int32_t key);
392 void SetTableField(
const char* key,
const TableDatum& value);
404 void SetTableField(int32_t key,
const TableDatum& value);
407 bool HasField(
const char* key);
408 bool HasField(int32_t key);
413 Datum& operator=(int32_t src);
414 Datum& operator=(
float src);
415 Datum& operator=(
bool src);
416 Datum& operator=(
const std::string& src);
417 Datum& operator=(
const char* src);
418 Datum& operator=(
const glm::vec2 src);
419 Datum& operator=(
const glm::vec3& src);
420 Datum& operator=(
const glm::vec4& src);
422 Datum& operator=(uint8_t src);
425 Datum& operator=(int16_t src);
429 bool operator==(
const Datum& other)
const;
431 bool operator==(
const int32_t& other)
const;
432 bool operator==(
const float& other)
const;
433 bool operator==(
const bool& other)
const;
434 bool operator==(
const std::string& other)
const;
435 bool operator==(
const char* other)
const;
436 bool operator==(
const glm::vec2& other)
const;
437 bool operator==(
const glm::vec3& other)
const;
438 bool operator==(
const glm::vec4& other)
const;
439 bool operator==(
const Asset*& other)
const;
440 bool operator==(
const uint32_t& other)
const;
441 bool operator==(
const uint8_t& other)
const;
442 bool operator==(
const Node*& other)
const;
445 bool operator==(
const int16_t& other)
const;
446 bool operator==(
const ScriptFunc& other)
const;
448 bool operator!=(
const Datum& other)
const;
450 bool operator!=(
const int32_t& other)
const;
451 bool operator!=(
const float& other)
const;
452 bool operator!=(
const bool& other)
const;
453 bool operator!=(
const std::string& other)
const;
454 bool operator!=(
const char* other)
const;
455 bool operator!=(
const glm::vec2& other)
const;
456 bool operator!=(
const glm::vec3& other)
const;
457 bool operator!=(
const glm::vec4& other)
const;
458 bool operator!=(
const Asset*& other)
const;
459 bool operator!=(
const uint32_t& other)
const;
460 bool operator!=(
const uint8_t& other)
const;
461 bool operator!=(
const Node*& other)
const;
464 bool operator!=(
const int16_t& other)
const;
465 bool operator!=(
const ScriptFunc& other)
const;
467 virtual bool IsProperty()
const;
468 virtual bool IsTableDatum()
const;
469 virtual void DeepCopy(
const Datum& src,
bool forceInternalStorage);
471 void* GetValue(uint32_t index);
478 void Reserve(uint32_t capacity);
480 void PreSet(uint32_t index,
DatumType type);
482 void PostSetExternal(
DatumType type, uint32_t count);
484 void PreGet(uint32_t index,
DatumType type)
const;
487 void ConstructData(
DatumData& dataUnion, uint32_t index);
488 void DestructData(
DatumData& dataUnion, uint32_t index);
491 virtual void Reset();
503 uint8_t mCapacity = 0;