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

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

#include <raw_csv_data.hpp>

Public Member Functions

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

Detailed Description

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

Implementation
Stores fields in page-aligned chunks (~170 fields/chunk) via a vector of unique_ptr<RawCSVField[]>:
  • This design provides better cache locality when accessing sequential fields in a row as well as much lower memory allocation overhead.
  • The unique_ptr ensures STL container does not invalidate pointers to fields when resizing, which is critical to ensure memory safety and correctness of the parser.
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(). Fixed by recalculating _back from _owned_blocks after move.

Definition at line 65 of file raw_csv_data.hpp.

Constructor & Destructor Documentation

◆ RawCSVFieldList() [1/2]

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

Construct a RawCSVFieldList which allocates blocks of a certain size.

Definition at line 68 of file raw_csv_data.hpp.

◆ RawCSVFieldList() [2/2]

csv::internals::RawCSVFieldList::RawCSVFieldList ( RawCSVFieldList &&  other)
inlinenoexcept

Definition at line 81 of file raw_csv_data.hpp.

Member Function Documentation

◆ emplace_back()

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

Definition at line 102 of file raw_csv_data.hpp.

◆ operator[]()

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

Access a field by its index.

This allows CSVRow objects to access fields without knowing internal implementation details of RawCSVFieldList.

Definition at line 119 of file raw_csv_data.hpp.

◆ size()

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

Definition at line 112 of file raw_csv_data.hpp.


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