CSV parser

template<typename HandlerT>
class csv_parser : public orcus::csv::parser_base

Parser for CSV documents.

Template Parameters:

HandlerT – Hanlder type with member functions for event callbacks. Refer to csv_handler.

Public Types

typedef HandlerT handler_type

Public Functions

csv_parser(std::string_view content, handler_type &hdl, const csv::parser_config &config)
void parse()
struct parser_config

Run-time configuration object for csv_parser.

Public Functions

parser_config()

Public Members

std::string delimiters

One or more characters that serve as cell boundaries.

char text_qualifier

A single character used as a text quote value.

bool trim_cell_value

When true, the value of each cell gets trimmed i.e. any leading or trailing white spaces will get ignored.

Parser handler

class csv_handler

Public Functions

inline void begin_parse()

Called when the parser starts parsing a stream.

inline void end_parse()

Called when the parser finishes parsing a stream.

inline void begin_row()

Called at the beginning of every row.

inline void end_row()

Called at the end of every row.

inline void cell(std::string_view value, bool transient)

Called after every cell is parsed.

Parameters:
  • value – cell content.

  • transient – when true, the text content has been converted and is stored in a temporary buffer. In such case, there is no guarantee that the text content remain available after the end of the call. When this value is false, the text content is guaranteed to be valid so long as the original CSV stream content is valid.