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

◆ get_metadata()

std::optional< FileMetadata > MayaFlux::IO::DelimitedTextReader::get_metadata ( ) const
overridevirtual

File metadata and ordered field names, when open.

Implements MayaFlux::IO::FileReader.

Definition at line 312 of file DelimitedTextReader.cpp.

313{
314 if (!is_open() || !m_layout)
315 return std::nullopt;
316
317 FileMetadata metadata;
318 metadata.format = m_active_delimiter == '\t' ? "tsv" : "csv";
319 metadata.mime_type = m_active_delimiter == '\t'
320 ? "text/tab-separated-values"
321 : "text/csv";
322
323 std::error_code error;
324 metadata.file_size = std::filesystem::file_size(m_filepath, error);
325 if (error)
326 metadata.file_size = 0;
327
328 std::vector<std::string> names;
329 names.reserve(m_layout->fields().size());
330 for (const auto& field : m_layout->fields())
331 names.push_back(field.name);
332
333 metadata.attributes.emplace("fields", std::move(names));
334 return metadata;
335}
std::unordered_map< std::string, std::string > metadata
std::string name
Definition VKDevice.cpp:123
bool is_open() const override
Whether a file is currently open.
std::optional< Kakshya::CompositeLayout > m_layout
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.

References MayaFlux::IO::FileMetadata::format, is_open(), m_active_delimiter, m_filepath, m_layout, and metadata.

+ Here is the call graph for this function: