src
EventFilter
Utilities
interface
writer.h
Go to the documentation of this file.
1
#ifndef JSON_WRITER_H_INCLUDED
2
#define JSON_WRITER_H_INCLUDED
3
4
#include "
value.h
"
5
#include <vector>
6
#include <string>
7
#include <iostream>
8
9
namespace
jsoncollector
{
10
namespace
Json {
11
12
class
Value
;
13
16
class
JSON_API
Writer
{
17
public
:
18
virtual
~
Writer
();
19
20
virtual
std::string
write
(
const
Value
&
root
) = 0;
21
};
22
29
class
JSON_API
FastWriter
:
public
Writer
{
30
public
:
31
FastWriter
();
32
~FastWriter
()
override
{}
33
34
void
enableYAMLCompatibility();
35
36
public
:
// overridden from Writer
37
std::string
write
(
const
Value
&
root
)
override
;
38
39
private
:
40
void
writeValue
(
const
Value
&
value
);
41
42
std::string
document_
;
43
bool
yamlCompatiblityEnabled_
;
44
};
45
64
class
JSON_API
StyledWriter
:
public
Writer
{
65
public
:
66
StyledWriter
();
67
~StyledWriter
()
override
{}
68
69
public
:
// overridden from Writer
74
std::string
write
(
const
Value
&
root
)
override
;
75
76
private
:
77
void
writeValue
(
const
Value
&
value
);
78
void
writeArrayValue(
const
Value
&
value
);
79
bool
isMultineArray(
const
Value
&
value
);
80
void
pushValue(
const
std::string
&
value
);
81
void
writeIndent();
82
void
writeWithIndent(
const
std::string
&
value
);
83
void
indent
();
84
void
unindent();
85
void
writeCommentBeforeValue(
const
Value
&
root
);
86
void
writeCommentAfterValueOnSameLine(
const
Value
&
root
);
87
bool
hasCommentForValue(
const
Value
&
value
);
88
static
std::string
normalizeEOL(
const
std::string
&
text
);
89
90
typedef
std::vector<std::string>
ChildValues
;
91
92
ChildValues
childValues_
;
93
std::string
document_
;
94
std::string
indentString_
;
95
int
rightMargin_
;
96
int
indentSize_
;
97
bool
addChildValues_
;
98
};
99
120
class
JSON_API
StyledStreamWriter
{
121
public
:
122
StyledStreamWriter
(
std::string
indentation
=
"\t"
);
123
~StyledStreamWriter
() {}
124
125
public
:
131
void
write
(std::ostream &
out
,
const
Value
&
root
);
132
133
private
:
134
void
writeValue
(
const
Value
&
value
);
135
void
writeArrayValue(
const
Value
&
value
);
136
bool
isMultineArray(
const
Value
&
value
);
137
void
pushValue(
const
std::string
&
value
);
138
void
writeIndent();
139
void
writeWithIndent(
const
std::string
&
value
);
140
void
indent
();
141
void
unindent();
142
void
writeCommentBeforeValue(
const
Value
&
root
);
143
void
writeCommentAfterValueOnSameLine(
const
Value
&
root
);
144
bool
hasCommentForValue(
const
Value
&
value
);
145
static
std::string
normalizeEOL(
const
std::string
&
text
);
146
147
typedef
std::vector<std::string>
ChildValues
;
148
149
ChildValues
childValues_
;
150
std::ostream *
document_
;
151
std::string
indentString_
;
152
int
rightMargin_
;
153
std::string
indentation_
;
154
bool
addChildValues_
;
155
};
156
157
std::string
JSON_API
valueToString
(
Int
value
);
158
std::string
JSON_API
valueToString
(
UInt
value
);
159
std::string
JSON_API
valueToString
(
double
value
);
160
std::string
JSON_API
valueToString
(
bool
value
);
161
std::string
JSON_API
valueToQuotedString
(
const
char
*
value
);
162
165
std::ostream &
operator<<
(std::ostream &,
const
Value
&
root
);
166
167
}
// namespace Json
168
}
// namespace jsoncollector
169
170
#endif // JSON_WRITER_H_INCLUDED
jsoncollector::Json::StyledStreamWriter
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string...
Definition:
writer.h:120
jsoncollector::Json::StyledStreamWriter::rightMargin_
int rightMargin_
Definition:
writer.h:152
jsoncollector::Json::StyledWriter::indentSize_
int indentSize_
Definition:
writer.h:96
jsoncollector::Json::StyledWriter::ChildValues
std::vector< std::string > ChildValues
Definition:
writer.h:90
jsoncollector::Json::FastWriter::yamlCompatiblityEnabled_
bool yamlCompatiblityEnabled_
Definition:
writer.h:43
jsoncollector::Json::StyledWriter::document_
std::string document_
Definition:
writer.h:93
jsoncollector::Json::operator<<
std::ostream & operator<<(std::ostream &, const Value &root)
Output using the StyledStreamWriter.
jsoncollector::Json::StyledStreamWriter::ChildValues
std::vector< std::string > ChildValues
Definition:
writer.h:147
jsoncollector::Json::StyledStreamWriter::childValues_
ChildValues childValues_
Definition:
writer.h:149
jsoncollector::Json::Writer
Abstract class for writers.
Definition:
writer.h:16
jsoncollector::Json::FastWriter
Outputs a Value in JSON format without formatting (not human friendly).
Definition:
writer.h:29
jsoncollector::Json::StyledWriter::indentString_
std::string indentString_
Definition:
writer.h:94
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
jsoncollector::Json::StyledStreamWriter::document_
std::ostream * document_
Definition:
writer.h:150
jsoncollector::Json::StyledStreamWriter::~StyledStreamWriter
~StyledStreamWriter()
Definition:
writer.h:123
jsoncollector::Json::FastWriter::document_
std::string document_
Definition:
writer.h:42
jsoncollector::Json::StyledWriter
Writes a Value in JSON format in a human friendly way.
Definition:
writer.h:64
JSON_API
#define JSON_API
Definition:
config.h:40
validateAlignments.indent
indent
Definition:
validateAlignments.py:315
jsoncollector::Json::StyledStreamWriter::addChildValues_
bool addChildValues_
Definition:
writer.h:154
jsoncollector::Json::StyledWriter::rightMargin_
int rightMargin_
Definition:
writer.h:95
reco::JetExtendedAssociation::Value
reco::JetExtendedAssociation::JetExtendedData Value
Definition:
JetExtendedAssociation.h:27
writeEcalDQMStatus.write
write
Definition:
writeEcalDQMStatus.py:48
value
Definition:
value.py:1
jsoncollector::Json::UInt
unsigned int UInt
Definition:
forwards.h:21
jsoncollector::Json::Int
int Int
Definition:
forwards.h:17
submitPVValidationJobs.text
string text
Definition:
submitPVValidationJobs.py:484
jsoncollector::Json::StyledWriter::addChildValues_
bool addChildValues_
Definition:
writer.h:97
jsoncollector::Json::StyledStreamWriter::indentString_
std::string indentString_
Definition:
writer.h:151
jsoncollector::Json::StyledStreamWriter::indentation_
std::string indentation_
Definition:
writer.h:153
MillePedeFileConverter_cfg.out
out
Definition:
MillePedeFileConverter_cfg.py:31
jsoncollector::Json::StyledWriter::~StyledWriter
~StyledWriter() override
Definition:
writer.h:67
jsoncollector::Json::valueToString
std::string valueToString(Int value)
edm::writeParameterValue::writeValue
void writeValue(std::ostream &os, int indentation, int const &value_, ValueFormat format)
Definition:
ParameterDescription.cc:645
value.h
printContent_cfi.indentation
indentation
Definition:
printContent_cfi.py:10
jsoncollector::Json::FastWriter::~FastWriter
~FastWriter() override
Definition:
writer.h:32
jsoncollector::Json::valueToQuotedString
std::string valueToQuotedString(const char *value)
jsoncollector::Json::Value
Represents a JSON value.
Definition:
value.h:101
jsoncollector
JSON (JavaScript Object Notation).
Definition:
DataPoint.h:26
jsoncollector::Json::StyledWriter::childValues_
ChildValues childValues_
Definition:
writer.h:92
root
Definition:
RooFitFunction.h:12
Generated for CMSSW Reference Manual by
1.8.14