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

Method newStreamWriter

Utilities/cmjsoncpp/src/lib_json/json_writer.cpp:1167–1208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1165StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
1166StreamWriterBuilder::~StreamWriterBuilder() = default;
1167StreamWriter* StreamWriterBuilder::newStreamWriter() const {
1168 const String indentation = settings_["indentation"].asString();
1169 const String cs_str = settings_["commentStyle"].asString();
1170 const String pt_str = settings_["precisionType"].asString();
1171 const bool eyc = settings_["enableYAMLCompatibility"].asBool();
1172 const bool dnp = settings_["dropNullPlaceholders"].asBool();
1173 const bool usf = settings_["useSpecialFloats"].asBool();
1174 const bool emitUTF8 = settings_["emitUTF8"].asBool();
1175 unsigned int pre = settings_["precision"].asUInt();
1176 CommentStyle::Enum cs = CommentStyle::All;
1177 if (cs_str == "All") {
1178 cs = CommentStyle::All;
1179 } else if (cs_str == "None") {
1180 cs = CommentStyle::None;
1181 } else {
1182 throwRuntimeError("commentStyle must be 'All' or 'None'");
1183 }
1184 PrecisionType precisionType(significantDigits);
1185 if (pt_str == "significant") {
1186 precisionType = PrecisionType::significantDigits;
1187 } else if (pt_str == "decimal") {
1188 precisionType = PrecisionType::decimalPlaces;
1189 } else {
1190 throwRuntimeError("precisionType must be 'significant' or 'decimal'");
1191 }
1192 String colonSymbol = " : ";
1193 if (eyc) {
1194 colonSymbol = ": ";
1195 } else if (indentation.empty()) {
1196 colonSymbol = ":";
1197 }
1198 String nullSymbol = "null";
1199 if (dnp) {
1200 nullSymbol.clear();
1201 }
1202 if (pre > 17)
1203 pre = 17;
1204 String endingLineFeedSymbol;
1205 return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, nullSymbol,
1206 endingLineFeedSymbol, usf, emitUTF8, pre,
1207 precisionType);
1208}
1209
1210bool StreamWriterBuilder::validate(Json::Value* invalid) const {
1211 static const auto& valid_keys = *new std::set<String>{

Callers 14

writeStringFunction · 0.80
json_writer.cppFile · 0.80
cmSpdxSerializerMethod · 0.80
PrintVersionJsonMethod · 0.80
cmGlobalGeneratorMethod · 0.80
cmConfigureLogMethod · 0.80
WritePackageInfoMethod · 0.80
WriteTraceFileMethod · 0.80
TryWriteMethod · 0.80
cmFileAPIMethod · 0.80

Calls 6

throwRuntimeErrorFunction · 0.85
asStringMethod · 0.80
asBoolMethod · 0.80
asUIntMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45

Tested by 1

PrintOutputAsJsonMethod · 0.64