MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / newStreamWriter

Method newStreamWriter

edrav2/eprj/jsoncpp/src/lib_json/json_writer.cpp:1163–1203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1161StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
1162StreamWriterBuilder::~StreamWriterBuilder() = default;
1163StreamWriter* StreamWriterBuilder::newStreamWriter() const {
1164 JSONCPP_STRING indentation = settings_["indentation"].asString();
1165 JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
1166 JSONCPP_STRING pt_str = settings_["precisionType"].asString();
1167 bool eyc = settings_["enableYAMLCompatibility"].asBool();
1168 bool dnp = settings_["dropNullPlaceholders"].asBool();
1169 bool usf = settings_["useSpecialFloats"].asBool();
1170 unsigned int pre = settings_["precision"].asUInt();
1171 CommentStyle::Enum cs = CommentStyle::All;
1172 if (cs_str == "All") {
1173 cs = CommentStyle::All;
1174 } else if (cs_str == "None") {
1175 cs = CommentStyle::None;
1176 } else {
1177 throwRuntimeError("commentStyle must be 'All' or 'None'");
1178 }
1179 PrecisionType precisionType(significantDigits);
1180 if (pt_str == "significant") {
1181 precisionType = PrecisionType::significantDigits;
1182 } else if (pt_str == "decimal") {
1183 precisionType = PrecisionType::decimalPlaces;
1184 } else {
1185 throwRuntimeError("precisionType must be 'significant' or 'decimal'");
1186 }
1187 JSONCPP_STRING colonSymbol = " : ";
1188 if (eyc) {
1189 colonSymbol = ": ";
1190 } else if (indentation.empty()) {
1191 colonSymbol = ":";
1192 }
1193 JSONCPP_STRING nullSymbol = "null";
1194 if (dnp) {
1195 nullSymbol.clear();
1196 }
1197 if (pre > 17)
1198 pre = 17;
1199 JSONCPP_STRING endingLineFeedSymbol;
1200 return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, nullSymbol,
1201 endingLineFeedSymbol, usf, pre,
1202 precisionType);
1203}
1204static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys) {
1205 valid_keys->clear();
1206 valid_keys->insert("indentation");

Callers 2

writeStringFunction · 0.80
json_writer.cppFile · 0.80

Calls 6

throwRuntimeErrorFunction · 0.85
asStringMethod · 0.80
asBoolMethod · 0.80
asUIntMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected