JSONValue.pkg 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. Vector<String> GetChildNames() const;
  38. Vector<String> GetValueNames() const;
  39. int GetInt(const String name) const;
  40. bool GetBool(const String name) const;
  41. float GetFloat(const String name) const;
  42. Vector2 GetVector2(const String name) const;
  43. Vector3 GetVector3(const String name) const;
  44. Vector4 GetVector4(const String name) const;
  45. Variant GetVectorVariant(const String name) const;
  46. Quaternion GetQuaternion(const String name) const;
  47. Color GetColor(const String name) const;
  48. String GetString(const String name) const;
  49. const char* GetCString(const String name) const;
  50. // PODVector<unsigned char> GetBuffer(const String name) const;
  51. // bool GetBuffer(const String name, void* dest, unsigned size) const;
  52. ResourceRef GetResourceRef(const String name) const;
  53. ResourceRefList GetResourceRefList(const String name) const;
  54. IntRect GetIntRect(const String name) const;
  55. IntVector2 GetIntVector2(const String name) const;
  56. Matrix3 GetMatrix3(const String name) const;
  57. Matrix3x4 GetMatrix3x4(const String name) const;
  58. Matrix4 GetMatrix4(const String name) const;
  59. Variant GetVariant(const String name) const;
  60. Variant GetVariantValue(const String name, VariantType type) const;
  61. JSONValue CreateChild(JSONValueType valueType = JSON_OBJECT);
  62. JSONValue GetChild(unsigned index, JSONValueType valueType = JSON_ANY) const;
  63. void AddInt(int value);
  64. void AddBool(bool value);
  65. void AddFloat(float value);
  66. void AddVector2(const Vector2& value);
  67. void AddVector3(const Vector3& value);
  68. void AddVector4(const Vector4& value);
  69. void AddVectorVariant(const Variant& value);
  70. void AddQuaternion(const Quaternion& value);
  71. void AddColor(const Color& value);
  72. void AddString(const String value);
  73. // void AddBuffer(const PODVector<unsigned char>& value);
  74. // void AddBuffer(const void* data, unsigned size);
  75. void AddResourceRef(const ResourceRef& value);
  76. void AddResourceRefList(const ResourceRefList& value);
  77. void AddIntRect(const IntRect& value);
  78. void AddIntVector2(const IntVector2& value);
  79. void AddMatrix3(const Matrix3& value);
  80. void AddMatrix3x4(const Matrix3x4& value);
  81. void AddMatrix4(const Matrix4& value);
  82. void AddVariant(const Variant& value);
  83. void AddVariantValue(const Variant& value);
  84. bool IsArray() const;
  85. unsigned GetSize() const;
  86. int GetInt(unsigned index) const;
  87. bool GetBool(unsigned index) const;
  88. float GetFloat(unsigned index) const;
  89. Vector2 GetVector2(unsigned index) const;
  90. Vector3 GetVector3(unsigned index) const;
  91. Vector4 GetVector4(unsigned index) const;
  92. Variant GetVectorVariant(unsigned index) const;
  93. Quaternion GetQuaternion(unsigned index) const;
  94. Color GetColor(unsigned index) const;
  95. String GetString(unsigned index) const;
  96. const char* GetCString(unsigned index) const;
  97. // PODVector<unsigned char> GetBuffer(unsigned index) const;
  98. // bool GetBuffer(unsigned index, void* dest, unsigned size) const;
  99. ResourceRef GetResourceRef(unsigned index) const;
  100. ResourceRefList GetResourceRefList(unsigned index) const;
  101. IntRect GetIntRect(unsigned index) const;
  102. IntVector2 GetIntVector2(unsigned index) const;
  103. Matrix3 GetMatrix3(unsigned index) const;
  104. Matrix3x4 GetMatrix3x4(unsigned index) const;
  105. Matrix4 GetMatrix4(unsigned index) const;
  106. Variant GetVariant(unsigned index) const;
  107. Variant GetVariantValue(unsigned index, VariantType type) const;
  108. static const JSONValue EMPTY;
  109. tolua_readonly tolua_property__is_set bool null;
  110. tolua_readonly tolua_property__is_set bool object;
  111. tolua_readonly tolua_property__is_set bool array;
  112. };