Open Lighting Architecture: include/ola/web/JsonLexer.h Source File

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