13#if !defined(CSV_ENABLE_THREADS) || CSV_ENABLE_THREADS
16#include <unordered_map>
21#include "col_names.hpp"
71 _block_capacity = (
max_fields + _single_buffer_capacity - 1) / _single_buffer_capacity;
72 _blocks = std::unique_ptr<RawCSVField*[]>(
new RawCSVField*[_block_capacity]());
82 _single_buffer_capacity(
other._single_buffer_capacity),
83 _block_capacity(
other._block_capacity) {
85 this->_blocks = std::move(
other._blocks);
86 this->_owned_blocks = std::move(
other._owned_blocks);
87 _current_buffer_size =
other._current_buffer_size;
88 _current_block =
other._current_block;
99 other._back =
nullptr;
100 other._current_buffer_size = 0;
101 other._current_block = 0;
102 other._block_capacity = 0;
105 template <
class...
Args>
107 if (this->_current_buffer_size == this->_single_buffer_capacity) {
112 *(_back++) = RawCSVField(std::forward<Args>(
args)...);
113 _current_buffer_size++;
117 return this->_current_buffer_size + (_current_block * this->_single_buffer_capacity);
120 RawCSVField& operator[](
size_t n)
const;
123 const size_t _single_buffer_capacity;
127 std::unique_ptr<RawCSVField*[]> _blocks =
nullptr;
130 std::vector<std::unique_ptr<RawCSVField[]>> _owned_blocks = {};
135 size_t _current_buffer_size = 0;
138 size_t _current_block = 0;
141 size_t _block_capacity = 0;
144 RawCSVField* _back =
nullptr;
156 std::shared_ptr<void> _data =
nullptr;
166#if CSV_ENABLE_THREADS
170 internals::ColNamesPtr col_names =
nullptr;
175 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::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.