summaryrefslogtreecommitdiff
path: root/json-glib/json-parser.h
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@openedhand.com>2007-09-21 11:54:40 +0100
committerEmmanuele Bassi <ebassi@openedhand.com>2007-09-21 11:54:40 +0100
commitd98d8c3d245192abe6ec5a531c9d0d678b07d061 (patch)
tree8e30d2694dc9f9ac94c3973fd9fd7276199445c1 /json-glib/json-parser.h
parentcd1040e2fb6f6da50aaf72017746b33234c39704 (diff)
downloadjson-glib-d98d8c3d245192abe6ec5a531c9d0d678b07d061.tar.gz
Add stubs to JsonParser for actually parsing a JSON stream
Initial commit for getting JsonParser to work. Because GScanner API is old and mostly sucks, we need to do some magic with signals. If json_parser_load_from_data() fails, the passed GError will be set with a JSON_PARSER_ERROR code and message; unfortunately, we can't get the nice error message out of GScanner. We can, however, override the default message handler and make it emit a signal on the JsonParser object. So, to make a long story short: the GError passed to the load_from_data() method is filled with a short error message; the *real* error message is passed to the ::error signal handlers so they can actually use it. GScanner should really get a way to retrieve the last error message.
Diffstat (limited to 'json-glib/json-parser.h')
-rw-r--r--json-glib/json-parser.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/json-glib/json-parser.h b/json-glib/json-parser.h
index 50d5aa5..071b881 100644
--- a/json-glib/json-parser.h
+++ b/json-glib/json-parser.h
@@ -19,13 +19,19 @@ typedef struct _JsonParserPrivate JsonParserPrivate;
typedef struct _JsonParserClass JsonParserClass;
typedef enum {
- JSON_PARSER_ERROR_INVALID_OBJECT,
- JSON_PARSER_ERROR_INVALID_ARRAY,
- JSON_PARSER_ERROR_INVALID_PAIR,
+ JSON_PARSER_ERROR_PARSE,
JSON_PARSER_ERROR_UNKNOWN
} JsonParserError;
+typedef enum {
+ JSON_TOKEN_INVALID = G_TOKEN_LAST,
+ JSON_TOKEN_TRUE,
+ JSON_TOKEN_FALSE,
+ JSON_TOKEN_NULL,
+ JSON_TOKEN_LAST
+} JsonTokenType;
+
struct _JsonParser
{
/*< private >*/
@@ -36,7 +42,23 @@ struct _JsonParser
struct _JsonParserClass
{
+ /*< private >*/
GObjectClass parent_class;
+
+ /*< public >*/
+ void (* error) (JsonParser *parser,
+ const GError *error);
+
+ /*< private >*/
+ /* padding for future expansion */
+ void (* _json_reserved1) (void);
+ void (* _json_reserved2) (void);
+ void (* _json_reserved3) (void);
+ void (* _json_reserved4) (void);
+ void (* _json_reserved5) (void);
+ void (* _json_reserved6) (void);
+ void (* _json_reserved7) (void);
+ void (* _json_reserved8) (void);
};
GQuark json_parser_error_quark (void);