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

◆ write_cell()

bool MayaFlux::IO::DelimitedTextWriter::write_cell ( std::string_view  text,
bool  force_quote 
)
private

Definition at line 315 of file DelimitedTextWriter.cpp.

317{
318 const bool needs_quote = force_quote
319 || text.find(m_active_delimiter) != std::string_view::npos
320 || text.find('"') != std::string_view::npos
321 || text.find('\r') != std::string_view::npos
322 || text.find('\n') != std::string_view::npos;
323
324 if (needs_quote)
325 m_file.put('"');
326
327 if (needs_quote) {
328 for (const char c : text) {
329 if (c == '"')
330 m_file.put('"');
331
332 m_file.put(c);
333 }
334 } else {
335 if (text.size() > static_cast<size_t>(
336 std::numeric_limits<std::streamsize>::max())) {
337 m_last_error = "Delimited text cell exceeds stream size";
338 return false;
339 }
340
341 m_file.write(text.data(), static_cast<std::streamsize>(text.size()));
342 }
343
344 if (needs_quote)
345 m_file.put('"');
346
347 if (!m_file) {
348 m_last_error = "Failed to write delimited text cell";
349 return false;
350 }
351
352 return true;
353}

References m_active_delimiter, m_file, and m_last_error.

Referenced by open(), and write_element().

+ Here is the caller graph for this function: