Skip to content

Commit c05b6b3

Browse files
committed
CSVRow::current_row_start(): track row start position of input stream
1 parent 985966e commit c05b6b3

File tree

7 files changed

+1108
-1026
lines changed

7 files changed

+1108
-1026
lines changed

include/internal/basic_csv_parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ namespace csv {
235235
this->field_start = UNINITIALIZED_FIELD;
236236
this->field_length = 0;
237237
this->reset_data_ptr();
238+
this->data_ptr->_stream_pos = this->mmap_pos;
238239

239240
// Create memory map
240241
size_t length = std::min(this->source_size - this->mmap_pos, bytes);

include/internal/basic_csv_parser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ namespace csv {
321321
if (this->eof()) return;
322322

323323
this->reset_data_ptr();
324+
this->data_ptr->_stream_pos = this->stream_pos;
324325
this->data_ptr->_data = std::make_shared<std::string>();
325326

326327
if (source_size == 0) {

include/internal/csv_row.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ namespace csv {
130130
internals::ColNamesPtr col_names = nullptr;
131131
internals::ParseFlagMap parse_flags;
132132
internals::WhitespaceMap ws_flags;
133+
134+
/** where in Stream we start */
135+
uint64_t _stream_pos = {};
133136
};
134137

135138
using RawCSVDataPtr = std::shared_ptr<RawCSVData>;
@@ -318,6 +321,9 @@ namespace csv {
318321
/** Return the number of fields in this row */
319322
CONSTEXPR size_t size() const noexcept { return row_length; }
320323

324+
/** Where in the Stream we start */
325+
size_t current_row_start() const { return data->_stream_pos + data_start; }
326+
321327
/** @name Value Retrieval */
322328
///@{
323329
CSVField operator[](size_t n) const;

0 commit comments

Comments
 (0)