Initial Import
[profile/ivi/json-glib.git] / json-glib / json-path.h
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
23 #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
24 #error "Only <json-glib/json-glib.h> can be included directly."
25 #endif
26
27 #ifndef __JSON_PATH_H__
28 #define __JSON_PATH_H__
29
30 #include <json-glib/json-types.h>
31
32 G_BEGIN_DECLS
33
34 #define JSON_TYPE_PATH          (json_path_get_type ())
35 #define JSON_PATH(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_PATH, JsonPath))
36 #define JSON_IS_PATH(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_PATH))
37
38 /**
39  * JSON_PATH_ERROR:
40  *
41  * Error domain for #JsonPath errors
42  *
43  * Since: 0.14
44  */
45 #define JSON_PATH_ERROR         (json_path_error_quark ())
46
47 /**
48  * JsonPathError:
49  * @JSON_PATH_ERROR_INVALID_QUERY: Invalid query
50  *
51  * Error code enumeration for the %JSON_PATH_ERROR domain.
52  *
53  * Since: 0.14
54  */
55 typedef enum {
56   JSON_PATH_ERROR_INVALID_QUERY
57 } JsonPathError;
58
59 /**
60  * JsonPath:
61  *
62  * The <structname>JsonPath</structname> structure is an opaque object
63  * whose members cannot be directly accessed except through the provided
64  * API.
65  *
66  * Since: 0.14
67  */
68 typedef struct _JsonPath        JsonPath;
69
70 /**
71  * JsonPathClass:
72  *
73  * The <structname>JsonPathClass</structname> structure is an opaque
74  * object class whose members cannot be directly accessed.
75  *
76  * Since: 0.14
77  */
78 typedef struct _JsonPathClass   JsonPathClass;
79
80 GType json_path_get_type (void) G_GNUC_CONST;
81 GQuark json_path_error_quark (void);
82
83 JsonPath *      json_path_new           (void);
84
85 gboolean        json_path_compile       (JsonPath    *path,
86                                          const char  *expression,
87                                          GError     **error);
88 JsonNode *      json_path_match         (JsonPath    *path,
89                                          JsonNode    *root);
90
91 JsonNode *      json_path_query         (const char  *expression,
92                                          JsonNode    *root,
93                                          GError     **error);
94
95 G_END_DECLS
96
97 #endif /* __JSON_PATH_H__ */