| 4739 | } |
| 4740 | StreamWriterBuilder::~StreamWriterBuilder() {} |
| 4741 | StreamWriter* StreamWriterBuilder::newStreamWriter() const { |
| 4742 | std::string indentation = settings_["indentation"].asString(); |
| 4743 | std::string cs_str = settings_["commentStyle"].asString(); |
| 4744 | bool eyc = settings_["enableYAMLCompatibility"].asBool(); |
| 4745 | bool dnp = settings_["dropNullPlaceholders"].asBool(); |
| 4746 | bool usf = settings_["useSpecialFloats"].asBool(); |
| 4747 | CommentStyle::Enum cs = CommentStyle::All; |
| 4748 | if (cs_str == "All") { |
| 4749 | cs = CommentStyle::All; |
| 4750 | } else if (cs_str == "None") { |
| 4751 | cs = CommentStyle::None; |
| 4752 | } else { |
| 4753 | throwRuntimeError("commentStyle must be 'All' or 'None'"); |
| 4754 | } |
| 4755 | std::string colonSymbol = " : "; |
| 4756 | if (eyc) { |
| 4757 | colonSymbol = ": "; |
| 4758 | } else if (indentation.empty()) { |
| 4759 | colonSymbol = ":"; |
| 4760 | } |
| 4761 | std::string nullSymbol = "null"; |
| 4762 | if (dnp) { |
| 4763 | nullSymbol = ""; |
| 4764 | } |
| 4765 | std::string endingLineFeedSymbol = ""; |
| 4766 | return new BuiltStyledStreamWriter( |
| 4767 | indentation, cs, |
| 4768 | colonSymbol, nullSymbol, endingLineFeedSymbol, usf); |
| 4769 | } |
| 4770 | static void getValidWriterKeys(std::set<std::string>* valid_keys) { |
| 4771 | valid_keys->clear(); |
| 4772 | valid_keys->insert("indentation"); |
no test coverage detected