Open Lighting Architecture
0.9.2
Main Page
Modules
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
ola
web
JsonWriter.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
* JsonWriter.h
17
* Serialize JSON data.
18
* Copyright (C) 2012 Simon Newton
19
*/
20
29
#ifndef INCLUDE_OLA_WEB_JSONWRITER_H_
30
#define INCLUDE_OLA_WEB_JSONWRITER_H_
31
32
#include <
ola/base/Macro.h
>
33
#include <
ola/web/Json.h
>
34
#include <stdint.h>
35
#include <ostream>
36
#include <string>
37
38
namespace
ola {
39
namespace
web {
40
49
class
JsonWriter
:
public
JsonValueConstVisitorInterface
,
50
JsonObjectPropertyVisitor
{
51
public
:
57
static
void
Write
(std::ostream *output,
const
JsonValue
&value);
58
63
static
std::string
AsString
(
const
JsonValue
&value);
64
68
void
Visit(
const
JsonString
&value);
69
void
Visit(
const
JsonBool
&value);
70
void
Visit(
const
JsonNull
&value);
71
void
Visit(
const
JsonRawValue
&value);
72
void
Visit(
const
JsonObject
&value);
73
void
Visit(
const
JsonArray
&value);
74
void
Visit(
const
JsonUInt
&value);
75
void
Visit(
const
JsonUInt64
&value);
76
void
Visit(
const
JsonInt
&value);
77
void
Visit(
const
JsonInt64
&value);
78
void
Visit(
const
JsonDouble
&value);
79
80
void
VisitProperty(
const
std::string &property,
const
JsonValue
&value);
81
86
private
:
87
std::ostream *m_output;
88
unsigned
int
m_indent;
89
std::string m_separator;
90
91
explicit
JsonWriter
(std::ostream *output)
92
: m_output(output),
93
m_indent(0),
94
m_separator(
""
) {
95
}
96
100
static
const
unsigned
int
DEFAULT_INDENT = 2;
101
};
103
}
// namespace web
104
}
// namespace ola
105
#endif // INCLUDE_OLA_WEB_JSONWRITER_H_
Generated on Thu Aug 21 2014 16:02:56 for Open Lighting Architecture by
1.8.1.2