Skip to content

Commit 21ff5cb

Browse files
committed
CSVRow::current_row_start(): track row start position of input stream
1 parent 9f8a721 commit 21ff5cb

File tree

7 files changed

+2708
-2626
lines changed

7 files changed

+2708
-2626
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
@@ -136,6 +136,9 @@ namespace csv {
136136
internals::ColNamesPtr col_names = nullptr;
137137
internals::ParseFlagMap parse_flags;
138138
internals::WhitespaceMap ws_flags;
139+
140+
/** where in Stream we start */
141+
uint64_t _stream_pos = {};
139142
};
140143

141144
using RawCSVDataPtr = std::shared_ptr<RawCSVData>;
@@ -324,6 +327,9 @@ namespace csv {
324327
/** Return the number of fields in this row */
325328
CONSTEXPR size_t size() const noexcept { return row_length; }
326329

330+
/** Where in the Stream we start */
331+
size_t current_row_start() const { return data->_stream_pos + data_start; }
332+
327333
/** @name Value Retrieval */
328334
///@{
329335
CSVField operator[](size_t n) const;

0 commit comments

Comments
 (0)