| 5285 | StreamWriterBuilder::~StreamWriterBuilder() |
| 5286 | {} |
| 5287 | StreamWriter* StreamWriterBuilder::newStreamWriter() const |
| 5288 | { |
| 5289 | JSONCPP_STRING indentation = settings_["indentation"].asString(); |
| 5290 | JSONCPP_STRING cs_str = settings_["commentStyle"].asString(); |
| 5291 | bool eyc = settings_["enableYAMLCompatibility"].asBool(); |
| 5292 | bool dnp = settings_["dropNullPlaceholders"].asBool(); |
| 5293 | bool usf = settings_["useSpecialFloats"].asBool(); |
| 5294 | unsigned int pre = settings_["precision"].asUInt(); |
| 5295 | CommentStyle::Enum cs = CommentStyle::All; |
| 5296 | if (cs_str == "All") { |
| 5297 | cs = CommentStyle::All; |
| 5298 | } else if (cs_str == "None") { |
| 5299 | cs = CommentStyle::None; |
| 5300 | } else { |
| 5301 | throwRuntimeError("commentStyle must be 'All' or 'None'"); |
| 5302 | } |
| 5303 | JSONCPP_STRING colonSymbol = " : "; |
| 5304 | if (eyc) { |
| 5305 | colonSymbol = ": "; |
| 5306 | } else if (indentation.empty()) { |
| 5307 | colonSymbol = ":"; |
| 5308 | } |
| 5309 | JSONCPP_STRING nullSymbol = "null"; |
| 5310 | if (dnp) { |
| 5311 | nullSymbol.clear(); |
| 5312 | } |
| 5313 | if (pre > 17) pre = 17; |
| 5314 | JSONCPP_STRING endingLineFeedSymbol; |
| 5315 | return new BuiltStyledStreamWriter( |
| 5316 | indentation, cs, |
| 5317 | colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre); |
| 5318 | } |
| 5319 | static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys) |
| 5320 | { |
| 5321 | valid_keys->clear(); |