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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 _MSC_VER
  24. #include <BaseTsd.h>
  25. typedef SSIZE_T ssize_t;
  26. #endif
  27. typedef void (json_object_private_delete_fn)(struct json_object *o);
  28. /* json object int type, support extension*/
  29. typedef enum json_object_int_type
  30. {
  31. json_object_int_type_int64,
  32. json_object_int_type_uint64
  33. } json_object_int_type;
  34. struct json_object
  35. {
  36. enum json_type o_type;
  37. uint32_t _ref_count;
  38. json_object_private_delete_fn *_delete;
  39. json_object_to_json_string_fn *_to_json_string;
  40. struct printbuf *_pb;
  41. json_object_delete_fn *_user_delete;
  42. void *_userdata;
  43. // Actually longer, always malloc'd as some more-specific type.
  44. // The rest of a struct json_object_${o_type} follows
  45. };
  46. struct json_object_object
  47. {
  48. struct json_object base;
  49. struct lh_table *c_object;
  50. };
  51. struct json_object_array
  52. {
  53. struct json_object base;
  54. struct array_list *c_array;
  55. };
  56. struct json_object_boolean
  57. {
  58. struct json_object base;
  59. json_bool c_boolean;
  60. };
  61. struct json_object_double
  62. {
  63. struct json_object base;
  64. double c_double;
  65. };
  66. struct json_object_int
  67. {
  68. struct json_object base;
  69. enum json_object_int_type cint_type;
  70. union
  71. {
  72. int64_t c_int64;
  73. uint64_t c_uint64;
  74. } cint;
  75. };
  76. struct json_object_string
  77. {
  78. struct json_object base;
  79. ssize_t len; // Signed b/c negative lengths indicate data is a pointer
  80. // Consider adding an "alloc" field here, if json_object_set_string calls
  81. // to expand the length of a string are common operations to perform.
  82. union
  83. {
  84. char idata[1]; // Immediate data. Actually longer
  85. char *pdata; // Only when len < 0
  86. } c_string;
  87. };
  88. void _json_c_set_last_err(const char *err_fmt, ...);
  89. extern const char *json_number_chars;
  90. extern const char *json_hex_chars;
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif