|
csvpp 1.2.0
CSV parsing / writing libraries
|
Map-based Reader iterator. More...
#include <csv.hpp>
Public Member Functions | |
| Map_reader_iter () | |
| Empty constructor. | |
| Map_reader_iter (std::istream &input_stream, const Value &default_val={}, const std::vector< Header > &headers={}, const char delimiter=',', const char quote='"', const bool lenient = false) | |
| Open a std::istream for CSV parsing. | |
| Map_reader_iter (const std::string &filename, const Value &default_val={}, const std::vector< Header > &headers={}, const char delimiter=',', const char quote='"', const bool lenient = false) | |
| Open a file for CSV parsing. | |
| Map_reader_iter (Reader::input_string_t, const std::string &input_data, const Value &default_val={}, const std::vector< Header > &headers={}, const char delimiter=',', const char quote='"', const bool lenient = false) | |
| Parse CSV from memory. | |
| const value_type & | operator* () const |
| value_type & | operator* () |
| const value_type * | operator-> () const |
| value_type * | operator-> () |
| const value_type::mapped_type & | operator[] (const typename value_type::key_type &key) const |
| Get a field from the current row. | |
| value_type::mapped_type & | operator[] (const typename value_type::key_type &key) |
| Map_reader_iter & | operator++ () |
| Iterate to next field. | |
| template<typename Header2 , typename Value2 > | |
| bool | equals (const Map_reader_iter< Header2, Value2 > &rhs) const |
| Compare to another Map_reader_iter. | |
| std::vector< Header > | get_headers () const |
| Get the headers. | |
Map-based Reader iterator.
Iterates through a Reader, returning rows as a std::map. Map keys (headers) come from the first row unless specified by the header parameter to the constructor. If a row has more fields than the header, Out_of_range_error error will be thrown
|
inline |
Empty constructor.
Denotes the end of iteration
|
inlineexplicit |
Open a std::istream for CSV parsing.
| input_stream | std::istream to read from |
| default_val | Value to use if a row has fewer fields than the header |
| headers | List of field names to use. Pass an empty vector to use first (header) row |
| delimiter | Delimiter character |
| quote | Quote character |
| lenient | Enable lenient parsing (will attempt to read past syntax errors) |
| Parse_error | if error parsing fields (only when not parsing in lenient mode) |
| IO_error | if error reading CSV data |
| Type_conversion_error | if error converting 1st row to type Header (if headers param is empty), or 1st row to type Value (if header param is specified) |
|
inlineexplicit |
Open a file for CSV parsing.
| filename | Path to a file to parse |
| default_val | Value to use if a row has fewer fields than the header |
| headers | List of field names to use. Pass an empty vector to use first (header) row |
| delimiter | Delimiter character |
| quote | Quote character |
| lenient | Enable lenient parsing (will attempt to read past syntax errors) |
| Parse_error | if error parsing fields (only when not parsing in lenient mode) |
| IO_error | if error reading CSV data |
| Type_conversion_error | if error converting 1st row to type Header (if headers param is empty), or 1st row to type Value (if header param is specified) |
|
inline |
Parse CSV from memory.
Use Reader::input_string to distinguish this constructor from the constructor accepting a filename
| input_data | String containing CSV to parse |
| default_val | Value to use if a row has fewer fields than the header |
| headers | List of field names to use. Pass an empty vector to use first (header) row |
| delimiter | Delimiter character |
| quote | Quote character |
| lenient | Enable lenient parsing (will attempt to read past syntax errors) |
| Parse_error | if error parsing fields (only when not parsing in lenient mode) |
| IO_error | if error reading CSV data |
| Type_conversion_error | if error converting 1st row to type Header (if headers param not specified), or 1st row to type Value (if header param is specified) |
|
inline |
Get the headers.
|
inline |
|
inline |
Iterate to next field.
| Parse_error | if error parsing fields (only when not parsing in lenient mode) |
| IO_error | if error reading CSV data |
| Type_conversion_error | if error converting fields to Value type |
|
inline |
|
inline |
Get a field from the current row.
This is a shortcut for map_reader_iter->at(key)
| key | Header for the desired field |
| std::out_or_range | if the key is not a valid header |