MCPcopy Create free account
hub / github.com/PlayFab/gsdk / newStreamWriter

Method newStreamWriter

cpp/cppsdk/jsoncpp.cpp:5336–5376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5334StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
5335StreamWriterBuilder::~StreamWriterBuilder() {}
5336StreamWriter* StreamWriterBuilder::newStreamWriter() const {
5337 JSONCPP_STRING indentation = settings_["indentation"].asString();
5338 JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
5339 JSONCPP_STRING pt_str = settings_["precisionType"].asString();
5340 bool eyc = settings_["enableYAMLCompatibility"].asBool();
5341 bool dnp = settings_["dropNullPlaceholders"].asBool();
5342 bool usf = settings_["useSpecialFloats"].asBool();
5343 unsigned int pre = settings_["precision"].asUInt();
5344 CommentStyle::Enum cs = CommentStyle::All;
5345 if (cs_str == "All") {
5346 cs = CommentStyle::All;
5347 } else if (cs_str == "None") {
5348 cs = CommentStyle::None;
5349 } else {
5350 throwRuntimeError("commentStyle must be 'All' or 'None'");
5351 }
5352 PrecisionType precisionType(significantDigits);
5353 if (pt_str == "significant") {
5354 precisionType = PrecisionType::significantDigits;
5355 } else if (pt_str == "decimal") {
5356 precisionType = PrecisionType::decimalPlaces;
5357 } else {
5358 throwRuntimeError("precisionType must be 'significant' or 'decimal'");
5359 }
5360 JSONCPP_STRING colonSymbol = " : ";
5361 if (eyc) {
5362 colonSymbol = ": ";
5363 } else if (indentation.empty()) {
5364 colonSymbol = ":";
5365 }
5366 JSONCPP_STRING nullSymbol = "null";
5367 if (dnp) {
5368 nullSymbol.clear();
5369 }
5370 if (pre > 17)
5371 pre = 17;
5372 JSONCPP_STRING endingLineFeedSymbol;
5373 return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, nullSymbol,
5374 endingLineFeedSymbol, usf, pre,
5375 precisionType);
5376}
5377static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys) {
5378 valid_keys->clear();
5379 valid_keys->insert("indentation");

Callers 2

writeStringFunction · 0.80
jsoncpp.cppFile · 0.80

Calls 6

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

Tested by

no test coverage detected