183 Datum(int32_t value);
184#if PLATFORM_3DS || (defined(POLYPHASE_PLATFORM_ADDON) && !defined(POLYPHASE_ADDON_INT32_IS_INT))
195 Datum(uint32_t value);
198 Datum(
const char* value);
199 Datum(
const std::string& value);
200 Datum(glm::vec2 value);
201 Datum(glm::vec3 value);
202 Datum(glm::vec4 value);
205 Datum(uint8_t value);
209 Datum(int16_t value);
218 for (uint32_t i = 0; i < arr.size(); ++i)
223 mForceScriptArray =
true;
231 for (uint32_t i = 0; i < arr.size(); ++i)
233 PushBack(arr[i].
Get());
236 mForceScriptArray =
true;
244 for (uint32_t i = 0; i < arr.size(); ++i)
246 PushBack(arr[i].
Get());
249 mForceScriptArray =
true;
253 operator int32_t()
const {
return GetInteger(); }
254 operator uint32_t()
const {
return (uint32_t)GetInteger(); }
256 operator bool()
const {
return GetBool(); }
257 operator const char*()
const {
return GetString().c_str(); }
258 operator std::string()
const {
return GetString(); }
259 operator glm::vec2()
const {
return (mType ==
DatumType::Color) ? glm::vec2(GetColor()) : GetVector2D(); }
260 operator glm::vec3()
const {
return (mType ==
DatumType::Color) ? glm::vec3(GetColor()) : GetVector(); }
261 operator glm::vec4()
const {
return GetColor(); }
262 operator Asset*()
const {
return GetAsset(); }
264 operator uint8_t()
const {
return (mType ==
DatumType::Integer) ? uint8_t(GetInteger()) : GetByte(); }
266 operator int16_t()
const {
return (mType ==
DatumType::Integer) ? int16_t(GetInteger()) : GetShort(); }
272 uint32_t GetCount()
const;
273 void SetCount(uint32_t count);
275 uint32_t GetDataTypeSize()
const;
276 uint32_t GetDataTypeSerializationSize(
bool net)
const;
278 bool IsExternal()
const;
279 bool IsValid()
const;
281 virtual void ReadStream(
Stream& stream, uint32_t version,
bool net,
bool external);
282 virtual void WriteStream(
Stream& stream,
bool net)
const;
283 virtual uint32_t GetSerializationSize(
bool net)
const;
285 void SetInteger(int32_t value, uint32_t index = 0);
286 void SetFloat(
float value, uint32_t index = 0);
287 void SetBool(
bool value, uint32_t index = 0);
288 void SetString(
const std::string& value, uint32_t index = 0);
289 void SetVector2D(
const glm::vec2& value, uint32_t index = 0);
290 void SetVector(
const glm::vec3& value, uint32_t index = 0);
291 void SetColor(
const glm::vec4& value, uint32_t index = 0);
292 void SetAsset(
const Asset* value, uint32_t index = 0);
293 void SetByte(uint8_t value, uint32_t index = 0);
294 void SetTableDatum(
const TableDatum& value, uint32_t index = 0);
295 void SetNode(
const WeakPtr<Node>& value, uint32_t index = 0);
296 void SetShort(int16_t value, uint32_t index = 0);
297 void SetFunction(
const ScriptFunc& value, uint32_t index = 0);
300 void SetValue(
const void* value, uint32_t index = 0, uint32_t count = 1);
301 void SetValueRaw(
const void* value, uint32_t index = 0);
303 void SetExternal(int32_t* data, uint32_t count = 1);
304 void SetExternal(
float* data, uint32_t count = 1);
305 void SetExternal(
bool* data, uint32_t count = 1);
306 void SetExternal(std::string* data, uint32_t count = 1);
307 void SetExternal(glm::vec2* data, uint32_t count = 1);
308 void SetExternal(glm::vec3* data, uint32_t count = 1);
309 void SetExternal(glm::vec4* data, uint32_t count = 1);
310 void SetExternal(
AssetRef* data, uint32_t count = 1);
311 void SetExternal(uint8_t* data, uint32_t count = 1);
312 void SetExternal(
TableDatum* data, uint32_t count = 1);
314 void SetExternal(int16_t* data, uint32_t count = 1);
315 void SetExternal(
ScriptFunc* data, uint32_t count = 1);
318 int32_t GetInteger(uint32_t index = 0)
const;
319 float GetFloat(uint32_t index = 0)
const;
320 bool GetBool(uint32_t index = 0)
const;
321 const std::string& GetString(uint32_t index = 0)
const;
322 const glm::vec2& GetVector2D(uint32_t index = 0)
const;
323 const glm::vec3& GetVector(uint32_t index = 0)
const;
324 const glm::vec4& GetColor(uint32_t index = 0)
const;
325 Asset* GetAsset(uint32_t index = 0)
const;
326 uint8_t GetByte(uint32_t index = 0)
const;
327 TableDatum& GetTableDatum(uint32_t index = 0);
328 const TableDatum& GetTableDatum(uint32_t index = 0)
const;
331 int16_t GetShort(uint32_t index = 0)
const;
332 const ScriptFunc& GetFunction(uint32_t index = 0)
const;
335 int32_t& GetIntegerRef(uint32_t index = 0);
336 float& GetFloatRef(uint32_t index = 0);
337 bool& GetBoolRef(uint32_t index = 0);
338 std::string& GetStringRef(uint32_t index = 0);
339 glm::vec2& GetVector2DRef(uint32_t index = 0);
340 glm::vec3& GetVectorRef(uint32_t index = 0);
341 glm::vec4& GetColorRef(uint32_t index = 0);
342 AssetRef& GetAssetRef(uint32_t index = 0);
343 uint8_t& GetByteRef(uint32_t index = 0);
345 int16_t& GetShortRef(uint32_t index = 0);
346 ScriptFunc& GetFunctionRef(uint32_t index = 0);
349 void PushBack(int32_t value);
350 void PushBack(
float value);
351 void PushBack(
bool value);
352 void PushBack(
const std::string& value);
353 void PushBack(
const char* value);
354 void PushBack(
const glm::vec2& value);
355 void PushBack(
const glm::vec3& value);
356 void PushBack(
const glm::vec4& value);
357 void PushBack(
Asset* value);
358 void PushBack(
const AssetRef& value);
359 void PushBack(uint8_t value);
363 void PushBack(
Node* node);
364 void PushBack(int16_t value);
368 void Erase(uint32_t index);
378 int32_t GetIntegerField(
const char* key);
379 float GetFloatField(
const char* key);
390 int32_t GetIntegerField(int32_t key);
391 float GetFloatField(int32_t key);
411 void SetTableField(
const char* key,
const TableDatum& value);
423 void SetTableField(int32_t key,
const TableDatum& value);
426 bool HasField(
const char* key);
427 bool HasField(int32_t key);
432 Datum& operator=(int32_t src);
433 Datum& operator=(
float src);
434 Datum& operator=(
bool src);
435 Datum& operator=(
const std::string& src);
436 Datum& operator=(
const char* src);
437 Datum& operator=(
const glm::vec2 src);
438 Datum& operator=(
const glm::vec3& src);
439 Datum& operator=(
const glm::vec4& src);
441 Datum& operator=(uint8_t src);
444 Datum& operator=(int16_t src);
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 bool operator!=(
const Datum& other)
const;
469 bool operator!=(
const int32_t& other)
const;
470 bool operator!=(
const float& other)
const;
471 bool operator!=(
const bool& other)
const;
472 bool operator!=(
const std::string& other)
const;
473 bool operator!=(
const char* other)
const;
474 bool operator!=(
const glm::vec2& other)
const;
475 bool operator!=(
const glm::vec3& other)
const;
476 bool operator!=(
const glm::vec4& other)
const;
477 bool operator!=(
const Asset*& other)
const;
478 bool operator!=(
const uint32_t& other)
const;
479 bool operator!=(
const uint8_t& other)
const;
480 bool operator!=(
const Node*& other)
const;
483 bool operator!=(
const int16_t& other)
const;
484 bool operator!=(
const ScriptFunc& other)
const;
486 virtual bool IsProperty()
const;
487 virtual bool IsTableDatum()
const;
488 virtual void DeepCopy(
const Datum& src,
bool forceInternalStorage);
490 void* GetValue(uint32_t index);
497 void Reserve(uint32_t capacity);
499 void PreSet(uint32_t index,
DatumType type);
501 void PostSetExternal(
DatumType type, uint32_t count);
503 void PreGet(uint32_t index,
DatumType type)
const;
506 void ConstructData(
DatumData& dataUnion, uint32_t index);
507 void DestructData(
DatumData& dataUnion, uint32_t index);
510 virtual void Reset();
522 uint8_t mCapacity = 0;