MCPcopy Create free account
hub / github.com/apache/trafficserver / ComputeStringFormat

Function ComputeStringFormat

lib/yamlcpp/src/emitterutils.cpp:270–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268} // namespace
269
270StringFormat::value ComputeStringFormat(const std::string& str,
271 EMITTER_MANIP strFormat,
272 FlowType::value flowType,
273 bool escapeNonAscii) {
274 switch (strFormat) {
275 case Auto:
276 if (IsValidPlainScalar(str, flowType, escapeNonAscii)) {
277 return StringFormat::Plain;
278 }
279 return StringFormat::DoubleQuoted;
280 case SingleQuoted:
281 if (IsValidSingleQuotedScalar(str, escapeNonAscii)) {
282 return StringFormat::SingleQuoted;
283 }
284 return StringFormat::DoubleQuoted;
285 case DoubleQuoted:
286 return StringFormat::DoubleQuoted;
287 case Literal:
288 if (IsValidLiteralScalar(str, flowType, escapeNonAscii)) {
289 return StringFormat::Literal;
290 }
291 return StringFormat::DoubleQuoted;
292 default:
293 break;
294 }
295
296 return StringFormat::DoubleQuoted;
297}
298
299bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str) {
300 out << "'";

Callers 1

emitter.cppFile · 0.85

Calls 3

IsValidPlainScalarFunction · 0.85
IsValidLiteralScalarFunction · 0.85

Tested by

no test coverage detected