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

Abstract base class which provides CSV parsing logic. More...

#include <basic_csv_parser.hpp>

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

Public Member Functions

 IBasicCSVParser (const CSVFormat &, const ColNamesPtr &)
 
 IBasicCSVParser (const ParseFlagMap &parse_flags, const WhitespaceMap &ws_flags)
 
bool eof ()
 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.
 
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
 
CONSTEXPR bool utf8_bom () const
 Whether or not this CSV has a UTF-8 byte order mark.
 
void set_output (RowCollection &rows)
 

Protected Member Functions

virtual std::string & get_csv_head ()=0
 
CONSTEXPR bool no_chunk () const
 Whether or not source needs to be read in chunks.
 
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.
 
void resolve_format_from_head (const CSVFormat &format)
 

Protected Attributes

Current Parser State
CSVRow current_row_
 
RawCSVDataPtr data_ptr_ = nullptr
 
ColNamesPtr col_names_ = nullptr
 
RawCSVFieldListfields_ = 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.
 
Current Stream/File State
bool eof_ = false
 
ResolvedFormat format
 
size_t source_size_ = 0
 The size of the incoming CSV.
 

Detailed Description

Abstract base class which provides CSV parsing logic.

Concrete implementations may customize this logic across different input sources, such as memory mapped files, stringstreams, etc...

Definition at line 177 of file basic_csv_parser.hpp.

Constructor & Destructor Documentation

◆ IBasicCSVParser() [1/2]

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

Definition at line 49 of file basic_csv_parser.cpp.

◆ IBasicCSVParser() [2/2]

csv::internals::IBasicCSVParser::IBasicCSVParser ( const ParseFlagMap parse_flags,
const WhitespaceMap ws_flags 
)
inline

Definition at line 181 of file basic_csv_parser.hpp.

◆ ~IBasicCSVParser()

virtual csv::internals::IBasicCSVParser::~IBasicCSVParser ( )
inlinevirtual

Definition at line 190 of file basic_csv_parser.hpp.

Member Function Documentation

◆ compound_parse_flag()

CONSTEXPR_17 ParseFlags csv::internals::IBasicCSVParser::compound_parse_flag ( const char  ch) const
inlinenoexcept

Definition at line 207 of file basic_csv_parser.hpp.

◆ end_feed()

void csv::internals::IBasicCSVParser::end_feed ( )

Indicate the last block of data has been parsed.

Definition at line 107 of file basic_csv_parser.cpp.

◆ eof()

bool csv::internals::IBasicCSVParser::eof ( )
inline

Whether or not we have reached the end of source.

Definition at line 193 of file basic_csv_parser.hpp.

◆ get_resolved_format()

ResolvedFormat csv::internals::IBasicCSVParser::get_resolved_format ( )
inline

Definition at line 195 of file basic_csv_parser.hpp.

◆ next()

virtual void csv::internals::IBasicCSVParser::next ( size_t  bytes)
pure virtual

Parse the next block of data.

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

◆ no_chunk()

CONSTEXPR bool csv::internals::IBasicCSVParser::no_chunk ( ) const
inlineprotected

Whether or not source needs to be read in chunks.

Definition at line 246 of file basic_csv_parser.hpp.

◆ parse()

size_t csv::internals::IBasicCSVParser::parse ( )
protected

Parse the current chunk of data and return the completed-row prefix length.

Parse the current chunk and return the number of bytes belonging to complete rows.

Definition at line 171 of file basic_csv_parser.cpp.

◆ parse_flag()

CONSTEXPR_17 ParseFlags csv::internals::IBasicCSVParser::parse_flag ( const char  ch) const
inlinenoexcept

Definition at line 203 of file basic_csv_parser.hpp.

◆ reset_data_ptr()

void csv::internals::IBasicCSVParser::reset_data_ptr ( )
protected

Create a new RawCSVDataPtr for a new chunk of data.

Definition at line 269 of file basic_csv_parser.cpp.

◆ resolve_format_from_head()

void csv::internals::IBasicCSVParser::resolve_format_from_head ( const CSVFormat format)
protected

Definition at line 62 of file basic_csv_parser.cpp.

◆ set_output()

void csv::internals::IBasicCSVParser::set_output ( RowCollection rows)
inline

Definition at line 214 of file basic_csv_parser.hpp.

◆ utf8_bom()

CONSTEXPR bool csv::internals::IBasicCSVParser::utf8_bom ( ) const
inline

Whether or not this CSV has a UTF-8 byte order mark.

Definition at line 212 of file basic_csv_parser.hpp.

Member Data Documentation

◆ col_names_

ColNamesPtr csv::internals::IBasicCSVParser::col_names_ = nullptr
protected

Definition at line 221 of file basic_csv_parser.hpp.

◆ current_row_

CSVRow csv::internals::IBasicCSVParser::current_row_
protected

Definition at line 219 of file basic_csv_parser.hpp.

◆ data_ptr_

RawCSVDataPtr csv::internals::IBasicCSVParser::data_ptr_ = nullptr
protected

Definition at line 220 of file basic_csv_parser.hpp.

◆ eof_

bool csv::internals::IBasicCSVParser::eof_ = false
protected

Definition at line 235 of file basic_csv_parser.hpp.

◆ field_length_

size_t csv::internals::IBasicCSVParser::field_length_ = 0
protected

Definition at line 224 of file basic_csv_parser.hpp.

◆ field_start_

int csv::internals::IBasicCSVParser::field_start_ = UNINITIALIZED_FIELD
protected

Definition at line 223 of file basic_csv_parser.hpp.

◆ fields_

RawCSVFieldList* csv::internals::IBasicCSVParser::fields_ = nullptr
protected

Definition at line 222 of file basic_csv_parser.hpp.

◆ format

ResolvedFormat csv::internals::IBasicCSVParser::format
protected

Definition at line 237 of file basic_csv_parser.hpp.

◆ parse_flags_

ParseFlagMap csv::internals::IBasicCSVParser::parse_flags_
protected

An array where the (i + 128)th slot gives the ParseFlags for ASCII character i.

Definition at line 230 of file basic_csv_parser.hpp.

◆ simd_sentinels_

SentinelVecs csv::internals::IBasicCSVParser::simd_sentinels_
protected

Precomputed SIMD broadcast vectors for find_next_non_special.

Definition at line 227 of file basic_csv_parser.hpp.

◆ source_size_

size_t csv::internals::IBasicCSVParser::source_size_ = 0
protected

The size of the incoming CSV.

Definition at line 240 of file basic_csv_parser.hpp.


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