Vince's CSV Parser
Loading...
Searching...
No Matches
csv::internals::parser::CSVParserDriverBase Class Referenceabstract

Abstract base class for source adapters. More...

#include <driver.hpp>

Inherits csv::internals::CSVParserCore< RowSink, ParsePolicy, FieldPolicy, RowPolicy >.

Inherited by csv::internals::parser::MmapParser, and csv::internals::parser::StreamParser< TStream >.

Public Member Functions

 CSVParserDriverBase (const CSVFormat &, const ColNamesPtr &)
 
 CSVParserDriverBase (const ParseFlagMap &parse_flags, const WhitespaceMap &ws_flags)
 
const CSVError & error () const noexcept
 Source errors are read by the consumer only after joining its scheduler.
 
bool eof () const noexcept
 Whether or not we have reached the end of source.
 
ResolvedFormat get_resolved_format ()
 
virtual void next (size_t bytes)=0
 Parse the next block of data.
 
virtual SpeculativeParseDiagnostics speculative_diagnostics () const noexcept
 
virtual size_t parse_worker_count () const noexcept
 
virtual bool utf8_bom () const noexcept
 
- Public Member Functions inherited from csv::internals::CSVParserCore< RowSink, ParsePolicy, FieldPolicy, RowPolicy >
 CSVParserCore (const CSVFormat &source_format, const ColNamesPtr &col_names)
 
 CSVParserCore (const ParseFlagMap &parse_flags, const WhitespaceMap &ws_flags)
 
 CSVParserCore (const ParseFlagMap &parse_flags, const WhitespaceMap &ws_flags, const ColNamesPtr &col_names)
 
void end_feed ()
 Indicate the last block of data has been parsed.
 
CONSTEXPR_17 ParseFlags parse_flag (const char ch) const noexcept
 
CONSTEXPR_17 ParseFlags compound_parse_flag (const char ch) const noexcept
 
void set_output (RowSink &output) noexcept
 
RowSink & output () noexcept
 
void reset_with_initial_state (ParserDFAState state) noexcept
 Seed the DFA state for the next parse call.
 
void reset_with_initial_state (bool starts_in_quoted, bool in_escape=false) noexcept
 Convenience overload for callers that only care about quote state.
 
ParserDFAState ending_state () const noexcept
 Return the DFA state observed when the most recent parse call stopped.
 
ParserChunkResult parse_chunk (csv::string_view chunk, std::shared_ptr< void > owner)
 
ParserChunkResult parse_chunk (csv::string_view chunk, std::shared_ptr< void > owner, const ParserChunkOptions &options)
 
ParserChunkResult parse_chunk (csv::string_view chunk, std::shared_ptr< void > owner, RowSink &output)
 
ParserChunkResult parse_chunk (csv::string_view chunk, std::shared_ptr< void > owner, RowSink &output, size_t source_start)
 
ParserChunkResult parse_chunk (csv::string_view chunk, std::shared_ptr< void > owner, RowSink &output, const ParserChunkOptions &options)
 

Protected Member Functions

virtual std::string & get_csv_head ()=0
 
void resolve_format_from_head (const CSVFormat &format)
 
- Protected Member Functions inherited from csv::internals::CSVParserCore< RowSink, ParsePolicy, FieldPolicy, RowPolicy >
void set_col_names (const ColNamesPtr &col_names)
 
void set_whitespace_flags (const WhitespaceMap &ws_flags)
 
void set_parse_flags (const ParseFlagMap &parse_flags)
 
void set_parse_flags (const ParseFlagMap &parse_flags, char delimiter, char quote_char)
 
size_t parse ()
 Parse the current chunk of data and return the completed-row prefix length.
 
void reset_data_ptr ()
 Create a new RawCSVDataPtr for a new chunk of data.
 
const WhitespaceMap & whitespace_flags () const noexcept
 
void emit_row (CSVRow &&row)
 

Protected Attributes

std::unique_ptr< ICSVParseOrchestrator > parse_orchestrator_
 
Current Stream/File State
bool eof_ = false
 
CSVError error_
 
ResolvedFormat format
 
size_t source_size_ = 0
 The size of the incoming CSV.
 
- Protected Attributes inherited from csv::internals::CSVParserCore< RowSink, ParsePolicy, FieldPolicy, RowPolicy >
CSVRow current_row_
 
RawCSVDataPtr data_ptr_ = nullptr
 
ColNamesPtr col_names_ = nullptr
 
RawCSVFieldList * fields_ = nullptr
 
int field_start_ = UNINITIALIZED_FIELD
 
size_t field_length_ = 0
 
SentinelVecs simd_sentinels_
 Precomputed SIMD broadcast vectors for find_next_non_special.
 
ParseFlagMap parse_flags_
 An array where the (i + 128)th slot gives the ParseFlags for ASCII character i.
 

Detailed Description

Abstract base class for source adapters.

It preserves the existing parser API while delegating byte-level parsing to CSVParserCore.

Definition at line 182 of file driver.hpp.

Constructor & Destructor Documentation

◆ CSVParserDriverBase() [1/2]

csv::internals::parser::CSVParserDriverBase::CSVParserDriverBase ( const CSVFormat &  source_format,
const ColNamesPtr &  col_names 
)

Definition at line 98 of file driver.cpp.

◆ CSVParserDriverBase() [2/2]

csv::internals::parser::CSVParserDriverBase::CSVParserDriverBase ( const ParseFlagMap &  parse_flags,
const WhitespaceMap &  ws_flags 
)
inline

Definition at line 186 of file driver.hpp.

◆ ~CSVParserDriverBase()

virtual csv::internals::parser::CSVParserDriverBase::~CSVParserDriverBase ( )
inlinevirtual

Definition at line 191 of file driver.hpp.

Member Function Documentation

◆ eof()

bool csv::internals::parser::CSVParserDriverBase::eof ( ) const
inlinenoexcept

Whether or not we have reached the end of source.

Definition at line 197 of file driver.hpp.

◆ error()

const CSVError & csv::internals::parser::CSVParserDriverBase::error ( ) const
inlinenoexcept

Source errors are read by the consumer only after joining its scheduler.

Definition at line 194 of file driver.hpp.

◆ get_resolved_format()

ResolvedFormat csv::internals::parser::CSVParserDriverBase::get_resolved_format ( )
inline

Definition at line 199 of file driver.hpp.

◆ next()

virtual void csv::internals::parser::CSVParserDriverBase::next ( size_t  bytes)
pure virtual

Parse the next block of data.

Implemented in csv::internals::parser::MmapParser, and csv::internals::parser::StreamParser< TStream >.

◆ parse_worker_count()

virtual size_t csv::internals::parser::CSVParserDriverBase::parse_worker_count ( ) const
inlinevirtualnoexcept

Definition at line 210 of file driver.hpp.

◆ resolve_format_from_head()

void csv::internals::parser::CSVParserDriverBase::resolve_format_from_head ( const CSVFormat &  format)
protected

Definition at line 103 of file driver.cpp.

◆ speculative_diagnostics()

virtual SpeculativeParseDiagnostics csv::internals::parser::CSVParserDriverBase::speculative_diagnostics ( ) const
inlinevirtualnoexcept

Definition at line 204 of file driver.hpp.

◆ utf8_bom()

virtual bool csv::internals::parser::CSVParserDriverBase::utf8_bom ( ) const
inlinevirtualnoexcept

Definition at line 216 of file driver.hpp.

Member Data Documentation

◆ eof_

bool csv::internals::parser::CSVParserDriverBase::eof_ = false
protected

Definition at line 225 of file driver.hpp.

◆ error_

CSVError csv::internals::parser::CSVParserDriverBase::error_
protected

Definition at line 226 of file driver.hpp.

◆ format

ResolvedFormat csv::internals::parser::CSVParserDriverBase::format
protected

Definition at line 228 of file driver.hpp.

◆ parse_orchestrator_

std::unique_ptr<ICSVParseOrchestrator> csv::internals::parser::CSVParserDriverBase::parse_orchestrator_
protected

Definition at line 234 of file driver.hpp.

◆ source_size_

size_t csv::internals::parser::CSVParserDriverBase::source_size_ = 0
protected

The size of the incoming CSV.

Definition at line 231 of file driver.hpp.


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