20#ifndef DOXYGEN_SHOULD_SKIP_THIS
30 while (getline(*_instream_, _line_)) {
33 if (_line_.size() == std::size_t(0))
continue;
36 std::size_t lastPos = _line_.find_first_not_of(_spaces_, std::size_t(0));
38 if (lastPos == std::string::npos)
continue;
40 if (_line_.at(lastPos) == _commentMarker_)
continue;
51 INLINE std::size_t CSVParser::_correspondingQuoteMarker_(
const std::string& str,
52 std::size_t pos)
const {
53 std::size_t res = pos, before;
56 res = str.find_first_of(_quoteMarker_, res + 1);
58 if (res == std::string::npos)
return res;
60 before = str.find_last_not_of(
'\\', res - 1);
62 if (before == std::string::npos)
return res;
64 if ((res - before) % 2 == 1)
73 if (_emptyData_)
GUM_ERROR(NullElement,
"No parsed data")
81 if (_nbLine_ == 0)
GUM_ERROR(NullElement,
"No parsed data")
Class for fast parsing of CSV file (never more than one line in application memory).
CSVParser(std::istream &in, const std::string &filename, const std::string &delimiter=",", const char commentmarker='#', const char quoteMarker='"')
default constructor
bool next()
gets the next line of the csv stream and parses it
std::size_t nbLine() const
returns the current line number within the stream
const std::vector< std::string > & current() const
returns the current parsed line
#define GUM_ERROR(type, msg)
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities