json-path.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* json-path.h - JSONPath implementation
  2. *
  3. * This file is part of JSON-GLib
  4. * Copyright © 2011 Intel Corp.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * Author:
  20. * Emmanuele Bassi <ebassi@linux.intel.com>
  21. */
  22. #ifndef __JSON_PATH_H__
  23. #define __JSON_PATH_H__
  24. #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
  25. #error "Only <json-glib/json-glib.h> can be included directly."
  26. #endif
  27. #include <json-glib/json-types.h>
  28. G_BEGIN_DECLS
  29. #define JSON_TYPE_PATH (json_path_get_type ())
  30. #define JSON_PATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_PATH, JsonPath))
  31. #define JSON_IS_PATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_PATH))
  32. /**
  33. * JSON_PATH_ERROR:
  34. *
  35. * Error domain for #JsonPath errors
  36. *
  37. * Since: 0.14
  38. */
  39. #define JSON_PATH_ERROR (json_path_error_quark ())
  40. /**
  41. * JsonPathError:
  42. * @JSON_PATH_ERROR_INVALID_QUERY: Invalid query
  43. *
  44. * Error code enumeration for the %JSON_PATH_ERROR domain.
  45. *
  46. * Since: 0.14
  47. */
  48. typedef enum {
  49. JSON_PATH_ERROR_INVALID_QUERY
  50. } JsonPathError;
  51. /**
  52. * JsonPath:
  53. *
  54. * The `JsonPath` structure is an opaque object whose members cannot be
  55. * directly accessed except through the provided API.
  56. *
  57. * Since: 0.14
  58. */
  59. typedef struct _JsonPath JsonPath;
  60. /**
  61. * JsonPathClass:
  62. *
  63. * The `JsonPathClass` structure is an opaque object class whose members
  64. * cannot be directly accessed.
  65. *
  66. * Since: 0.14
  67. */
  68. typedef struct _JsonPathClass JsonPathClass;
  69. JSON_AVAILABLE_IN_1_0
  70. GType json_path_get_type (void) G_GNUC_CONST;
  71. JSON_AVAILABLE_IN_1_0
  72. GQuark json_path_error_quark (void);
  73. JSON_AVAILABLE_IN_1_0
  74. JsonPath * json_path_new (void);
  75. JSON_AVAILABLE_IN_1_0
  76. gboolean json_path_compile (JsonPath *path,
  77. const char *expression,
  78. GError **error);
  79. JSON_AVAILABLE_IN_1_0
  80. JsonNode * json_path_match (JsonPath *path,
  81. JsonNode *root);
  82. JSON_AVAILABLE_IN_1_0
  83. JsonNode * json_path_query (const char *expression,
  84. JsonNode *root,
  85. GError **error);
  86. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  87. G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonPath, g_object_unref)
  88. #endif
  89. G_END_DECLS
  90. #endif /* __JSON_PATH_H__ */