14#include <unordered_map>
19#include "col_names.hpp"
69 _block_capacity = (
max_fields + _single_buffer_capacity - 1) / _single_buffer_capacity;
70 _blocks = std::unique_ptr<RawCSVField*[]>(
new RawCSVField*[_block_capacity]());
80 _single_buffer_capacity(
other._single_buffer_capacity),
81 _block_capacity(
other._block_capacity) {
83 this->_blocks = std::move(
other._blocks);
84 this->_owned_blocks = std::move(
other._owned_blocks);
85 _current_buffer_size =
other._current_buffer_size;
86 _current_block =
other._current_block;
97 other._back =
nullptr;
98 other._current_buffer_size = 0;
99 other._current_block = 0;
100 other._block_capacity = 0;
103 template <
class...
Args>
105 if (this->_current_buffer_size == this->_single_buffer_capacity) {
110 *(_back++) = RawCSVField(std::forward<Args>(
args)...);
111 _current_buffer_size++;
115 return this->_current_buffer_size + (_current_block * this->_single_buffer_capacity);
118 RawCSVField& operator[](
size_t n)
const;
121 const size_t _single_buffer_capacity;
125 std::unique_ptr<RawCSVField*[]> _blocks =
nullptr;
128 std::vector<std::unique_ptr<RawCSVField[]>> _owned_blocks = {};
133 size_t _current_buffer_size = 0;
136 size_t _current_block = 0;
139 size_t _block_capacity = 0;
142 RawCSVField* _back =
nullptr;
154 std::shared_ptr<void> _data =
nullptr;
166 internals::ColNamesPtr col_names =
nullptr;
171 using RawCSVDataPtr = std::shared_ptr<RawCSVData>;
A class used for efficiently storing RawCSVField objects and expanding as necessary.
CSVFieldList(size_t single_buffer_capacity=(size_t)(internals::PAGE_SIZE/sizeof(RawCSVField)))
Construct a CSVFieldList which allocates blocks of a certain size.
A standalone header file containing shared code.
std::array< ParseFlags, 256 > ParseFlagMap
An array which maps ASCII chars to a parsing flag.
std::array< bool, 256 > WhitespaceMap
An array which maps ASCII chars to a flag indicating if it is whitespace.
constexpr size_t ITERATION_CHUNK_SIZE
Chunk size for lazy-loading large CSV files.
const int PAGE_SIZE
Size of a memory page in bytes.
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.
nonstd::string_view string_view
The string_view class used by this library.
A class for storing raw CSV data and associated metadata.
std::mutex double_quote_init_lock
Protects lazy initialization only.
std::unordered_map< size_t, std::string > double_quote_fields
Cached unescaped field values for fields with escaped quotes.
A barebones class used for describing CSV fields.
size_t start
The start of the field, relative to the beginning of the row.
bool has_double_quote
Whether or not the field contains an escaped quote.
size_t length
The length of the row, ignoring quote escape characters.