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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 the rest of 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. double 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. ssize_t len; // Signed b/c negative lengths indicate data is a pointer
  78. // Consider adding an "alloc" field here, if json_object_set_string calls
  79. // to expand the length of a string are common operations to perform.
  80. union
  81. {
  82. char idata[1]; // Immediate data. Actually longer
  83. char *pdata; // Only when len < 0
  84. } c_string;
  85. };
  86. struct json_object
  87. {
  88. int newold;
  89. enum json_type o_type;
  90. uint32_t _ref_count;
  91. json_object_private_delete_fn *_delete;
  92. json_object_to_json_string_fn *_to_json_string;
  93. struct printbuf *_pb;
  94. int dummyval; // XAX temp spacer to catch casting errors
  95. int du1mmyval; // XAX spacer
  96. int d2ummyval; // XAX spacer
  97. json_object_delete_fn *_user_delete;
  98. void *_userdata;
  99. };
  100. void _json_c_set_last_err(const char *err_fmt, ...);
  101. extern const char *json_number_chars;
  102. extern const char *json_hex_chars;
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif