You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

json_object_private.h 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * $Id: json_object_private.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
  3. *
  4. * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  5. * Michael Clark <michael@metaparadigm.com>
  6. *
  7. * This library is free software; you can redistribute it and/or modify
  8. * it under the terms of the MIT license. See COPYING for details.
  9. *
  10. */
  11. /**
  12. * @file
  13. * @brief Do not use, json-c internal, may be changed or removed at any time.
  14. */
  15. #ifndef _json_object_private_h_
  16. #define _json_object_private_h_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**< how many bytes are directly stored in json_object for strings? */
  21. #define LEN_DIRECT_STRING_DATA 32
  22. struct json_object;
  23. #include "json_inttypes.h"
  24. #include "json_types.h"
  25. typedef void(json_object_private_delete_fn)(struct json_object *o);
  26. /* json object int type, support extension*/
  27. typedef enum json_object_int_type
  28. {
  29. json_object_int_type_int64,
  30. json_object_int_type_uint64
  31. } json_object_int_type;
  32. struct json_object_base // XAX rename to json_object after conversion
  33. {
  34. int newold; // XAX temporary, remove after code conversion
  35. enum json_type o_type;
  36. uint32_t _ref_count;
  37. json_object_private_delete_fn *_delete;
  38. json_object_to_json_string_fn *_to_json_string;
  39. struct printbuf *_pb;
  40. json_object_delete_fn *_user_delete;
  41. void *_userdata;
  42. char data[1]; // Actually a struct json_object_${o_type}
  43. };
  44. struct json_object_object
  45. {
  46. struct json_object_base base;
  47. struct lh_table *c_object;
  48. };
  49. struct json_object_array
  50. {
  51. struct json_object_base base;
  52. struct array_list *c_array;
  53. };
  54. struct json_object_boolean
  55. {
  56. struct json_object_base base;
  57. json_bool c_boolean;
  58. };
  59. struct json_object_double
  60. {
  61. struct json_object_base base;
  62. json_bool c_double;
  63. };
  64. struct json_object_int
  65. {
  66. struct json_object_base base;
  67. enum json_object_int_type cint_type;
  68. union
  69. {
  70. int64_t c_int64;
  71. uint64_t c_uint64;
  72. } cint;
  73. };
  74. struct json_object_string
  75. {
  76. struct json_object_base base;
  77. size_t len;
  78. char data[1]; // Actually longer
  79. };
  80. struct json_object
  81. {
  82. int newold;
  83. enum json_type o_type;
  84. uint32_t _ref_count;
  85. json_object_private_delete_fn *_delete;
  86. json_object_to_json_string_fn *_to_json_string;
  87. struct printbuf *_pb;
  88. union data
  89. {
  90. double c_double;
  91. struct
  92. {
  93. union
  94. {
  95. int64_t c_int64;
  96. uint64_t c_uint64;
  97. } cint;
  98. enum json_object_int_type cint_type;
  99. } c_int;
  100. struct
  101. {
  102. union
  103. {
  104. /* optimize: if we have small strings, we can store them
  105. * directly. This saves considerable CPU cycles AND memory.
  106. */
  107. char *ptr;
  108. char data[LEN_DIRECT_STRING_DATA];
  109. } str;
  110. int len;
  111. } c_string;
  112. } o;
  113. json_object_delete_fn *_user_delete;
  114. void *_userdata;
  115. };
  116. void _json_c_set_last_err(const char *err_fmt, ...);
  117. extern const char *json_number_chars;
  118. extern const char *json_hex_chars;
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif