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

◆ seek()

bool MayaFlux::IO::DelimitedTextReader::seek ( const std::vector< uint64_t > &  position)
overridevirtual

Seek to a zero-based data record by replaying from the first.

Parameters
positionOne record index.
Returns
False for an invalid or out-of-range position.
Note
On an out-of-range position, the reader is left at the end of file (get_read_position() reflects how far the replay reached, and subsequent read_next() calls return an empty array), not at an undefined position.

Implements MayaFlux::IO::FileReader.

Definition at line 375 of file DelimitedTextReader.cpp.

377{
378 if (!is_open() || position.size() != 1) {
379 m_last_error = "Seek requires one record position in an open file";
380 return false;
381 }
382 m_file.clear();
383 m_file.seekg(m_data_start);
384 m_row_position = 0;
385 m_at_end = false;
386
387 std::vector<ParsedField> fields;
388
389 while (m_row_position < position[0]) {
390 bool at_end = false;
391
392 if (!read_record(fields, at_end))
393 return false;
394
395 if (at_end) {
396 m_at_end = true;
397 m_last_error = "Seek position is past the end of the file";
398 return false;
399 }
400
402 }
403
404 m_last_error.clear();
405 return true;
406}
std::optional< glm::vec3 > position
Definition Decoder.cpp:93
bool read_record(std::vector< ParsedField > &fields, bool &at_end)
bool is_open() const override
Whether a file is currently open.

References MayaFlux::Kakshya::CompositeArray::clear(), is_open(), m_at_end, m_data_start, m_file, MayaFlux::IO::CompositeReader::m_last_error, m_row_position, position, and read_record().

+ Here is the call graph for this function: