Stateless utility for parsing CSV files into in-memory records. More...
#include <CSV.hpp>
Static Public Member Functions | |
| static auto | parse (const std::filesystem::path &filename) -> std::vector< std::vector< std::string > > |
| Parses a CSV file from disk into a vector of records. | |
Stateless utility for parsing CSV files into in-memory records.
CSV exposes a single static entry point, parse(), which reads a file from disk and returns its contents as std::vector<std::vector<std::string>>: one inner vector per record (row), each containing the unescaped field values of that record in order.
The underlying grammar (see csv.l / csv.y) follows the RFC 4180 conventions:
CRLF, CR or LF.CR, LF, and double-quote characters represented as a double "")."" becomes a single '' in the returned string, and embedded CR/LF tokens become literal \r/\n characters in the field.CSV has no instance state; both parse() and the private parse_helper() are static. The class exists purely to namespace the parsing entry point and is never instantiated.
|
static |
Parses a CSV file from disk into a vector of records.
Validates that filename exists and refers to a regular file, opens it for reading, and delegates to parse_helper() to run the lexer/parser over the resulting stream.
| filename | Path to the CSV file to parse. |
| std::invalid_argument | if filename does not exist or does not refer to a regular file |
| std::invalid_argument | if the file cannot be opened for reading (e.g. permissions) |
| (parse-defined) | if the file content does not conform to the CSV grammar; parse errors are thrown. |