diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2025-01-02 16:27:56 -0600 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2025-01-02 16:27:56 -0600 |
commit | 8f12614f2da8221438a3807b1d234517650fbdb6 (patch) | |
tree | 18b4aebe99b1d64628546ca5811c10aeb139f1e7 /source/fud_csv.cpp | |
parent | 87071200872c2450c947047350132aee493033c1 (diff) |
Clang tidy fixes.
Diffstat (limited to 'source/fud_csv.cpp')
-rw-r--r-- | source/fud_csv.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/source/fud_csv.cpp b/source/fud_csv.cpp index 198aeca..e1ecf72 100644 --- a/source/fud_csv.cpp +++ b/source/fud_csv.cpp @@ -43,41 +43,55 @@ Csv Csv::make(Allocator& entryAllocator, Allocator& bufferAllocator) return csv; } -FudStatus Csv::parseFromFilename( +FudStatus Csv::parseFromFilenameUnbuffered( Csv& csv, - Option<TextBuffer&&> bufferOption, StringView filename, OpenFlags flags, Option<int> dirFdOption, - Option<size_t> maxExtraAttempts) + size_t maxExtraAttempts) { debugPrint(u8"Enter parse from filename\n"); - auto fileResult{RegularFile::open(filename, FileAccessMode::Read, flags, dirFdOption)}; + auto fileResult{RegularFile::open(filename, FileAccessMode::Read, flags, std::move(dirFdOption))}; if (fileResult.isError()) { debugPrint(u8"Error opening file: {}\n", FudStatusToString(fileResult.getError())); return fileResult.takeError(); } - if (bufferOption.hasValue()) { - auto bufferedFile{BufferedRegularFile::make(fileResult.takeOkay(), std::move(bufferOption.value()))}; - return parseFromBufferedFile(csv, bufferedFile, maxExtraAttempts); - } - auto unbufferedFile{fileResult.takeOkay()}; return parseFromUnbufferedFile(csv, std::move(unbufferedFile), maxExtraAttempts); } +FudStatus Csv::parseFromFilenameBuffered( + Csv& csv, + TextBuffer&& bufferOption, + StringView filename, + OpenFlags flags, + Option<int> dirFdOption, + size_t maxExtraAttempts) +{ + debugPrint(u8"Enter parse from filename\n"); + auto fileResult{RegularFile::open(filename, FileAccessMode::Read, flags, std::move(dirFdOption))}; + + if (fileResult.isError()) { + debugPrint(u8"Error opening file: {}\n", FudStatusToString(fileResult.getError())); + return fileResult.takeError(); + } + + auto bufferedFile{BufferedRegularFile::make(fileResult.takeOkay(), std::move(bufferOption))}; + return parseFromBufferedFile(csv, bufferedFile, maxExtraAttempts); +} + template <typename File> -DrainResult readHeader(Csv& csv, File& file, Option<size_t> maxExtraAttempts, size_t& rawSize); +DrainResult readHeader(Csv& csv, File& file, size_t maxExtraAttempts, size_t& rawSize); template <typename File> -DrainResult scanLine(const Csv& csv, File& file, Option<size_t> maxExtraAttempts, size_t& rawSize); +DrainResult scanLine(const Csv& csv, File& file, size_t maxExtraAttempts, size_t& rawSize); template <typename File> -FudStatus fillBuffer(Csv& csv, File& file, Option<size_t> maxExtraAttempts, size_t rawSize); +FudStatus fillBuffer(Csv& csv, File& file, size_t maxExtraAttempts, size_t rawSize); -FudStatus Csv::parseFromBufferedFile(Csv& csv, BufferedRegularFile& file, Option<size_t> maxExtraAttempts) +FudStatus Csv::parseFromBufferedFile(Csv& csv, BufferedRegularFile& file, size_t maxExtraAttempts) { size_t rawSize = 0; DrainResult readResult{readHeader(csv, file, maxExtraAttempts, rawSize)}; @@ -139,7 +153,7 @@ FudStatus Csv::parseFromBufferedFile(Csv& csv, BufferedRegularFile& file, Option return FudStatus::Success; } -FudStatus Csv::parseFromUnbufferedFile(Csv& csv, RegularFile&& file, Option<size_t> maxExtraAttempts) +FudStatus Csv::parseFromUnbufferedFile(Csv& csv, RegularFile&& file, size_t maxExtraAttempts) { static_cast<void>(csv); constexpr size_t BufferSize = 256; @@ -150,7 +164,7 @@ FudStatus Csv::parseFromUnbufferedFile(Csv& csv, RegularFile&& file, Option<size // NOLINTBEGIN(readability-function-cognitive-complexity) template <typename File> -DrainResult readHeader(Csv& csv, File& file, Option<size_t> maxExtraAttempts, size_t& rawSize) +DrainResult readHeader(Csv& csv, File& file, size_t maxExtraAttempts, size_t& rawSize) { debugPrint(u8"Entered read header\n"); @@ -215,7 +229,7 @@ DrainResult readHeader(Csv& csv, File& file, Option<size_t> maxExtraAttempts, si } template <typename File> -DrainResult scanLine(const Csv& csv, File& file, Option<size_t> maxExtraAttempts, size_t& rawSize) +DrainResult scanLine(const Csv& csv, File& file, size_t maxExtraAttempts, size_t& rawSize) { debugPrint(u8"Entered scanLine\n"); DrainResult readResult{}; @@ -305,7 +319,7 @@ DrainResult scanLine(const Csv& csv, File& file, Option<size_t> maxExtraAttempts } template <typename File> -FudStatus fillBuffer(Csv& csv, File& file, Option<size_t> maxExtraAttempts, size_t rawSize) +FudStatus fillBuffer(Csv& csv, File& file, size_t maxExtraAttempts, size_t rawSize) { static_cast<void>(rawSize); |