JSONValue.pkg 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. $#include "JSONValue.h"
  2. enum JSONValueType
  3. {
  4. JSON_ANY = 0,
  5. JSON_OBJECT,
  6. JSON_ARRAY
  7. };
  8. class JSONValue
  9. {
  10. bool IsNull() const;
  11. bool NotNull() const;
  12. operator bool () const;
  13. JSONValue CreateChild(const String name, JSONValueType valueType = JSON_OBJECT);
  14. JSONValue GetChild(const String name, JSONValueType valueType = JSON_ANY) const;
  15. void SetInt(const String name, int value);
  16. void SetBool(const String name, bool value);
  17. void SetFloat(const String name, float value);
  18. void SetVector2(const String name, const Vector2& value);
  19. void SetVector3(const String name, const Vector3& value);
  20. void SetVector4(const String name, const Vector4& value);
  21. void SetVectorVariant(const String name, const Variant& value);
  22. void SetQuaternion(const String name, const Quaternion& value);
  23. void SetColor(const String name, const Color& value);
  24. void SetString(const String name, const String value);
  25. // void SetBuffer(const String name, const void* data, unsigned size);
  26. // void SetBuffer(const String name, const PODVector<unsigned char>& value);
  27. void SetResourceRef(const String name, const ResourceRef& value);
  28. void SetResourceRefList(const String name, const ResourceRefList& value);
  29. void SetIntRect(const String name, const IntRect& value);
  30. void SetIntVector2(const String name, const IntVector2& value);
  31. void SetMatrix3(const String name, const Matrix3& value);
  32. void SetMatrix3x4(const String name, const Matrix3x4& value);
  33. void SetMatrix4(const String name, const Matrix4& value);
  34. void SetVariant(const String name, const Variant& value);
  35. void SetVariantValue(const String name, const Variant& value);
  36. bool IsObject() const;
  37. int GetInt(const String name) const;
  38. bool GetBool(const String name) const;
  39. float GetFloat(const String name) const;
  40. Vector2 GetVector2(const String name) const;
  41. Vector3 GetVector3(const String name) const;
  42. Vector4 GetVector4(const String name) const;
  43. Variant GetVectorVariant(const String name) const;
  44. Quaternion GetQuaternion(const String name) const;
  45. Color GetColor(const String name) const;
  46. String GetString(const String name) const;
  47. const char* GetCString(const String name) const;
  48. // PODVector<unsigned char> GetBuffer(const String name) const;
  49. // bool GetBuffer(const String name, void* dest, unsigned size) const;
  50. ResourceRef GetResourceRef(const String name) const;
  51. ResourceRefList GetResourceRefList(const String name) const;
  52. IntRect GetIntRect(const String name) const;
  53. IntVector2 GetIntVector2(const String name) const;
  54. Matrix3 GetMatrix3(const String name) const;
  55. Matrix3x4 GetMatrix3x4(const String name) const;
  56. Matrix4 GetMatrix4(const String name) const;
  57. Variant GetVariant(const String name) const;
  58. Variant GetVariantValue(const String name, VariantType type) const;
  59. JSONValue CreateChild(JSONValueType valueType = JSON_OBJECT);
  60. JSONValue GetChild(unsigned index, JSONValueType valueType = JSON_ANY) const;
  61. void AddInt(int value);
  62. void AddBool(bool value);
  63. void AddFloat(float value);
  64. void AddVector2(const Vector2& value);
  65. void AddVector3(const Vector3& value);
  66. void AddVector4(const Vector4& value);
  67. void AddVectorVariant(const Variant& value);
  68. void AddQuaternion(const Quaternion& value);
  69. void AddColor(const Color& value);
  70. void AddString(const String value);
  71. // void AddBuffer(const PODVector<unsigned char>& value);
  72. // void AddBuffer(const void* data, unsigned size);
  73. void AddResourceRef(const ResourceRef& value);
  74. void AddResourceRefList(const ResourceRefList& value);
  75. void AddIntRect(const IntRect& value);
  76. void AddIntVector2(const IntVector2& value);
  77. void AddMatrix3(const Matrix3& value);
  78. void AddMatrix3x4(const Matrix3x4& value);
  79. void AddMatrix4(const Matrix4& value);
  80. void AddVariant(const Variant& value);
  81. void AddVariantValue(const Variant& value);
  82. bool IsArray() const;
  83. unsigned GetSize() const;
  84. int GetInt(unsigned index) const;
  85. bool GetBool(unsigned index) const;
  86. float GetFloat(unsigned index) const;
  87. Vector2 GetVector2(unsigned index) const;
  88. Vector3 GetVector3(unsigned index) const;
  89. Vector4 GetVector4(unsigned index) const;
  90. Variant GetVectorVariant(unsigned index) const;
  91. Quaternion GetQuaternion(unsigned index) const;
  92. Color GetColor(unsigned index) const;
  93. String GetString(unsigned index) const;
  94. const char* GetCString(unsigned index) const;
  95. // PODVector<unsigned char> GetBuffer(unsigned index) const;
  96. // bool GetBuffer(unsigned index, void* dest, unsigned size) const;
  97. ResourceRef GetResourceRef(unsigned index) const;
  98. ResourceRefList GetResourceRefList(unsigned index) const;
  99. IntRect GetIntRect(unsigned index) const;
  100. IntVector2 GetIntVector2(unsigned index) const;
  101. Matrix3 GetMatrix3(unsigned index) const;
  102. Matrix3x4 GetMatrix3x4(unsigned index) const;
  103. Matrix4 GetMatrix4(unsigned index) const;
  104. Variant GetVariant(unsigned index) const;
  105. Variant GetVariantValue(unsigned index, VariantType type) const;
  106. static const JSONValue EMPTY;
  107. tolua_readonly tolua_property__is_set bool null;
  108. tolua_readonly tolua_property__is_set bool object;
  109. tolua_readonly tolua_property__is_set bool array;
  110. };