Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
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
39namespace ola {
40namespace web {
41
54class 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_
Basic data types used to represent elements in a JSON document.
Parse a string containing Json data.
Definition JsonLexer.h:54
static bool Parse(const std::string &input, class JsonParserInterface *handler)
Parse a string containing JSON data.
Definition JsonLexer.cpp:432
The interface used to handle tokens during JSON parsing.
Definition JsonLexer.h:71
virtual void Number(int64_t value)=0
Called when a int64_t is encountered.
virtual void End()=0
Called when parsing completes.
virtual void SetError(const std::string &error)=0
Can be called at any time to indicate an error with the input data.
virtual void Number(const JsonDouble::DoubleRepresentation &rep)=0
Called when a double value is encountered.
virtual void CloseArray()=0
Called when an array completes.
virtual void Null()=0
Called when a null token is encountered.
virtual void Bool(bool value)=0
Called when a bool is encountered.
virtual void Number(uint64_t value)=0
Called when a uint64_t is encountered.
virtual void Number(double d)=0
Called when a double value is encountered.
virtual void CloseObject()=0
Called when an object completes.
virtual void OpenObject()=0
Called when an object starts.
virtual void Number(int32_t value)=0
Called when a int32_t is encountered.
virtual void OpenArray()=0
Called when an array starts.
virtual void Begin()=0
Called when parsing begins.
virtual void Number(uint32_t value)=0
Called when a uint32_t is encountered.
virtual void ObjectKey(const std::string &key)=0
Called when a new key is encountered.
virtual void String(const std::string &value)=0
Called when a string is encountered.
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
Represents a JSON double value broken down as separate components.
Definition Json.h:666