Main Page
Namespaces
Classes
Package Documentation
EventFilter
Utilities
interface
reader.h
Go to the documentation of this file.
1
#ifndef CPPTL_JSON_READER_H_INCLUDED
2
# define CPPTL_JSON_READER_H_INCLUDED
3
4
# include "
features.h
"
5
# include "
value.h
"
6
# include <deque>
7
# include <stack>
8
# include <string>
9
# include <iostream>
10
11
namespace
Json
{
12
16
class
JSON_API
Reader
17
{
18
public
:
19
typedef
char
Char
;
20
typedef
const
Char *
Location
;
21
25
Reader
();
26
30
Reader
(
const
Features
&features );
31
42
bool
parse
(
const
std::string
&document,
43
Value
&
root
,
44
bool
collectComments =
true
);
45
56
bool
parse
(
const
char
*beginDoc,
const
char
*endDoc,
57
Value
&
root
,
58
bool
collectComments =
true
);
59
62
bool
parse
( std::istream &is,
63
Value
&
root
,
64
bool
collectComments =
true
);
65
71
std::string
getFormatedErrorMessages()
const
;
72
73
private
:
74
enum
TokenType
75
{
76
tokenEndOfStream = 0,
77
tokenObjectBegin
,
78
tokenObjectEnd
,
79
tokenArrayBegin
,
80
tokenArrayEnd
,
81
tokenString
,
82
tokenNumber
,
83
tokenTrue
,
84
tokenFalse
,
85
tokenNull
,
86
tokenArraySeparator
,
87
tokenMemberSeparator
,
88
tokenComment
,
89
tokenError
90
};
91
92
class
Token
93
{
94
public
:
95
TokenType
type_
;
96
Location
start_
;
97
Location
end_
;
98
};
99
100
class
ErrorInfo
101
{
102
public
:
103
Token
token_
;
104
std::string
message_
;
105
Location
extra_
;
106
};
107
108
typedef
std::deque<ErrorInfo>
Errors
;
109
110
bool
expectToken(
TokenType
type
,
Token
&token,
const
char
*message );
111
bool
readToken(
Token
&token );
112
void
skipSpaces();
113
bool
match
( Location
pattern
,
114
int
patternLength );
115
bool
readComment();
116
bool
readCStyleComment();
117
bool
readCppStyleComment();
118
bool
readString();
119
void
readNumber();
120
bool
readValue();
121
bool
readObject(
Token
&token );
122
bool
readArray(
Token
&token );
123
bool
decodeNumber(
Token
&token );
124
bool
decodeString(
Token
&token );
125
bool
decodeString(
Token
&token,
std::string
&decoded );
126
bool
decodeDouble(
Token
&token );
127
bool
decodeUnicodeCodePoint(
Token
&token,
128
Location ¤t,
129
Location
end
,
130
unsigned
int
&unicode );
131
bool
decodeUnicodeEscapeSequence(
Token
&token,
132
Location ¤t,
133
Location
end
,
134
unsigned
int
&unicode );
135
bool
addError(
const
std::string
&message,
136
Token
&token,
137
Location extra =
nullptr
);
138
bool
recoverFromError(
TokenType
skipUntilToken );
139
bool
addErrorAndRecover(
const
std::string
&message,
140
Token
&token,
141
TokenType
skipUntilToken );
142
void
skipUntilSpace();
143
Value
¤tValue();
144
Char getNextChar();
145
void
getLocationLineAndColumn( Location location,
146
int
&
line
,
147
int
&column )
const
;
148
std::string
getLocationLineAndColumn( Location location )
const
;
149
void
addComment( Location
begin
,
150
Location
end
,
151
CommentPlacement
placement );
152
void
skipCommentTokens(
Token
&token );
153
154
typedef
std::stack<Value *>
Nodes
;
155
Nodes
nodes_
;
156
Errors
errors_
;
157
std::string
document_
;
158
Location
begin_
;
159
Location
end_
;
160
Location
current_
;
161
Location
lastValueEnd_
;
162
Value
*
lastValue_
;
163
std::string
commentsBefore_
;
164
Features
features_
;
165
bool
collectComments_
;
166
};
167
192
std::istream&
operator>>
( std::istream&,
Value
& );
193
194
}
// namespace Json
195
196
#endif // CPPTL_JSON_READER_H_INCLUDED
type
type
Definition:
HCALResponse.h:21
Json::Reader::Nodes
std::stack< Value * > Nodes
Definition:
reader.h:154
JSON_API
#define JSON_API
Definition:
config.h:40
Json::Reader::current_
Location current_
Definition:
reader.h:160
Json::Reader::tokenString
Definition:
reader.h:81
Json::Reader::Char
char Char
Definition:
reader.h:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
Json::Reader::tokenMemberSeparator
Definition:
reader.h:87
Json::Reader::commentsBefore_
std::string commentsBefore_
Definition:
reader.h:163
Json::Reader::tokenObjectBegin
Definition:
reader.h:77
Json::Reader::TokenType
TokenType
Definition:
reader.h:74
Json::Reader::Token::type_
TokenType type_
Definition:
reader.h:95
Json::Reader::collectComments_
bool collectComments_
Definition:
reader.h:165
Json::Reader::tokenArraySeparator
Definition:
reader.h:86
Json::Value
Represents a JSON value.
Definition:
value.h:111
Json::Reader::ErrorInfo::message_
std::string message_
Definition:
reader.h:104
Json::Features
Configuration passed to reader and writer. This configuration object can be used to force the Reader ...
Definition:
features.h:12
Json::Reader::tokenNumber
Definition:
reader.h:82
Json::Reader::Errors
std::deque< ErrorInfo > Errors
Definition:
reader.h:108
Json::Reader::Token::start_
Location start_
Definition:
reader.h:96
Json::Reader::Token
Definition:
reader.h:92
Json::Reader::tokenTrue
Definition:
reader.h:83
mps_splice.line
line
Definition:
mps_splice.py:75
Json::Reader::ErrorInfo::token_
Token token_
Definition:
reader.h:103
Json::Reader::tokenObjectEnd
Definition:
reader.h:78
Json::Reader::Token::end_
Location end_
Definition:
reader.h:97
Json::Reader::errors_
Errors errors_
Definition:
reader.h:156
end
#define end
Definition:
vmac.h:39
Json::Reader::tokenArrayEnd
Definition:
reader.h:80
Json
JSON (JavaScript Object Notation).
Definition:
EvFDaqDirector.h:44
Json::Reader::end_
Location end_
Definition:
reader.h:159
Json::CommentPlacement
CommentPlacement
Definition:
value.h:35
listBenchmarks.pattern
pattern
Definition:
listBenchmarks.py:26
dumpparser.parse
def parse(path, config)
Definition:
dumpparser.py:13
Json::operator>>
std::istream & operator>>(std::istream &, Value &)
Read from 'sin' into 'root'.
Json::Reader::nodes_
Nodes nodes_
Definition:
reader.h:155
begin
#define begin
Definition:
vmac.h:32
value.h
Json::Reader::tokenNull
Definition:
reader.h:85
Json::Reader::ErrorInfo
Definition:
reader.h:100
Json::Reader::ErrorInfo::extra_
Location extra_
Definition:
reader.h:105
Json::Reader::tokenArrayBegin
Definition:
reader.h:79
Json::Reader
Unserialize a JSON document into a Value.
Definition:
reader.h:16
Json::Reader::features_
Features features_
Definition:
reader.h:164
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
features.h
Json::Reader::tokenFalse
Definition:
reader.h:84
Json::Reader::lastValueEnd_
Location lastValueEnd_
Definition:
reader.h:161
Json::Reader::Location
const Char * Location
Definition:
reader.h:20
Json::Reader::document_
std::string document_
Definition:
reader.h:157
Json::Reader::begin_
Location begin_
Definition:
reader.h:158
Json::Reader::lastValue_
Value * lastValue_
Definition:
reader.h:162
Json::Reader::tokenComment
Definition:
reader.h:88
root
Definition:
RooFitFunction.h:11
Generated for CMSSW Reference Manual by
1.8.11