diff options
Diffstat (limited to 'src/csv.hpp')
| -rw-r--r-- | src/csv.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/csv.hpp b/src/csv.hpp new file mode 100644 index 0000000..485d8a5 --- /dev/null +++ b/src/csv.hpp @@ -0,0 +1,21 @@ +#ifndef CEPIS_SRC_CSV_HPP +#define CEPIS_SRC_CSV_HPP + +#include <string> +#include <string_view> +#include <vector> + +namespace cepis::detail { + +/// Parses RFC 4180 CSV into rows of fields. +/// +/// Values may contain commas, quotes and newlines when double-quoted, with +/// `""` as the escape — splitting on `,` would corrupt exactly the street +/// names most likely to matter. A leading UTF-8 BOM is dropped, `\r\n` and +/// `\n` both end a record, and a trailing newline does not produce an empty +/// final row. +std::vector<std::vector<std::string>> parse_csv(std::string_view text); + +} // namespace cepis::detail + +#endif // CEPIS_SRC_CSV_HPP |