MCPcopy Create free account
hub / github.com/Kitware/VTK / newStreamWriter

Method newStreamWriter

ThirdParty/jsoncpp/vtkjsoncpp/jsoncpp.cpp:5255–5296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5253StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
5254StreamWriterBuilder::~StreamWriterBuilder() = default;
5255StreamWriter* StreamWriterBuilder::newStreamWriter() const {
5256 const String indentation = settings_["indentation"].asString();
5257 const String cs_str = settings_["commentStyle"].asString();
5258 const String pt_str = settings_["precisionType"].asString();
5259 const bool eyc = settings_["enableYAMLCompatibility"].asBool();
5260 const bool dnp = settings_["dropNullPlaceholders"].asBool();
5261 const bool usf = settings_["useSpecialFloats"].asBool();
5262 const bool emitUTF8 = settings_["emitUTF8"].asBool();
5263 unsigned int pre = settings_["precision"].asUInt();
5264 CommentStyle::Enum cs = CommentStyle::All;
5265 if (cs_str == "All") {
5266 cs = CommentStyle::All;
5267 } else if (cs_str == "None") {
5268 cs = CommentStyle::None;
5269 } else {
5270 throwRuntimeError("commentStyle must be 'All' or 'None'");
5271 }
5272 PrecisionType precisionType(significantDigits);
5273 if (pt_str == "significant") {
5274 precisionType = PrecisionType::significantDigits;
5275 } else if (pt_str == "decimal") {
5276 precisionType = PrecisionType::decimalPlaces;
5277 } else {
5278 throwRuntimeError("precisionType must be 'significant' or 'decimal'");
5279 }
5280 String colonSymbol = " : ";
5281 if (eyc) {
5282 colonSymbol = ": ";
5283 } else if (indentation.empty()) {
5284 colonSymbol = ":";
5285 }
5286 String nullSymbol = "null";
5287 if (dnp) {
5288 nullSymbol.clear();
5289 }
5290 if (pre > 17)
5291 pre = 17;
5292 String endingLineFeedSymbol;
5293 return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, nullSymbol,
5294 endingLineFeedSymbol, usf, emitUTF8, pre,
5295 precisionType);
5296}
5297
5298bool StreamWriterBuilder::validate(Json::Value* invalid) const {
5299 static const auto& valid_keys = *new std::set<String>{

Callers 7

WriteDataMethod · 0.80
PrintSelfMethod · 0.80
writeStringFunction · 0.80
jsoncpp.cppFile · 0.80
WriteBufferMethod · 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