summaryrefslogtreecommitdiff
path: root/cdec_json_parser/json_parse.h
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-08-16 21:25:52 +0100
committerPatrick Simianer <p@simianer.de>2014-08-16 21:25:52 +0100
commit9a0859212de4d1304f9392fe910921227421c8c3 (patch)
tree1b1276312c83415d7d7d3838ce0347441b71951a /cdec_json_parser/json_parse.h
parent3ba77e3474e39d7970784812f6851a726572f7c7 (diff)
cleanup
Diffstat (limited to 'cdec_json_parser/json_parse.h')
-rw-r--r--cdec_json_parser/json_parse.h62
1 files changed, 0 insertions, 62 deletions
diff --git a/cdec_json_parser/json_parse.h b/cdec_json_parser/json_parse.h
deleted file mode 100644
index 80c037b..0000000
--- a/cdec_json_parser/json_parse.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef _JSON_WRAPPER_H_
-#define _JSON_WRAPPER_H_
-
-#include <iostream>
-#include <cassert>
-#include "JSON_parser.h"
-
-class JSONParser {
- public:
- JSONParser() {
- state = -1;
- init_JSON_config(&config);
- hack.mf = &JSONParser::Callback;
- config.depth = 10;
- config.callback_ctx = reinterpret_cast<void*>(this);
- config.callback = hack.cb;
- config.allow_comments = 1;
- config.handle_floats_manually = 1;
- jc = new_JSON_parser(&config);
- }
- virtual ~JSONParser() {
- delete_JSON_parser(jc);
- }
- bool Parse(std::istream* in) {
- int count = 0;
- int lc = 1;
- for (; in ; ++count) {
- int next_char = in->get();
- if (!in->good()) break;
- if (lc == '\n') { ++lc; }
- if (!JSON_parser_char(jc, next_char)) {
- std::cerr << "JSON_parser_char: syntax error, line " << lc << " (byte " << count << ")" << std::endl;
- return false;
- }
- }
- if (!JSON_parser_done(jc)) {
- std::cerr << "JSON_parser_done: syntax error\n";
- return false;
- }
- return true;
- }
- static void WriteEscapedString(const std::string& in, std::ostream* out);
- protected:
- bool HandleJSONEvent(int type, const JSON_value* value);
- private:
- int state;
- std::string cur_key;
- std::string cat;
- int Callback(int type, const JSON_value* value) {
- if (HandleJSONEvent(type, value)) return 1;
- return 0;
- }
- JSON_parser_struct* jc;
- JSON_config config;
- typedef int (JSONParser::* MF)(int type, const struct JSON_value_struct* value);
- union CBHack {
- JSON_parser_callback cb;
- MF mf;
- } hack;
-};
-
-#endif