MCPcopy Create free account
hub / github.com/Cantera/cantera / emitFlowVector

Function emitFlowVector

src/base/AnyMap.cpp:372–388  ·  view source on GitHub ↗

Write a vector in YAML "flow" style, wrapping lines to avoid exceeding the preferred maximum line length (set by `max_line_length`). Specialized for `vector ` to be able to use the custom `formatDouble` function with a given precision.

Source from the content-addressed store, hash-verified

370//! `vector<double>` to be able to use the custom `formatDouble` function with
371//! a given precision.
372void emitFlowVector(YAML::Emitter& out, const vector<double>& v, long int precision)
373{
374 out << YAML::Flow;
375 out << YAML::BeginSeq;
376 size_t width = 15; // wild guess, but no better value is available
377 for (auto& x : v) {
378 string xstr = formatDouble(x, precision);
379 // Wrap to the next line if this item would exceed the target line length
380 if (width + xstr.size() > max_line_length) {
381 out << YAML::Newline;
382 width = 15;
383 }
384 out << xstr;
385 width += xstr.size() + 2; // Update width including comma and space
386 }
387 out << YAML::EndSeq;
388}
389
390//! Write a vector in YAML "flow" style, wrapping lines to avoid exceeding the
391//! preferred maximum line length (set by `max_line_length`). Specialized for

Callers 1

AnyMap.cppFile · 0.85

Calls 3

formatDoubleFunction · 0.85
isFloatFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected