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
public
:
18
typedef
char
Char
;
19
typedef
const
Char
*
Location
;
20
24
Reader
();
25
29
Reader
(
const
Features
&
features
);
30
41
bool
parse
(
const
std::string
&document,
Value
&
root
,
bool
collectComments =
true
);
42
53
bool
parse
(
const
char
*beginDoc,
const
char
*endDoc,
Value
&
root
,
bool
collectComments =
true
);
54
57
bool
parse
(std::istream &is,
Value
&
root
,
bool
collectComments =
true
);
58
64
std::string
getFormatedErrorMessages()
const
;
65
66
private
:
67
enum
TokenType
{
68
tokenEndOfStream = 0,
69
tokenObjectBegin
,
70
tokenObjectEnd
,
71
tokenArrayBegin
,
72
tokenArrayEnd
,
73
tokenString
,
74
tokenNumber
,
75
tokenTrue
,
76
tokenFalse
,
77
tokenNull
,
78
tokenArraySeparator
,
79
tokenMemberSeparator
,
80
tokenComment
,
81
tokenError
82
};
83
84
class
Token
{
85
public
:
86
TokenType
type_
;
87
Location
start_
;
88
Location
end_
;
89
};
90
91
class
ErrorInfo
{
92
public
:
93
Token
token_
;
94
std::string
message_
;
95
Location
extra_
;
96
};
97
98
typedef
std::deque<ErrorInfo>
Errors
;
99
100
bool
expectToken(
TokenType
type
,
Token
&
token
,
const
char
*message);
101
bool
readToken(
Token
&
token
);
102
void
skipSpaces();
103
bool
match
(
Location
pattern
,
int
patternLength);
104
bool
readComment();
105
bool
readCStyleComment();
106
bool
readCppStyleComment();
107
bool
readString();
108
void
readNumber();
109
bool
readValue();
110
bool
readObject(
Token
&
token
);
111
bool
readArray(
Token
&
token
);
112
bool
decodeNumber(
Token
&
token
);
113
bool
decodeString(
Token
&
token
);
114
bool
decodeString(
Token
&
token
,
std::string
&decoded);
115
bool
decodeDouble(
Token
&
token
);
116
bool
decodeUnicodeCodePoint(
Token
&
token
,
Location
¤t,
Location
end
,
unsigned
int
&
unicode
);
117
bool
decodeUnicodeEscapeSequence(
Token
&
token
,
Location
¤t,
Location
end
,
unsigned
int
&
unicode
);
118
bool
addError(
const
std::string
&message,
Token
&
token
,
Location
extra =
nullptr
);
119
bool
recoverFromError(
TokenType
skipUntilToken);
120
bool
addErrorAndRecover(
const
std::string
&message,
Token
&
token
,
TokenType
skipUntilToken);
121
void
skipUntilSpace();
122
Value
¤tValue();
123
Char
getNextChar();
124
void
getLocationLineAndColumn(
Location
location
,
int
&
line
,
int
&column)
const
;
125
std::string
getLocationLineAndColumn(
Location
location
)
const
;
126
void
addComment(
Location
begin,
Location
end
,
CommentPlacement
placement);
127
void
skipCommentTokens(
Token
&
token
);
128
129
typedef
std::stack<Value *>
Nodes
;
130
Nodes
nodes_
;
131
Errors
errors_
;
132
std::string
document_
;
133
Location
begin_
;
134
Location
end_
;
135
Location
current_
;
136
Location
lastValueEnd_
;
137
Value
*
lastValue_
;
138
std::string
commentsBefore_
;
139
Features
features_
;
140
bool
collectComments_
;
141
};
142
167
std::istream &
operator>>
(std::istream &,
Value
&);
168
169
}
// namespace Json
170
171
#endif // CPPTL_JSON_READER_H_INCLUDED
Json::Reader::Nodes
std::stack< Value * > Nodes
Definition:
reader.h:129
parse
vector< string > parse(string line, const string &delimiter)
Definition:
beamSpotDipStandalone.cc:141
JSON_API
#define JSON_API
Definition:
config.h:40
Json::Reader::current_
Location current_
Definition:
reader.h:135
Json::Reader::tokenString
Definition:
reader.h:73
Json::Reader::Char
char Char
Definition:
reader.h:18
Json::Reader::tokenMemberSeparator
Definition:
reader.h:79
betterConfigParser.unicode
unicode
Definition:
betterConfigParser.py:13
Json::Reader::commentsBefore_
std::string commentsBefore_
Definition:
reader.h:138
Json::Reader::tokenObjectBegin
Definition:
reader.h:69
Json::Reader::TokenType
TokenType
Definition:
reader.h:67
Json::Reader::Token::type_
TokenType type_
Definition:
reader.h:86
Json::Reader::collectComments_
bool collectComments_
Definition:
reader.h:140
Json::Reader::tokenArraySeparator
Definition:
reader.h:78
Json::Value
Represents a JSON value.
Definition:
value.h:99
type
type
Definition:
SiPixelVCal_PayloadInspector.cc:39
Json::Reader::ErrorInfo::message_
std::string message_
Definition:
reader.h:94
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:74
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
Json::Reader::Errors
std::deque< ErrorInfo > Errors
Definition:
reader.h:98
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition:
topSingleLeptonDQM_PU_cfi.py:39
Json::Reader::Token::start_
Location start_
Definition:
reader.h:87
Json::Reader::Token
Definition:
reader.h:84
lowptgsfeleseed::features
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
Definition:
LowPtGsfElectronFeatures.cc:17
Json::Reader::tokenTrue
Definition:
reader.h:75
mps_splice.line
line
Definition:
mps_splice.py:76
Json::Reader::ErrorInfo::token_
Token token_
Definition:
reader.h:93
Json::Reader::tokenObjectEnd
Definition:
reader.h:70
Json::Reader::Token::end_
Location end_
Definition:
reader.h:88
Json::Reader::errors_
Errors errors_
Definition:
reader.h:131
Json::Reader::tokenArrayEnd
Definition:
reader.h:72
Json
JSON (JavaScript Object Notation).
Definition:
EvFDaqDirector.h:44
Json::Reader::end_
Location end_
Definition:
reader.h:134
Json::CommentPlacement
CommentPlacement
Definition:
value.h:34
mps_fire.end
end
Definition:
mps_fire.py:242
EcalCondDBWriter_cfi.location
location
Definition:
EcalCondDBWriter_cfi.py:63
Json::operator>>
std::istream & operator>>(std::istream &, Value &)
Read from 'sin' into 'root'.
Json::Reader::nodes_
Nodes nodes_
Definition:
reader.h:130
value.h
Json::Reader::tokenNull
Definition:
reader.h:77
Json::Reader::ErrorInfo
Definition:
reader.h:91
Json::Reader::ErrorInfo::extra_
Location extra_
Definition:
reader.h:95
Json::Reader::tokenArrayBegin
Definition:
reader.h:71
Json::Reader
Unserialize a JSON document into a Value.
Definition:
reader.h:16
Json::Reader::features_
Features features_
Definition:
reader.h:139
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:76
Json::Reader::lastValueEnd_
Location lastValueEnd_
Definition:
reader.h:136
Json::Reader::Location
const Char * Location
Definition:
reader.h:19
Json::Reader::document_
std::string document_
Definition:
reader.h:132
Json::Reader::begin_
Location begin_
Definition:
reader.h:133
Json::Reader::lastValue_
Value * lastValue_
Definition:
reader.h:137
unpackBuffers-CaloStage2.token
token
Definition:
unpackBuffers-CaloStage2.py:316
Json::Reader::tokenComment
Definition:
reader.h:80
root
Definition:
RooFitFunction.h:10
Generated for CMSSW Reference Manual by
1.8.14