Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JsonLexer.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * JsonLexer.h
17  * A class for Parsing Json data.
18  * See http://www.json.org/
19  * Copyright (C) 2014 Simon Newton
20  */
21 
33 #ifndef INCLUDE_OLA_WEB_JSONLEXER_H_
34 #define INCLUDE_OLA_WEB_JSONLEXER_H_
35 
36 #include <ola/web/Json.h>
37 #include <string>
38 
39 namespace ola {
40 namespace web {
41 
54 class JsonLexer {
55  public:
62  static bool Parse(const std::string &input,
63  class JsonParserInterface *handler);
64 };
65 
72  public:
74  virtual ~JsonParserInterface() {}
75 
79  virtual void Begin() = 0;
80 
84  virtual void End() = 0;
85 
91  virtual void String(const std::string &value) = 0;
92 
96  virtual void Number(uint32_t value) = 0;
97 
101  virtual void Number(int32_t value) = 0;
102 
106  virtual void Number(uint64_t value) = 0;
107 
111  virtual void Number(int64_t value) = 0;
112 
121  virtual void Number(const JsonDouble::DoubleRepresentation &rep) = 0;
122 
126  virtual void Number(double d) = 0;
127 
131  virtual void Bool(bool value) = 0;
132 
136  virtual void Null() = 0;
137 
141  virtual void OpenArray() = 0;
142 
146  virtual void CloseArray() = 0;
147 
151  virtual void OpenObject() = 0;
152 
160  virtual void ObjectKey(const std::string &key) = 0;
161 
165  virtual void CloseObject() = 0;
166 
170  virtual void SetError(const std::string &error) = 0;
171 };
172 
174 } // namespace web
175 } // namespace ola
176 #endif // INCLUDE_OLA_WEB_JSONLEXER_H_