MCPcopy Create free account
hub / github.com/Samsung/ONE / newStreamWriter

Method newStreamWriter

runtime/3rdparty/jsoncpp/jsoncpp.cpp:5689–5744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5687StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
5688StreamWriterBuilder::~StreamWriterBuilder() = default;
5689StreamWriter *StreamWriterBuilder::newStreamWriter() const
5690{
5691 const String indentation = settings_["indentation"].asString();
5692 const String cs_str = settings_["commentStyle"].asString();
5693 const String pt_str = settings_["precisionType"].asString();
5694 const bool eyc = settings_["enableYAMLCompatibility"].asBool();
5695 const bool dnp = settings_["dropNullPlaceholders"].asBool();
5696 const bool usf = settings_["useSpecialFloats"].asBool();
5697 const bool emitUTF8 = settings_["emitUTF8"].asBool();
5698 unsigned int pre = settings_["precision"].asUInt();
5699 CommentStyle::Enum cs = CommentStyle::All;
5700 if (cs_str == "All")
5701 {
5702 cs = CommentStyle::All;
5703 }
5704 else if (cs_str == "None")
5705 {
5706 cs = CommentStyle::None;
5707 }
5708 else
5709 {
5710 throwRuntimeError("commentStyle must be 'All' or 'None'");
5711 }
5712 PrecisionType precisionType(significantDigits);
5713 if (pt_str == "significant")
5714 {
5715 precisionType = PrecisionType::significantDigits;
5716 }
5717 else if (pt_str == "decimal")
5718 {
5719 precisionType = PrecisionType::decimalPlaces;
5720 }
5721 else
5722 {
5723 throwRuntimeError("precisionType must be 'significant' or 'decimal'");
5724 }
5725 String colonSymbol = " : ";
5726 if (eyc)
5727 {
5728 colonSymbol = ": ";
5729 }
5730 else if (indentation.empty())
5731 {
5732 colonSymbol = ":";
5733 }
5734 String nullSymbol = "null";
5735 if (dnp)
5736 {
5737 nullSymbol.clear();
5738 }
5739 if (pre > 17)
5740 pre = 17;
5741 String endingLineFeedSymbol;
5742 return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, nullSymbol, endingLineFeedSymbol,
5743 usf, emitUTF8, pre, precisionType);
5744}
5745
5746bool StreamWriterBuilder::validate(Json::Value *invalid) const

Callers 4

writeFunction · 0.80
writeStringFunction · 0.80
jsoncpp.cppFile · 0.80

Calls 6

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

Tested by

no test coverage detected