From 35262ebf8835476e0f2c3353e132e196f7c2e615 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sun, 11 Aug 2024 20:48:03 -0400 Subject: Fix CSV logger file invalid pointer Add explicit move semantics to FileParseState --- src/openvic-dataloader/ParseState.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/openvic-dataloader/ParseState.hpp b/src/openvic-dataloader/ParseState.hpp index a9a9953..6d635ee 100644 --- a/src/openvic-dataloader/ParseState.hpp +++ b/src/openvic-dataloader/ParseState.hpp @@ -96,6 +96,21 @@ namespace ovdl { FileParseState(const char* path, lexy::buffer&& buffer, detail::Encoding encoding) : FileParseState(file_type { path, std::move(buffer) }, encoding) {} + FileParseState(const FileParseState&) = delete; + FileParseState& operator=(const FileParseState&) = delete; + + FileParseState(FileParseState&& other) + : _file { std::move(other._file) }, + _logger { this->file() }, + BasicParseState(std::move(other)) {} + + FileParseState& operator=(FileParseState&& rhs) { + this->~FileParseState(); + new (this) FileParseState(std::move(rhs)); + + return *this; + } + file_type& file() { return _file; } -- cgit v1.2.3-56-ga3b1