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 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. struct json_object;
  21. #include "json_inttypes.h"
  22. #include "json_types.h"
  23. #ifdef HAVE_UNISTD_H
  24. #include <unistd.h>
  25. #endif /* HAVE_UNISTD_H */
  26. #ifdef _MSC_VER
  27. #include <BaseTsd.h>
  28. typedef SSIZE_T ssize_t;
  29. #endif
  30. /* json object int type, support extension*/
  31. typedef enum json_object_int_type
  32. {
  33. json_object_int_type_int64,
  34. json_object_int_type_uint64
  35. } json_object_int_type;
  36. struct json_object
  37. {
  38. enum json_type o_type;
  39. uint32_t _ref_count;
  40. json_object_to_json_string_fn *_to_json_string;
  41. struct printbuf *_pb;
  42. json_object_delete_fn *_user_delete;
  43. void *_userdata;
  44. // Actually longer, always malloc'd as some more-specific type.
  45. // The rest of a struct json_object_${o_type} follows
  46. };
  47. struct json_object_object
  48. {
  49. struct json_object base;
  50. struct lh_table *c_object;
  51. };
  52. struct json_object_array
  53. {
  54. struct json_object base;
  55. struct array_list *c_array;
  56. };
  57. struct json_object_boolean
  58. {
  59. struct json_object base;
  60. json_bool c_boolean;
  61. };
  62. struct json_object_double
  63. {
  64. struct json_object base;
  65. double c_double;
  66. };
  67. struct json_object_int
  68. {
  69. struct json_object base;
  70. enum json_object_int_type cint_type;
  71. union
  72. {
  73. int64_t c_int64;
  74. uint64_t c_uint64;
  75. } cint;
  76. };
  77. struct json_object_string
  78. {
  79. struct json_object base;
  80. ssize_t len; // Signed b/c negative lengths indicate data is a pointer
  81. // Consider adding an "alloc" field here, if json_object_set_string calls
  82. // to expand the length of a string are common operations to perform.
  83. union
  84. {
  85. char idata[1]; // Immediate data. Actually longer
  86. char *pdata; // Only when len < 0
  87. } c_string;
  88. };
  89. void _json_c_set_last_err(const char *err_fmt, ...);
  90. /**
  91. * @brief Add an object field to a json_object of type json_type_object
  92. *
  93. * The semantics are identical to json_object_object_add_ex, except that @p key
  94. * contains both the data and the length.
  95. *
  96. * @param obj the json_object instance
  97. * @param key the object field name (a private copy will be duplicated)
  98. * @param val a json_object or NULL member to associate with the given field
  99. * @param opts process-modifying options. To specify multiple options, use
  100. * (OPT1|OPT2)
  101. * @return On success, @c 0 is returned.
  102. * On error, a negative value is returned.
  103. */
  104. int json_object_object_add_internal(struct json_object *obj, const struct lh_string *key,
  105. struct json_object *const val, const unsigned opts);
  106. /**
  107. * The characters that can make up hexadecimal numbers
  108. */
  109. extern const char *json_hex_chars;
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif