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/io.hh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/io.hh (limited to 'src/io.hh') diff --git a/src/io.hh b/src/io.hh new file mode 100644 index 0000000..315d0bb --- /dev/null +++ b/src/io.hh @@ -0,0 +1,52 @@ +#ifndef IO_HH +#define IO_HH + +#include +#include +#include +#include + +namespace io { + +enum class ReadError { + Error, + InvalidData, // Used by decompress and such +}; + +enum class OpenError { + NoSuchFile, + NoAccess, + Error, +}; + +class Reader { + public: + virtual ~Reader() = default; + + [[nodiscard]] virtual std::expected read(void* dst, + size_t max) = 0; + [[nodiscard]] virtual std::expected skip(size_t max) = 0; + + [[nodiscard]] std::expected read(std::string& str); + + [[nodiscard]] std::expected repeat_read(void* dst, + size_t max); + [[nodiscard]] std::expected repeat_read(std::string& str); + [[nodiscard]] std::expected repeat_skip(size_t max); + + protected: + Reader() = default; + + Reader(Reader const&) = delete; + Reader& operator=(Reader const&) = delete; +}; + +[[nodiscard]] std::expected, OpenError> open( + const std::string& file_path); +[[nodiscard]] std::expected, OpenError> openat( + int dirfd, const std::string& file_path); +[[nodiscard]] std::unique_ptr memory(std::string data); + +} // namespace io + +#endif // IO_HH -- cgit v1.3