MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write_element()

bool MayaFlux::IO::DelimitedTextWriter::write_element ( const Kakshya::Composite &  element)
private

Definition at line 355 of file DelimitedTextWriter.cpp.

357{
358 const auto& fields = m_layout->fields();
359
360 for (size_t i = 0; i < fields.size(); ++i) {
361 if (i != 0)
363
364 const auto& field = fields[i];
365 if (!element.has(field.name))
366 continue;
367
368 if (field.type == typeid(std::string)) {
369 const auto text = element.text(field.name);
370
371 if (!text || !write_cell(*text, text->empty())) {
372 if (m_last_error.empty())
373 m_last_error = "Invalid text field: " + field.name;
374 return false;
375 }
376 } else {
377 const auto text = format_field(element, field);
378
379 if (!text || !write_cell(*text, false)) {
380 if (m_last_error.empty())
381 m_last_error = "Invalid numeric field: " + field.name;
382 return false;
383 }
384 }
385 }
386
387 m_file.put('\n');
388
389 if (!m_file) {
390 m_last_error = "Failed to write delimited text element";
391 return false;
392 }
393
394 return true;
395}
bool write_cell(std::string_view text, bool force_quote)
std::optional< Kakshya::CompositeLayout > m_layout

References MayaFlux::Kakshya::Composite::has(), m_active_delimiter, m_file, m_last_error, m_layout, MayaFlux::Kakshya::Composite::text(), and write_cell().

Referenced by write_rows().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: