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.
| 370 | //! `vector<double>` to be able to use the custom `formatDouble` function with |
| 371 | //! a given precision. |
| 372 | void 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 |
no test coverage detected