| 638 | } |
| 639 | StreamWriterBuilder::~StreamWriterBuilder() = default; |
| 640 | StreamWriter* StreamWriterBuilder::newStreamWriter() const { |
| 641 | const StringContainer indentation = settings_["indentation"].asString(); |
| 642 | const StringContainer cs_str = settings_["commentStyle"].asString(); |
| 643 | const StringContainer pt_str = settings_["precisionType"].asString(); |
| 644 | const bool eyc = settings_["enableYAMLCompatibility"].asBool(); |
| 645 | const bool dnp = settings_["dropNullPlaceholders"].asBool(); |
| 646 | const bool usf = settings_["useSpecialFloats"].asBool(); |
| 647 | const bool emitUTF8 = settings_["emitUTF8"].asBool(); |
| 648 | unsigned int pre = settings_["precision"].asUInt(); |
| 649 | CommentStyle::Enum cs = CommentStyle::All; |
| 650 | if (cs_str == "All") { |
| 651 | cs = CommentStyle::All; |
| 652 | } else if (cs_str == "None") { |
| 653 | cs = CommentStyle::None; |
| 654 | } else { |
| 655 | throwRuntimeError("commentStyle must be 'All' or 'None'"); |
| 656 | } |
| 657 | PrecisionType precisionType(significantDigits); |
| 658 | if (pt_str == "significant") { |
| 659 | precisionType = PrecisionType::significantDigits; |
| 660 | } else if (pt_str == "decimal") { |
| 661 | precisionType = PrecisionType::decimalPlaces; |
| 662 | } else { |
| 663 | throwRuntimeError("precisionType must be 'significant' or 'decimal'"); |
| 664 | } |
| 665 | |
| 666 | StringContainer colonSymbol = (!eyc && indentation.empty() ? ":" : ": "); |
| 667 | |
| 668 | if (pre > 17) |
| 669 | pre = 17; |
| 670 | |
| 671 | return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, {}, usf, emitUTF8, pre, precisionType, dnp); |
| 672 | } |
| 673 | |
| 674 | bool StreamWriterBuilder::validate(Json::Value* invalid) const { |
| 675 | #ifdef JSONCPP_HAS_STRING_VIEW |
no test coverage detected