From 32e14551a90e85000e41b3f0445d34d58a1431e4 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 10 Sep 2025 22:12:22 +0200 Subject: Add unicode general category lookup Generate the lookup tables from UnicodeData.txt, do to that, add gen_ugc, which uses csv, buffers, line, io and other modules to do the job. --- src/csv.hh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/csv.hh (limited to 'src/csv.hh') diff --git a/src/csv.hh b/src/csv.hh new file mode 100644 index 0000000..8c47ceb --- /dev/null +++ b/src/csv.hh @@ -0,0 +1,44 @@ +#ifndef CSV_HH +#define CSV_HH + +#include "io.hh" // IWYU pragma: export +#include "line.hh" + +#include +#include +#include +#include + +namespace csv { + +// Note that this reader is very simple, no quotes or escapes. +// Empty lines are ignored. +class Reader { + public: + virtual ~Reader() = default; + + // Returned span is only valid until next call to read. + // Returns empty span at end-of-file and only then. + [[nodiscard]] + virtual std::expected, io::ReadError> read() = 0; + + // Starts at zero. Returns next line. + // So, before first read it is zero, after first read it is one. + [[nodiscard]] virtual uint64_t number() const = 0; + + protected: + Reader() = default; + + Reader(Reader const&) = delete; + Reader& operator=(Reader const&) = delete; +}; + +[[nodiscard]] std::unique_ptr open(std::unique_ptr reader, + char separator = ','); + +[[nodiscard]] std::unique_ptr open(std::unique_ptr reader, + char separator = ','); + +} // namespace csv + +#endif // CSV_HH -- cgit v1.3