From cf3bfd60ad03f2feb2ccc62a12fc2922bdc2fb71 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Jun 2022 20:07:09 +0200 Subject: refactor: remove randomization & argument parser --- src/CMakeLists.txt | 5 +- src/argument_parser.cpp | 104 ----------------------------------- src/argument_parser.hpp | 31 ----------- src/bootstrap.cpp | 13 ----- src/game_of_life.cpp | 28 +--------- src/interfaces/argument_parser.hpp | 28 ---------- src/interfaces/randomization.hpp | 33 ----------- src/randomization/generator.cpp | 14 ----- src/randomization/generator.hpp | 18 ------ src/randomization/seed_generator.cpp | 6 -- src/randomization/seed_generator.hpp | 19 ------- 11 files changed, 3 insertions(+), 296 deletions(-) delete mode 100644 src/argument_parser.cpp delete mode 100644 src/argument_parser.hpp delete mode 100644 src/interfaces/argument_parser.hpp delete mode 100644 src/interfaces/randomization.hpp delete mode 100644 src/randomization/generator.cpp delete mode 100644 src/randomization/generator.hpp delete mode 100644 src/randomization/seed_generator.cpp delete mode 100644 src/randomization/seed_generator.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c576e3..76a6d5a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,6 @@ file(GLOB SOURCES game_of_life.cpp bootstrap.cpp conversion.cpp - argument_parser.cpp util/color.cpp game/game.cpp game/status_manager.cpp @@ -24,9 +23,7 @@ file(GLOB SOURCES engine/graphics/string_matrix.cpp engine/graphics/statusline.cpp engine/user/input.cpp - engine/user/cursor.cpp - randomization/generator.cpp - randomization/seed_generator.cpp) + engine/user/cursor.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) diff --git a/src/argument_parser.cpp b/src/argument_parser.cpp deleted file mode 100644 index 117d979..0000000 --- a/src/argument_parser.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "argument_parser.hpp" - -#include "conversion.hpp" -#include "interfaces/randomization.hpp" - -#include -#include -#include - -namespace -{ -void optarg_error(char arg, const std::string_view &error) noexcept -{ - std::cout << "Error: Invalid option argument for -" << arg << ". " << error - << std::endl; - exit(EXIT_FAILURE); -} - -/** - * Returns the current optarg as a string view. - */ -auto get_str_optarg() noexcept -> std::string_view -{ - return {optarg}; -} - -/** - * Returns the current optarg as a unsigned integer. - * - * @param arg The current command-line argument character - * @param check_zero Whether or not to make sure that the result is not zero - */ -auto get_uint_optarg(char arg, bool check_zero = false) noexcept -> uint32_t -{ - auto conversion_result = str_to_uint(get_str_optarg()); - - if (!conversion_result.success || (check_zero && conversion_result.result == 0)) - { - optarg_error(arg, conversion_result.fail_reason); - } - - return conversion_result.result; -} -} // namespace - -ArgumentParser::ArgumentParser( - IRandomNumberGeneratorFactory random_number_generator_factory) noexcept - : _random_number_generator_factory(random_number_generator_factory) -{ -} - -auto ArgumentParser::parse( - const std::vector