Vince's CSV Parser
Loading...
Searching...
No Matches
raw_csv_data.cpp
Go to the documentation of this file.
1
5#include "raw_csv_data.hpp"
6
7#include <cassert>
8
9namespace csv {
10 namespace internals {
11 CSV_INLINE RawCSVField& CSVFieldList::operator[](size_t n) const {
12 const size_t page_no = n / _single_buffer_capacity;
13 const size_t buffer_idx = n % _single_buffer_capacity;
14
15 assert(page_no < _block_capacity);
16 RawCSVField* block = this->_blocks[page_no];
17 assert(block != nullptr);
18 return block[buffer_idx];
19 }
20
21 CSV_INLINE void CSVFieldList::allocate() {
22 if (_back != nullptr) {
23 _current_block++;
24 }
25
26 assert(_current_block < _block_capacity);
27
28 std::unique_ptr<RawCSVField[]> block(new RawCSVField[_single_buffer_capacity]);
29 RawCSVField* block_ptr = block.get();
30 this->_owned_blocks.push_back(std::move(block));
31
32 this->_blocks[_current_block] = block_ptr;
33 _current_buffer_size = 0;
34 _back = block_ptr;
35 }
36 }
37}
#define CSV_INLINE
Helper macro which should be #defined as "inline" in the single header version.
Definition common.hpp:26
CSV_CONST CONSTEXPR_17 OutArray arrayToDefault(T &&value)
Helper constexpr function to initialize an array with all the elements set to value.
The all encompassing namespace.
Internal data structures for CSV parsing.