Vince's CSV Parser
Loading...
Searching...
No Matches
csv::internals::CSVFieldList Class Reference

A class used for efficiently storing RawCSVField objects and expanding as necessary. More...

#include <raw_csv_data.hpp>

Public Member Functions

 CSVFieldList (size_t single_buffer_capacity=(size_t)(internals::PAGE_SIZE/sizeof(RawCSVField)))
 Construct a CSVFieldList which allocates blocks of a certain size.
 
 CSVFieldList (const CSVFieldList &other)=delete
 
 CSVFieldList (CSVFieldList &&other)
 
template<class... Args>
void emplace_back (Args &&... args)
 
size_t size () const noexcept
 
RawCSVFieldoperator[] (size_t n) const
 

Detailed Description

A class used for efficiently storing RawCSVField objects and expanding as necessary.

Implementation
Uses std::deque<unique_ptr<RawCSVField[]>> instead of std::deque<RawCSVField> for performance. This design keeps adjacent fields in page-aligned chunks (~170 fields/chunk), providing better cache locality when accessing sequential fields in a row.

Standard std::deque uses smaller, implementation-defined chunks which increases pointer indirection and reduces cache efficiency for CSV parsing workloads.

Thread Safety
Cross-thread visibility is provided by the records queue mutex in ThreadSafeDeque: the writer enqueues a RawCSVData only after all fields are written, and the reader dequeues it only after the mutex unlock/lock pair, which is a full happens-before edge. No additional atomics are needed here.
Historical Bug (Issue #278, fixed Feb 2026)
Move constructor previously left _back pointing to moved-from buffer memory, causing memory corruption on next emplace_back(). Now properly recalculates _back pointer to point into the new buffers after move.

Definition at line 63 of file raw_csv_data.hpp.

Constructor & Destructor Documentation

◆ CSVFieldList() [1/2]

csv::internals::CSVFieldList::CSVFieldList ( size_t  single_buffer_capacity = (size_t)(internals::PAGE_SIZE / sizeof(RawCSVField)))
inline

Construct a CSVFieldList which allocates blocks of a certain size.

Definition at line 66 of file raw_csv_data.hpp.

◆ CSVFieldList() [2/2]

csv::internals::CSVFieldList::CSVFieldList ( CSVFieldList &&  other)
inline

Definition at line 79 of file raw_csv_data.hpp.

Member Function Documentation

◆ emplace_back()

template<class... Args>
void csv::internals::CSVFieldList::emplace_back ( Args &&...  args)
inline

Definition at line 104 of file raw_csv_data.hpp.

◆ operator[]()

RawCSVField & csv::internals::CSVFieldList::operator[] ( size_t  n) const

Definition at line 11 of file raw_csv_data.cpp.

◆ size()

size_t csv::internals::CSVFieldList::size ( ) const
inlinenoexcept

Definition at line 114 of file raw_csv_data.hpp.


The documentation for this class was generated from the following files: