qjson: replace QString in JSONLexer with GString
[qemu.git] / include / qapi / qmp / json-lexer.h
blobcb456d53e5594ad1280b1e991539cce0427034e0
1 /*
2 * JSON lexer
4 * Copyright IBM, Corp. 2009
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
14 #ifndef QEMU_JSON_LEXER_H
15 #define QEMU_JSON_LEXER_H
17 #include "glib-compat.h"
19 typedef enum json_token_type {
20 JSON_MIN = 100,
21 JSON_LCURLY = JSON_MIN,
22 JSON_RCURLY,
23 JSON_LSQUARE,
24 JSON_RSQUARE,
25 JSON_COLON,
26 JSON_COMMA,
27 JSON_INTEGER,
28 JSON_FLOAT,
29 JSON_KEYWORD,
30 JSON_STRING,
31 JSON_ESCAPE,
32 JSON_SKIP,
33 JSON_ERROR,
34 } JSONTokenType;
36 typedef struct JSONLexer JSONLexer;
38 typedef void (JSONLexerEmitter)(JSONLexer *, GString *,
39 JSONTokenType, int x, int y);
41 struct JSONLexer
43 JSONLexerEmitter *emit;
44 int state;
45 GString *token;
46 int x, y;
49 void json_lexer_init(JSONLexer *lexer, JSONLexerEmitter func);
51 int json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
53 int json_lexer_flush(JSONLexer *lexer);
55 void json_lexer_destroy(JSONLexer *lexer);
57 #endif