MCPcopy Create free account
hub / github.com/SICKAG/sick_scan_xd / newStreamWriter

Method newStreamWriter

test/docker/jsoncpp/src/lib_json/json_writer.cpp:1162–1203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1160StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
1161StreamWriterBuilder::~StreamWriterBuilder() = default;
1162StreamWriter* StreamWriterBuilder::newStreamWriter() const {
1163 const String indentation = settings_["indentation"].asString();
1164 const String cs_str = settings_["commentStyle"].asString();
1165 const String pt_str = settings_["precisionType"].asString();
1166 const bool eyc = settings_["enableYAMLCompatibility"].asBool();
1167 const bool dnp = settings_["dropNullPlaceholders"].asBool();
1168 const bool usf = settings_["useSpecialFloats"].asBool();
1169 const bool emitUTF8 = settings_["emitUTF8"].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 String colonSymbol = " : ";
1188 if (eyc) {
1189 colonSymbol = ": ";
1190 } else if (indentation.empty()) {
1191 colonSymbol = ":";
1192 }
1193 String nullSymbol = "null";
1194 if (dnp) {
1195 nullSymbol.clear();
1196 }
1197 if (pre > 17)
1198 pre = 17;
1199 String endingLineFeedSymbol;
1200 return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, nullSymbol,
1201 endingLineFeedSymbol, usf, emitUTF8, pre,
1202 precisionType);
1203}
1204
1205bool StreamWriterBuilder::validate(Json::Value* invalid) const {
1206 static const auto& valid_keys = *new std::set<String>{

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