Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
CsvParser Class Reference

#include "lib/stat/csv.hpp"

Description

Parser to split one line of CSV data into fields.

Remarks
iterator-like throw-away object
  • the bool evaluation indicates more fields to extract
  • dereference to get the field as string
  • increment to move to the next field
Exceptions
error::Invalidon CSV format violation

Definition at line 241 of file csv.hpp.

Public Member Functions

 CsvParser ()
 
 CsvParser (string &line)
 
 operator bool () const
 
 ENABLE_USE_IN_STD_RANGE_FOR_LOOPS (CsvParser)
 
string operator* () const
 
void operator++ ()
 
size_t getParsedFieldCnt ()
 
bool isValid () const
 
bool isParseFail () const
 
void fail () const
 
- Public Member Functions inherited from RegexSearchIter
 RegexSearchIter ()=default
 
 RegexSearchIter (string const &toParse, regex const &regex)
 
 RegexSearchIter (string_view toParse, regex const &regex)
 
 operator bool () const
 
bool isValid () const
 
bool empty () const
 
 LIFT_PARENT_INCREMENT_OPERATOR (std::sregex_iterator)
 
 ENABLE_USE_IN_STD_RANGE_FOR_LOOPS (RegexSearchIter)
 

Private Member Functions

util::RegexSearchIter const & curr () const
 
util::RegexSearchIter end () const
 

Private Attributes

string const & line_ {}
 
size_t field_ {0}
 
size_t pos_ {0}
 

Constructor & Destructor Documentation

◆ CsvParser() [1/2]

CsvParser ( )
inline

Definition at line 252 of file csv.hpp.

◆ CsvParser() [2/2]

CsvParser ( string &  line)
inline

Definition at line 256 of file csv.hpp.

Member Function Documentation

◆ curr()

util::RegexSearchIter const & curr ( ) const
inlineprivate

Definition at line 248 of file csv.hpp.

Referenced by CsvParser::fail(), CsvParser::isParseFail(), CsvParser::isValid(), CsvParser::operator*(), and CsvParser::operator++().

+ Here is the caller graph for this function:

◆ end()

util::RegexSearchIter end ( ) const
inlineprivate

Definition at line 249 of file csv.hpp.

Referenced by CsvParser::fail(), CsvParser::isParseFail(), and CsvParser::isValid().

+ Here is the caller graph for this function:

◆ operator bool()

operator bool ( ) const
inlineexplicit

Definition at line 261 of file csv.hpp.

References CsvParser::isValid().

+ Here is the call graph for this function:

◆ ENABLE_USE_IN_STD_RANGE_FOR_LOOPS()

ENABLE_USE_IN_STD_RANGE_FOR_LOOPS ( CsvParser  )

◆ operator*()

string operator* ( ) const
inline

Definition at line 269 of file csv.hpp.

References CsvParser::curr(), CsvParser::fail(), and CsvParser::isValid().

+ Here is the call graph for this function:

◆ operator++()

void operator++ ( )
inline

Definition at line 278 of file csv.hpp.

References CsvParser::curr(), CsvParser::fail(), CsvParser::field_, CsvParser::isValid(), CsvParser::line_, and CsvParser::pos_.

+ Here is the call graph for this function:

◆ getParsedFieldCnt()

size_t getParsedFieldCnt ( )
inline

Definition at line 290 of file csv.hpp.

References CsvParser::field_.

◆ isValid()

bool isValid ( ) const
inline

Definition at line 296 of file csv.hpp.

References CsvParser::curr(), RegexSearchIter::empty(), CsvParser::end(), and CsvParser::pos_.

Referenced by CsvParser::isParseFail(), CsvParser::operator bool(), CsvParser::operator*(), and CsvParser::operator++().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isParseFail()

bool isParseFail ( ) const
inline

Definition at line 304 of file csv.hpp.

References CsvParser::curr(), CsvParser::end(), and CsvParser::isValid().

+ Here is the call graph for this function:

◆ fail()

void fail ( ) const
inline

Definition at line 311 of file csv.hpp.

References CsvParser::curr(), CsvParser::end(), CsvParser::field_, CsvParser::line_, and CsvParser::pos_.

Referenced by CsvParser::operator*(), and CsvParser::operator++().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ line_

string const& line_ {}
private

Definition at line 244 of file csv.hpp.

Referenced by CsvParser::fail(), and CsvParser::operator++().

◆ field_

size_t field_ {0}
private

Definition at line 245 of file csv.hpp.

Referenced by CsvParser::fail(), CsvParser::getParsedFieldCnt(), and CsvParser::operator++().

◆ pos_

size_t pos_ {0}
private

Definition at line 246 of file csv.hpp.

Referenced by CsvParser::fail(), CsvParser::isValid(), and CsvParser::operator++().

+ Inheritance diagram for CsvParser:
+ Collaboration diagram for CsvParser:

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