| 1141 | StreamWriterBuilder::~StreamWriterBuilder() |
| 1142 | {} |
| 1143 | StreamWriter* StreamWriterBuilder::newStreamWriter() const |
| 1144 | { |
| 1145 | JSONCPP_STRING indentation = settings_["indentation"].asString(); |
| 1146 | JSONCPP_STRING cs_str = settings_["commentStyle"].asString(); |
| 1147 | bool eyc = settings_["enableYAMLCompatibility"].asBool(); |
| 1148 | bool dnp = settings_["dropNullPlaceholders"].asBool(); |
| 1149 | bool usf = settings_["useSpecialFloats"].asBool(); |
| 1150 | unsigned int pre = settings_["precision"].asUInt(); |
| 1151 | CommentStyle::Enum cs = CommentStyle::All; |
| 1152 | if (cs_str == "All") { |
| 1153 | cs = CommentStyle::All; |
| 1154 | } else if (cs_str == "None") { |
| 1155 | cs = CommentStyle::None; |
| 1156 | } else { |
| 1157 | throwRuntimeError("commentStyle must be 'All' or 'None'"); |
| 1158 | } |
| 1159 | JSONCPP_STRING colonSymbol = " : "; |
| 1160 | if (eyc) { |
| 1161 | colonSymbol = ": "; |
| 1162 | } else if (indentation.empty()) { |
| 1163 | colonSymbol = ":"; |
| 1164 | } |
| 1165 | JSONCPP_STRING nullSymbol = "null"; |
| 1166 | if (dnp) { |
| 1167 | nullSymbol.clear(); |
| 1168 | } |
| 1169 | if (pre > 17) pre = 17; |
| 1170 | JSONCPP_STRING endingLineFeedSymbol; |
| 1171 | return new BuiltStyledStreamWriter( |
| 1172 | indentation, cs, |
| 1173 | colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre); |
| 1174 | } |
| 1175 | static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys) |
| 1176 | { |
| 1177 | valid_keys->clear(); |