From 2f14c18ff51356c93b2f0b2aeecc84de6398cc0a Mon Sep 17 00:00:00 2001 From: Jan Sucan Date: Mon, 27 Jan 2025 10:46:40 +0100 Subject: Remove use of inheritance for Options classes --- src/options.cpp | 12 ++++++++++-- src/options.h | 28 +++++++++------------------- 2 files changed, 19 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/options.cpp b/src/options.cpp index a836b53..9b85962 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -35,10 +35,10 @@ */ #include "program_info.h" -Options::Options() : buffer_size{Options::DEFAULT_BUFFER_SIZE} {} +OptionsCreate::OptionsCreate() : buffer_size{OPTIONS_DEFAULT_BUFFER_SIZE} {} uint32_t -Options::getBufferSize() const +OptionsCreate::getBufferSize() const { return buffer_size; } @@ -61,6 +61,14 @@ OptionsCreate::getOutFilePath() const return out_file_path; } +OptionsRestore::OptionsRestore() : buffer_size{OPTIONS_DEFAULT_BUFFER_SIZE} {} + +uint32_t +OptionsRestore::getBufferSize() const +{ + return buffer_size; +} + std::filesystem::path OptionsRestore::getDiffFilePath() const { diff --git a/src/options.h b/src/options.h index ec1906b..f30f253 100644 --- a/src/options.h +++ b/src/options.h @@ -37,50 +37,40 @@ class OptionError : public DiffddError explicit OptionError(const std::string &message) : DiffddError(message) {} }; -class Options -{ - friend class OptionParser; - - public: - static const int DEFAULT_BUFFER_SIZE{4 * 1024 * 1024}; +const inline int OPTIONS_DEFAULT_BUFFER_SIZE{4 * 1024 * 1024}; - Options(); - virtual ~Options() = default; - - uint32_t getBufferSize() const; - - private: - uint32_t buffer_size; -}; - -class OptionsCreate : public Options +class OptionsCreate { friend class OptionParser; public: - virtual ~OptionsCreate() override = default; + OptionsCreate(); + uint32_t getBufferSize() const; std::filesystem::path getInFilePath() const; std::filesystem::path getBaseFilePath() const; std::filesystem::path getOutFilePath() const; private: + uint32_t buffer_size; std::filesystem::path in_file_path; std::filesystem::path base_file_path; std::filesystem::path out_file_path; }; -class OptionsRestore : public Options +class OptionsRestore { friend class OptionParser; public: - virtual ~OptionsRestore() override = default; + OptionsRestore(); + uint32_t getBufferSize() const; std::filesystem::path getDiffFilePath() const; std::filesystem::path getOutFilePath() const; private: + uint32_t buffer_size; std::filesystem::path diff_file_path; std::filesystem::path out_file_path; }; -- cgit v1.2.3