aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/DI/auto_wirable.hpp6
-rw-r--r--src/DI/auto_wirable.tpp4
-rw-r--r--src/DI/container.hpp14
-rw-r--r--src/DI/container.tpp13
-rw-r--r--src/DI/function_wrapper.hpp2
-rw-r--r--src/DI/function_wrapper.tpp2
-rw-r--r--src/DI/interfaces/wrapper.hpp4
-rw-r--r--src/DI/object_type.cpp2
-rw-r--r--src/DI/object_type.hpp6
-rw-r--r--src/DI/object_wrapper.hpp2
-rw-r--r--src/DI/object_wrapper.tpp2
-rw-r--r--src/argument_parser.cpp18
-rw-r--r--src/argument_parser.hpp12
-rw-r--r--src/bootstrap.cpp2
-rw-r--r--src/bootstrap.hpp2
-rw-r--r--src/conversion.cpp2
-rw-r--r--src/conversion.hpp4
-rw-r--r--src/engine/data/bounds.cpp18
-rw-r--r--src/engine/data/bounds.hpp16
-rw-r--r--src/engine/data/vector2.cpp22
-rw-r--r--src/engine/data/vector2.hpp26
-rw-r--r--src/engine/engine.cpp2
-rw-r--r--src/engine/engine.hpp3
-rw-r--r--src/engine/graphics/scene.cpp2
-rw-r--r--src/engine/graphics/string_matrix.cpp12
-rw-r--r--src/engine/graphics/string_matrix.hpp12
-rw-r--r--src/engine/user/cursor.cpp16
-rw-r--r--src/engine/user/cursor.hpp6
-rw-r--r--src/engine/user/input.cpp10
-rw-r--r--src/engine/user/input.hpp12
-rw-r--r--src/game/game.cpp2
-rw-r--r--src/game/game.hpp4
-rw-r--r--src/game_of_life.cpp2
-rw-r--r--src/input_actions.cpp4
-rw-r--r--src/input_actions.hpp6
-rw-r--r--src/interfaces/argument_parser.hpp6
-rw-r--r--src/interfaces/input.hpp12
-rw-r--r--src/interfaces/matrix.hpp12
-rw-r--r--src/interfaces/observable.hpp8
-rw-r--r--src/interfaces/randomization.hpp8
-rw-r--r--src/randomization/generator.cpp5
-rw-r--r--src/randomization/generator.hpp5
-rw-r--r--src/randomization/seed_generator.cpp5
-rw-r--r--src/randomization/seed_generator.hpp5
44 files changed, 170 insertions, 168 deletions
diff --git a/src/DI/auto_wirable.hpp b/src/DI/auto_wirable.hpp
index 13d252e..a903242 100644
--- a/src/DI/auto_wirable.hpp
+++ b/src/DI/auto_wirable.hpp
@@ -8,21 +8,21 @@
class IGenericAutoWirable
{
public:
- virtual ~IGenericAutoWirable() = default;
+ virtual ~IGenericAutoWirable() noexcept = default;
};
template <class Interface>
class IAutoWirable : public IGenericAutoWirable
{
public:
- static Interface resolve();
+ static Interface resolve() noexcept;
};
template <class Interface, class ObjectImpl, class... Dependencies>
class AutoWirable : public IAutoWirable<Interface>
{
public:
- static std::shared_ptr<Interface> resolve(const Container &container);
+ static std::shared_ptr<Interface> resolve(const Container &container) noexcept;
};
#include "auto_wirable.tpp"
diff --git a/src/DI/auto_wirable.tpp b/src/DI/auto_wirable.tpp
index 6c0d111..a99d82b 100644
--- a/src/DI/auto_wirable.tpp
+++ b/src/DI/auto_wirable.tpp
@@ -3,8 +3,8 @@
#include "auto_wirable.hpp"
template <class Interface, class ObjectImpl, class... Dependencies>
-std::shared_ptr<Interface>
-AutoWirable<Interface, ObjectImpl, Dependencies...>::resolve(const Container &container)
+std::shared_ptr<Interface> AutoWirable<Interface, ObjectImpl, Dependencies...>::resolve(
+ const Container &container) noexcept
{
return std::make_shared<ObjectImpl>(container.get<Dependencies>()...);
}
diff --git a/src/DI/container.hpp b/src/DI/container.hpp
index 93722b6..974780a 100644
--- a/src/DI/container.hpp
+++ b/src/DI/container.hpp
@@ -14,13 +14,13 @@ template <typename Interface>
class BindingBuilder
{
public:
- explicit BindingBuilder(Container *container);
+ explicit BindingBuilder(Container *container) noexcept;
template <class ObjectImpl,
class = std::enable_if_t<std::is_base_of_v<Interface, ObjectImpl>>>
- void to();
+ void to() noexcept;
- void to_factory(Interface func);
+ void to_factory(Interface func) noexcept;
private:
Container *_container;
@@ -29,16 +29,16 @@ private:
class Container
{
public:
- Container() = default;
+ Container() noexcept = default;
template <class Interface>
- BindingBuilder<Interface> bind();
+ BindingBuilder<Interface> bind() noexcept;
template <class Interface, class = std::enable_if_t<std::is_class_v<Interface>>>
- std::shared_ptr<Interface> get() const;
+ std::shared_ptr<Interface> get() const noexcept;
template <typename Interface, typename = std::enable_if_t<is_func_v<Interface>>>
- Interface get() const;
+ Interface get() const noexcept;
std::unordered_map<BaseObjectType, std::shared_ptr<IGenericWrapper>, ObjectTypeHasher>
bindings;
diff --git a/src/DI/container.tpp b/src/DI/container.tpp
index e5bf7f7..ed7f34f 100644
--- a/src/DI/container.tpp
+++ b/src/DI/container.tpp
@@ -8,13 +8,14 @@
#include <iostream>
template <class Interface>
-BindingBuilder<Interface>::BindingBuilder(Container *container) : _container(container)
+BindingBuilder<Interface>::BindingBuilder(Container *container) noexcept
+ : _container(container)
{
}
template <class Interface>
template <class ObjectImpl, class>
-void BindingBuilder<Interface>::to()
+void BindingBuilder<Interface>::to() noexcept
{
_container->bindings.emplace(
ObjectType<Interface>(),
@@ -23,7 +24,7 @@ void BindingBuilder<Interface>::to()
}
template <class Interface>
-void BindingBuilder<Interface>::to_factory(Interface func)
+void BindingBuilder<Interface>::to_factory(Interface func) noexcept
{
_container->bindings.emplace(ObjectType<Interface>(),
std::dynamic_pointer_cast<IGenericWrapper>(
@@ -31,13 +32,13 @@ void BindingBuilder<Interface>::to_factory(Interface func)
}
template <class Interface>
-BindingBuilder<Interface> Container::bind()
+BindingBuilder<Interface> Container::bind() noexcept
{
return BindingBuilder<Interface>(this);
}
template <class Interface, class>
-std::shared_ptr<Interface> Container::get() const
+std::shared_ptr<Interface> Container::get() const noexcept
{
ObjectType<Interface> interface_type;
@@ -56,7 +57,7 @@ std::shared_ptr<Interface> Container::get() const
}
template <typename Interface, typename>
-Interface Container::get() const
+Interface Container::get() const noexcept
{
auto wrapper = std::dynamic_pointer_cast<IWrapper<Interface>>(
bindings.at(ObjectType<Interface>()));
diff --git a/src/DI/function_wrapper.hpp b/src/DI/function_wrapper.hpp
index f135e7f..e6468f2 100644
--- a/src/DI/function_wrapper.hpp
+++ b/src/DI/function_wrapper.hpp
@@ -11,7 +11,7 @@ class FunctionWrapper : public IWrapper<Interface>
public:
explicit FunctionWrapper(Interface func) noexcept;
- [[nodiscard]] Interface get() const override;
+ [[nodiscard]] Interface get() const noexcept override;
private:
const Interface _func;
diff --git a/src/DI/function_wrapper.tpp b/src/DI/function_wrapper.tpp
index 920c7f2..540a7aa 100644
--- a/src/DI/function_wrapper.tpp
+++ b/src/DI/function_wrapper.tpp
@@ -8,7 +8,7 @@ FunctionWrapper<Interface>::FunctionWrapper(Interface func) noexcept : _func(fun
}
template <class Interface>
-Interface FunctionWrapper<Interface>::get() const
+Interface FunctionWrapper<Interface>::get() const noexcept
{
return _func;
}
diff --git a/src/DI/interfaces/wrapper.hpp b/src/DI/interfaces/wrapper.hpp
index 3cc75a0..cde555f 100644
--- a/src/DI/interfaces/wrapper.hpp
+++ b/src/DI/interfaces/wrapper.hpp
@@ -6,12 +6,12 @@
class IGenericWrapper
{
public:
- virtual ~IGenericWrapper() = default;
+ virtual ~IGenericWrapper() noexcept = default;
};
template <class Interface>
class IWrapper : public IGenericWrapper
{
public:
- [[nodiscard]] virtual Interface get() const = 0;
+ [[nodiscard]] virtual Interface get() const noexcept = 0;
};
diff --git a/src/DI/object_type.cpp b/src/DI/object_type.cpp
index f6004cb..008c4a4 100644
--- a/src/DI/object_type.cpp
+++ b/src/DI/object_type.cpp
@@ -20,7 +20,7 @@ std::string_view BaseObjectType::name() const noexcept
return std::string_view(_type_info.name());
}
-std::size_t ObjectTypeHasher::operator()(const BaseObjectType &object_type) const
+std::size_t ObjectTypeHasher::operator()(const BaseObjectType &object_type) const noexcept
{
return object_type.hash();
}
diff --git a/src/DI/object_type.hpp b/src/DI/object_type.hpp
index 3910c03..84bb287 100644
--- a/src/DI/object_type.hpp
+++ b/src/DI/object_type.hpp
@@ -22,17 +22,17 @@ template <class Object>
class ObjectType : public BaseObjectType
{
public:
- ObjectType() : BaseObjectType(typeid(Object)) {}
+ ObjectType() noexcept : BaseObjectType(typeid(Object)) {}
};
class IObjectTypeHasher
{
public:
- virtual std::size_t operator()(const BaseObjectType &object_type) const = 0;
+ virtual std::size_t operator()(const BaseObjectType &object_type) const noexcept = 0;
};
class ObjectTypeHasher : public IObjectTypeHasher
{
public:
- std::size_t operator()(const BaseObjectType &object_type) const override;
+ std::size_t operator()(const BaseObjectType &object_type) const noexcept override;
};
diff --git a/src/DI/object_wrapper.hpp b/src/DI/object_wrapper.hpp
index 6fe3997..4aee9af 100644
--- a/src/DI/object_wrapper.hpp
+++ b/src/DI/object_wrapper.hpp
@@ -11,7 +11,7 @@ class ObjectWrapper : public IWrapper<std::shared_ptr<Interface>>
public:
explicit ObjectWrapper(const Container &container) noexcept : _container(container) {}
- [[nodiscard]] std::shared_ptr<Interface> get() const override;
+ [[nodiscard]] std::shared_ptr<Interface> get() const noexcept override;
private:
const Container &_container;
diff --git a/src/DI/object_wrapper.tpp b/src/DI/object_wrapper.tpp
index 7efefc4..bbb7bee 100644
--- a/src/DI/object_wrapper.tpp
+++ b/src/DI/object_wrapper.tpp
@@ -3,7 +3,7 @@
#include "object_wrapper.hpp"
template <class Interface, class ObjectImpl>
-std::shared_ptr<Interface> ObjectWrapper<Interface, ObjectImpl>::get() const
+std::shared_ptr<Interface> ObjectWrapper<Interface, ObjectImpl>::get() const noexcept
{
return ObjectImpl::resolve(_container);
}
diff --git a/src/argument_parser.cpp b/src/argument_parser.cpp
index 16945f7..94c6a4a 100644
--- a/src/argument_parser.cpp
+++ b/src/argument_parser.cpp
@@ -9,7 +9,7 @@
namespace
{
-void optarg_error(char arg, const std::string_view &error)
+void optarg_error(char arg, const std::string_view &error) noexcept
{
std::cout << "Error: Invalid option argument for -" << arg << ". " << error
<< std::endl;
@@ -19,7 +19,7 @@ void optarg_error(char arg, const std::string_view &error)
/**
* Returns the current optarg as a string view.
*/
-std::string_view get_str_optarg()
+std::string_view get_str_optarg() noexcept
{
return std::string_view(optarg);
}
@@ -30,7 +30,7 @@ std::string_view get_str_optarg()
* @param arg The current command-line argument character
* @param check_zero Whether or not to make sure that the result is not zero
*/
-uint32_t get_uint_optarg(char arg, bool check_zero = false)
+uint32_t get_uint_optarg(char arg, bool check_zero = false) noexcept
{
auto conversion_result = str_to_uint(get_str_optarg());
@@ -44,16 +44,16 @@ uint32_t get_uint_optarg(char arg, bool check_zero = false)
} // namespace
ArgumentParser::ArgumentParser(
- IRandomNumberGeneratorFactory random_number_generator_factory)
+ IRandomNumberGeneratorFactory random_number_generator_factory) noexcept
: _random_number_generator_factory(random_number_generator_factory)
{
}
-ParsedArguments
-ArgumentParser::parse(const std::vector<option> &options,
- const std::string_view &short_options, const int &argc,
- char *const *argv) // NOLINT(cppcoreguidelines-avoid-c-arrays,
- // modernize-avoid-c-arrays)
+ParsedArguments ArgumentParser::parse(
+ const std::vector<option> &options, const std::string_view &short_options,
+ const int &argc,
+ char *const *argv) noexcept // NOLINT(cppcoreguidelines-avoid-c-arrays,
+ // modernize-avoid-c-arrays)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
const auto args = std::vector<std::string_view>(argv, argv + argc);
diff --git a/src/argument_parser.hpp b/src/argument_parser.hpp
index 0bcaeb5..c7f33de 100644
--- a/src/argument_parser.hpp
+++ b/src/argument_parser.hpp
@@ -14,13 +14,13 @@ class ArgumentParser
{
public:
explicit ArgumentParser(
- IRandomNumberGeneratorFactory random_number_generator_factory);
+ IRandomNumberGeneratorFactory random_number_generator_factory) noexcept;
- ParsedArguments
- parse(const std::vector<option> &options, const std::string_view &short_options,
- const int &argc,
- char *const *argv) override; // NOLINT(cppcoreguidelines-avoid-c-arrays,
- // modernize-avoid-c-arrays)
+ ParsedArguments parse(
+ const std::vector<option> &options, const std::string_view &short_options,
+ const int &argc,
+ char *const *argv) noexcept override; // NOLINT(cppcoreguidelines-avoid-c-arrays,
+ // modernize-avoid-c-arrays)
private:
IRandomNumberGeneratorFactory _random_number_generator_factory;
diff --git a/src/bootstrap.cpp b/src/bootstrap.cpp
index 5ff71db..0ef0584 100644
--- a/src/bootstrap.cpp
+++ b/src/bootstrap.cpp
@@ -31,7 +31,7 @@
#include <random>
#include <string_view>
-Container bootstrap()
+Container bootstrap() noexcept
{
auto container = Container();
diff --git a/src/bootstrap.hpp b/src/bootstrap.hpp
index a822017..2c4fd1d 100644
--- a/src/bootstrap.hpp
+++ b/src/bootstrap.hpp
@@ -2,4 +2,4 @@
#include "DI/container.hpp"
-Container bootstrap();
+Container bootstrap() noexcept;
diff --git a/src/conversion.cpp b/src/conversion.cpp
index 26f2db2..4dbf651 100644
--- a/src/conversion.cpp
+++ b/src/conversion.cpp
@@ -3,7 +3,7 @@
#include <climits>
#include <stdexcept>
-ConversionResult<uint32_t> str_to_uint(const std::string_view &str)
+ConversionResult<uint32_t> str_to_uint(const std::string_view &str) noexcept
{
if (!ctre::match<IS_VALID_UINT>(str))
{
diff --git a/src/conversion.hpp b/src/conversion.hpp
index f915606..9f6f933 100644
--- a/src/conversion.hpp
+++ b/src/conversion.hpp
@@ -10,7 +10,7 @@ class ConversionResult
{
public:
explicit ConversionResult(const bool &success_, const ResultType &result_,
- const std::string_view &fail_reason_ = "")
+ const std::string_view &fail_reason_ = "") noexcept
: success(success_), result(result_), fail_reason(fail_reason_)
{
}
@@ -29,4 +29,4 @@ static constexpr auto IS_UINT_IN_RANGE = ctll::fixed_string("^[0-9]{1,19}$");
* @param str A string that possibly is a unsigned integer
* @returns A conversion result
*/
-ConversionResult<uint32_t> str_to_uint(const std::string_view &str);
+ConversionResult<uint32_t> str_to_uint(const std::string_view &str) noexcept;
diff --git a/src/engine/data/bounds.cpp b/src/engine/data/bounds.cpp
index 41b6dc0..fdf8c6b 100644
--- a/src/engine/data/bounds.cpp
+++ b/src/engine/data/bounds.cpp
@@ -1,48 +1,48 @@
#include "bounds.hpp"
-Bounds::Bounds(const BoundsOptions &options)
+Bounds::Bounds(const BoundsOptions &options) noexcept
: _width(options.width), _height(options.height)
{
}
-uint32_t Bounds::get_width() const noexcept
+Bounds::Value Bounds::get_width() const noexcept
{
return _width;
}
-void Bounds::set_width(uint32_t width) noexcept
+void Bounds::set_width(Bounds::Value width) noexcept
{
_width = width;
}
-uint32_t Bounds::get_height() const noexcept
+Bounds::Value Bounds::get_height() const noexcept
{
return _height;
}
-void Bounds::set_height(uint32_t height) noexcept
+void Bounds::set_height(Bounds::Value height) noexcept
{
_height = height;
}
CoordsValidation Bounds::validate_coords(const Vector2 &coords) const noexcept
{
- if (static_cast<uint32_t>(coords.get_x()) >= _width)
+ if (static_cast<Bounds::Value>(coords.get_x()) >= _width)
{
return CoordsValidation::X_HIGH;
}
- if (static_cast<uint32_t>(coords.get_x()) <= 0)
+ if (static_cast<Bounds::Value>(coords.get_x()) <= 0)
{
return CoordsValidation::X_LOW;
}
- if (static_cast<uint32_t>(coords.get_y()) >= _height)
+ if (static_cast<Bounds::Value>(coords.get_y()) >= _height)
{
return CoordsValidation::Y_HIGH;
}
- if (static_cast<uint32_t>(coords.get_y()) <= 0)
+ if (static_cast<Bounds::Value>(coords.get_y()) <= 0)
{
return CoordsValidation::Y_LOW;
}
diff --git a/src/engine/data/bounds.hpp b/src/engine/data/bounds.hpp
index 9b72f59..4a29158 100644
--- a/src/engine/data/bounds.hpp
+++ b/src/engine/data/bounds.hpp
@@ -22,15 +22,17 @@ struct BoundsOptions
class Bounds
{
public:
- explicit Bounds(const BoundsOptions &options);
+ using Value = uint32_t;
- [[nodiscard]] uint32_t get_width() const noexcept;
+ explicit Bounds(const BoundsOptions &options) noexcept;
- void set_width(uint32_t width) noexcept;
+ [[nodiscard]] Value get_width() const noexcept;
- [[nodiscard]] uint32_t get_height() const noexcept;
+ void set_width(Value width) noexcept;
- void set_height(uint32_t height) noexcept;
+ [[nodiscard]] Value get_height() const noexcept;
+
+ void set_height(Value height) noexcept;
[[nodiscard]] CoordsValidation validate_coords(const Vector2 &coords) const noexcept;
@@ -39,6 +41,6 @@ public:
const Bounds &operator-=(const Bounds &bounds) noexcept;
private:
- uint32_t _width = 0U;
- uint32_t _height = 0U;
+ Value _width = 0U;
+ Value _height = 0U;
};
diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp
index 04cc42e..dba745f 100644
--- a/src/engine/data/vector2.cpp
+++ b/src/engine/data/vector2.cpp
@@ -2,8 +2,6 @@
#include "util/hash.hpp"
-Vector2::Vector2(const Vector2Options &options) : _x(options.x), _y(options.y) {}
-
Vector2::Value Vector2::get_x() const noexcept
{
return _x;
@@ -71,26 +69,6 @@ bool Vector2::operator==(const Vector2 &vector2) const noexcept
return _x == vector2._x && _y == vector2._y;
}
-Vector2 Vector2::up() noexcept
-{
- return Vector2({.x = 0, .y = -1});
-}
-
-Vector2 Vector2::down() noexcept
-{
- return Vector2({.x = 0, .y = 1});
-}
-
-Vector2 Vector2::left() noexcept
-{
- return Vector2({.x = -1, .y = 0});
-}
-
-Vector2 Vector2::right() noexcept
-{
- return Vector2({.x = 1, .y = 0});
-}
-
std::size_t Vector2Hasher::operator()(const Vector2 &vector2) const noexcept
{
std::size_t result_hash = 0;
diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp
index e835e65..868394a 100644
--- a/src/engine/data/vector2.hpp
+++ b/src/engine/data/vector2.hpp
@@ -17,7 +17,10 @@ class Vector2
public:
using Value = int32_t;
- explicit Vector2(const Vector2Options &options);
+ constexpr explicit Vector2(const Vector2Options &options) noexcept
+ : _x(options.x), _y(options.y)
+ {
+ }
[[nodiscard]] Value get_x() const noexcept;
@@ -41,22 +44,35 @@ public:
/**
* Returns Vector2({.x = 0, .y = -1})
*/
- static Vector2 up() noexcept;
+ static constexpr Vector2 up() noexcept
+ {
+ return Vector2({.x = 0, .y = -1});
+ }
/**
* Returns Vector2({.x = 0, .y = 1})
*/
- static Vector2 down() noexcept;
+ static constexpr Vector2 down() noexcept
+ {
+ return Vector2({.x = 0, .y = 1});
+ }
/**
* Returns Vector2({.x = -1, .y = 0})
*/
- static Vector2 left() noexcept;
+ static constexpr Vector2 left() noexcept
+ {
+
+ return Vector2({.x = -1, .y = 0});
+ }
/**
* Returns Vector2({.x = 1, .y = 0})
*/
- static Vector2 right() noexcept;
+ static constexpr Vector2 right() noexcept
+ {
+ return Vector2({.x = 1, .y = 0});
+ }
private:
Value _x;
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp
index d793c65..2fc94fe 100644
--- a/src/engine/engine.cpp
+++ b/src/engine/engine.cpp
@@ -68,7 +68,7 @@ void CLIGameEngine::start() noexcept
}
void CLIGameEngine::_configure_input(
- const std::unordered_map<char, Callback> &input_config)
+ const std::unordered_map<char, Callback> &input_config) noexcept
{
for (const auto &config_pair : input_config)
{
diff --git a/src/engine/engine.hpp b/src/engine/engine.hpp
index 504fc28..42cc297 100644
--- a/src/engine/engine.hpp
+++ b/src/engine/engine.hpp
@@ -33,5 +33,6 @@ private:
std::shared_ptr<ICursorController> _cursor_controller;
std::shared_ptr<IWindow> _window;
- void _configure_input(const std::unordered_map<char, Callback> &input_config);
+ void
+ _configure_input(const std::unordered_map<char, Callback> &input_config) noexcept;
};
diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp
index 6b85915..660e3ca 100644
--- a/src/engine/graphics/scene.cpp
+++ b/src/engine/graphics/scene.cpp
@@ -53,7 +53,7 @@ void Scene::write_status(const std::string_view &str) noexcept
_cursor_controller->move_to(
Vector2({.x = 2, .y = static_cast<Vector2::Value>(window_size.get_height())}));
- const auto background_color = get_background_esc_seq(STATUSBAR_COLOR);
+ auto background_color = get_background_esc_seq(STATUSBAR_COLOR);
fmt::print("{}", background_color);
fmt::print(ERASE_ENTIRE_LINE, fmt::arg("esc", ESC));
diff --git a/src/engine/graphics/string_matrix.cpp b/src/engine/graphics/string_matrix.cpp
index 26d48df..ae06755 100644
--- a/src/engine/graphics/string_matrix.cpp
+++ b/src/engine/graphics/string_matrix.cpp
@@ -1,13 +1,13 @@
#include "string_matrix.hpp"
-StringMatrix::StringMatrix(const Bounds &bounds)
+StringMatrix::StringMatrix(const Bounds &bounds) noexcept
: _rows(bounds.get_height()), _columns(bounds.get_width())
{
_matrix.reserve(bounds.get_height());
_matrix.assign(_matrix.capacity(), std::vector<std::string_view>(bounds.get_width()));
};
-void StringMatrix::fill(std::string_view element)
+void StringMatrix::fill(std::string_view element) noexcept
{
for (uint32_t row = 0U; row < _matrix.capacity(); row++)
{
@@ -20,7 +20,7 @@ void StringMatrix::fill(std::string_view element)
}
}
-std::string_view StringMatrix::get(const Vector2 &pos) const
+std::string_view StringMatrix::get(const Vector2 &pos) const noexcept
{
auto x = static_cast<std::size_t>(pos.get_x());
auto y = static_cast<std::size_t>(pos.get_y());
@@ -28,7 +28,7 @@ std::string_view StringMatrix::get(const Vector2 &pos) const
return _matrix[y][x];
}
-void StringMatrix::set(const Vector2 &pos, std::string_view element)
+void StringMatrix::set(const Vector2 &pos, std::string_view element) noexcept
{
auto x = static_cast<std::size_t>(pos.get_x());
auto y = static_cast<std::size_t>(pos.get_y());
@@ -36,12 +36,12 @@ void StringMatrix::set(const Vector2 &pos, std::string_view element)
_matrix[y][x] = element;
}
-uint32_t StringMatrix::rows() const
+uint32_t StringMatrix::rows() const noexcept
{
return _rows;
}
-uint32_t StringMatrix::columns() const
+uint32_t StringMatrix::columns() const noexcept
{
return _columns;
}
diff --git a/src/engine/graphics/string_matrix.hpp b/src/engine/graphics/string_matrix.hpp
index 540d63b..40fbb11 100644
--- a/src/engine/graphics/string_matrix.hpp
+++ b/src/engine/graphics/string_matrix.hpp
@@ -19,21 +19,21 @@ public:
*
* @param bounds The bounds of the matrix
*/
- explicit StringMatrix(const Bounds &bounds);
+ explicit StringMatrix(const Bounds &bounds) noexcept;
/**
* Fills the matrix with a element.
*
* @param element A element
*/
- void fill(std::string_view element) override;
+ void fill(std::string_view element) noexcept override;
/**
* Returns a element of the matrix.
*
* @param pos The position of a element
*/
- [[nodiscard]] std::string_view get(const Vector2 &pos) const override;
+ [[nodiscard]] std::string_view get(const Vector2 &pos) const noexcept override;
/**
* Sets a element of the matrix.
@@ -41,17 +41,17 @@ public:
* @param pos The position of a element
* @param element A new element
*/
- void set(const Vector2 &pos, std::string_view element) override;
+ void set(const Vector2 &pos, std::string_view element) noexcept override;
/**
* Returns the number of rows the matrix has.
*/
- [[nodiscard]] uint32_t rows() const override;
+ [[nodiscard]] uint32_t rows() const noexcept override;
/**
* Returns the number of columns the matrix has.
*/
- [[nodiscard]] uint32_t columns() const override;
+ [[nodiscard]] uint32_t columns() const noexcept override;
private:
std::vector<std::vector<std::string_view>> _matrix;
diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp
index 663d56a..b02a9bc 100644
--- a/src/engine/user/cursor.cpp
+++ b/src/engine/user/cursor.cpp
@@ -5,7 +5,7 @@
#include <cstdlib>
#include <iostream>
-CursorController::CursorController() : _position({.x = 0, .y = 0}) {}
+CursorController::CursorController() noexcept : _position({.x = 0, .y = 0}) {}
void CursorController::move(const Vector2 &direction, const uint32_t &amount) noexcept
{
@@ -32,12 +32,6 @@ Vector2 CursorController::where() const noexcept
return _position;
}
-void CursorController::hide()
-{
- fmt::print(CURSOR_INVISIBLE, fmt::arg("esc", ESC));
- std::cout.flush();
-}
-
void CursorController::ensure_position() noexcept
{
fmt::print(REQUEST_CURSOR_POSITION, fmt::arg("esc", ESC));
@@ -51,7 +45,13 @@ void CursorController::ensure_position() noexcept
_position = Vector2(vector2_options);
}
-void CursorController::show()
+void CursorController::hide() noexcept
+{
+ fmt::print(CURSOR_INVISIBLE, fmt::arg("esc", ESC));
+ std::cout.flush();
+}
+
+void CursorController::show() noexcept
{
fmt::print(CURSOR_VISIBLE, fmt::arg("esc", ESC));
std::cout.flush();
diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp
index c591235..713ee31 100644
--- a/src/engine/user/cursor.hpp
+++ b/src/engine/user/cursor.hpp
@@ -33,7 +33,7 @@ class CursorController : public ICursorController,
public AutoWirable<ICursorController, CursorController>
{
public:
- CursorController();
+ CursorController() noexcept;
void move(const Vector2 &direction, const uint32_t &amount) noexcept override;
@@ -43,9 +43,9 @@ public:
void ensure_position() noexcept override;
- static void hide();
+ static void hide() noexcept;
- static void show();
+ static void show() noexcept;
private:
Vector2 _position;
diff --git a/src/engine/user/input.cpp b/src/engine/user/input.cpp
index 1dc7f63..62aef67 100644
--- a/src/engine/user/input.cpp
+++ b/src/engine/user/input.cpp
@@ -2,7 +2,7 @@
#include <unistd.h>
-void InputHandler::listen() const
+void InputHandler::listen() const noexcept
{
char character = 0;
@@ -12,7 +12,7 @@ void InputHandler::listen() const
}
}
-void InputHandler::attach(const char &event, Callback callback)
+void InputHandler::attach(const char &event, Callback callback) noexcept
{
if (_key_observers.count(event) == 0)
{
@@ -22,7 +22,7 @@ void InputHandler::attach(const char &event, Callback callback)
_key_observers[event].push_back(callback);
}
-void InputHandler::notify(const char &event) const
+void InputHandler::notify(const char &event) const noexcept
{
if (_key_observers.count(event) == 0)
{
@@ -35,7 +35,7 @@ void InputHandler::notify(const char &event) const
}
}
-void InputHandler::enter_raw_mode()
+void InputHandler::enter_raw_mode() noexcept
{
if (_original_termios == nullptr)
{
@@ -51,7 +51,7 @@ void InputHandler::enter_raw_mode()
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw_termios);
}
-void InputHandler::leave_raw_mode()
+void InputHandler::leave_raw_mode() noexcept
{
if (_original_termios == nullptr)
{
diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp
index f48ab86..3dd7fa9 100644
--- a/src/engine/user/input.hpp
+++ b/src/engine/user/input.hpp
@@ -12,17 +12,17 @@
class InputHandler : public IInputHandler, public AutoWirable<IInputHandler, InputHandler>
{
public:
- InputHandler() = default;
+ InputHandler() noexcept = default;
- void listen() const override;
+ void listen() const noexcept override;
- void attach(const char &event, Callback callback) override;
+ void attach(const char &event, Callback callback) noexcept override;
- void notify(const char &event) const override;
+ void notify(const char &event) const noexcept override;
- void enter_raw_mode() override;
+ void enter_raw_mode() noexcept override;
- void leave_raw_mode() override;
+ void leave_raw_mode() noexcept override;
private:
std::unordered_map<char, std::vector<Callback>> _key_observers;
diff --git a/src/game/game.cpp b/src/game/game.cpp
index dafa847..d7e9056 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -1,3 +1,3 @@
#include "game.hpp"
-void Game::run() {}
+void Game::run() noexcept {}
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 2111026..110b1c8 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -6,7 +6,7 @@
class Game : public IGame, public AutoWirable<IGame, Game>
{
public:
- Game() = default;
+ Game() noexcept = default;
- void run() override;
+ void run() noexcept override;
};
diff --git a/src/game_of_life.cpp b/src/game_of_life.cpp
index 37e241c..6af6809 100644
--- a/src/game_of_life.cpp
+++ b/src/game_of_life.cpp
@@ -10,7 +10,7 @@ const std::vector<option> options = {option({"seed", required_argument, nullptr,
option({"help", no_argument, nullptr, 'h'}),
option({nullptr, 0, nullptr, 0})};
-int main(int argc, char *argv[])
+int main(int argc, char *argv[]) noexcept
{
auto container = bootstrap();
diff --git a/src/input_actions.cpp b/src/input_actions.cpp
index 7a6976d..fa41bdd 100644
--- a/src/input_actions.cpp
+++ b/src/input_actions.cpp
@@ -7,7 +7,7 @@
namespace InputActions
{
-void exit_success()
+void exit_success() noexcept
{
exit(EXIT_SUCCESS);
}
@@ -15,7 +15,7 @@ void exit_success()
Callback move_cursor(const Vector2 &direction,
const std::shared_ptr<ICursorController> &cursor_controller,
const std::shared_ptr<IScene> &scene,
- const std::shared_ptr<IWindow> &window)
+ const std::shared_ptr<IWindow> &window) noexcept
{
return [direction, cursor_controller, scene, window]()
{
diff --git a/src/input_actions.hpp b/src/input_actions.hpp
index 224c280..b9c33c1 100644
--- a/src/input_actions.hpp
+++ b/src/input_actions.hpp
@@ -12,11 +12,11 @@
namespace InputActions
{
+void exit_success() noexcept;
+
Callback move_cursor(const Vector2 &direction,
const std::shared_ptr<ICursorController> &cursor_controller,
const std::shared_ptr<IScene> &scene,
- const std::shared_ptr<IWindow> &window);
-
-void exit_success();
+ const std::shared_ptr<IWindow> &window) noexcept;
} // namespace InputActions
diff --git a/src/interfaces/argument_parser.hpp b/src/interfaces/argument_parser.hpp
index fbf1b2a..742646d 100644
--- a/src/interfaces/argument_parser.hpp
+++ b/src/interfaces/argument_parser.hpp
@@ -15,11 +15,11 @@ struct ParsedArguments
class IArgumentParser
{
public:
- virtual ~IArgumentParser() = default;
+ virtual ~IArgumentParser() noexcept = default;
virtual ParsedArguments
parse(const std::vector<option> &options, const std::string_view &short_options,
const int &argc,
- char *const *argv) = 0; // NOLINT(cppcoreguidelines-avoid-c-arrays,
- // modernize-avoid-c-arrays)
+ char *const *argv) noexcept = 0; // NOLINT(cppcoreguidelines-avoid-c-arrays,
+ // modernize-avoid-c-arrays)
};
diff --git a/src/interfaces/input.hpp b/src/interfaces/input.hpp
index b8679c7..b243a16 100644
--- a/src/interfaces/input.hpp
+++ b/src/interfaces/input.hpp
@@ -5,15 +5,15 @@
class IInputHandler : public IObservable<char>
{
public:
- ~IInputHandler() override = default;
+ ~IInputHandler() noexcept override = default;
- void listen() const override = 0;
+ void listen() const noexcept override = 0;
- void attach(const char &event, Callback callback) override = 0;
+ void attach(const char &event, Callback callback) noexcept override = 0;
- void notify(const char &event) const override = 0;
+ void notify(const char &event) const noexcept override = 0;
- virtual void enter_raw_mode() = 0;
+ virtual void enter_raw_mode() noexcept = 0;
- virtual void leave_raw_mode() = 0;
+ virtual void leave_raw_mode() noexcept = 0;
};
diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp
index e0a92bf..44a26ed 100644
--- a/src/interfaces/matrix.hpp
+++ b/src/interfaces/matrix.hpp
@@ -9,21 +9,21 @@ template <typename Element>
class IMatrix
{
public:
- virtual ~IMatrix() = default;
+ virtual ~IMatrix() noexcept = default;
/**
* Fills the matrix with a element.
*
* @param element A element
*/
- virtual void fill(Element element) = 0;
+ virtual void fill(Element element) noexcept = 0;
/**
* Returns a element of the matrix.
*
* @param pos The position of a element
*/
- [[nodiscard]] virtual Element get(const Vector2 &pos) const = 0;
+ [[nodiscard]] virtual Element get(const Vector2 &pos) const noexcept = 0;
/**
* Sets a element of the matrix.
@@ -31,17 +31,17 @@ public:
* @param pos The position of a element
* @param element A new element
*/
- virtual void set(const Vector2 &pos, Element element) = 0;
+ virtual void set(const Vector2 &pos, Element element) noexcept = 0;
/**
* Returns the number of rows the matrix has.
*/
- [[nodiscard]] virtual uint32_t rows() const = 0;
+ [[nodiscard]] virtual uint32_t rows() const noexcept = 0;
/**
* Returns the number of columns the matrix has.
*/
- [[nodiscard]] virtual uint32_t columns() const = 0;
+ [[nodiscard]] virtual uint32_t columns() const noexcept = 0;
};
template <typename Element>
diff --git a/src/interfaces/observable.hpp b/src/interfaces/observable.hpp
index 7dbd50a..1777b7d 100644
--- a/src/interfaces/observable.hpp
+++ b/src/interfaces/observable.hpp
@@ -8,11 +8,11 @@ template <typename Event>
class IObservable
{
public:
- virtual ~IObservable() = default;
+ virtual ~IObservable() noexcept = default;
- virtual void listen() const = 0;
+ virtual void listen() const noexcept = 0;
- virtual void attach(const Event &event, Callback callback) = 0;
+ virtual void attach(const Event &event, Callback callback) noexcept = 0;
- virtual void notify(const Event &event) const = 0;
+ virtual void notify(const Event &event) const noexcept = 0;
};
diff --git a/src/interfaces/randomization.hpp b/src/interfaces/randomization.hpp
index 524069a..f290d5c 100644
--- a/src/interfaces/randomization.hpp
+++ b/src/interfaces/randomization.hpp
@@ -5,9 +5,9 @@
class ISeedGenerator
{
public:
- virtual ~ISeedGenerator() = default;
+ virtual ~ISeedGenerator() noexcept = default;
- [[nodiscard]] virtual uint32_t random_seed() const = 0;
+ [[nodiscard]] virtual uint32_t random_seed() const noexcept = 0;
};
using ISeedGeneratorFactory = std::shared_ptr<ISeedGenerator> (*)();
@@ -18,7 +18,7 @@ using ISeedGeneratorFactory = std::shared_ptr<ISeedGenerator> (*)();
class IRandomNumberGenerator
{
public:
- virtual ~IRandomNumberGenerator() = default;
+ virtual ~IRandomNumberGenerator() noexcept = default;
/**
* Returns a number in the range of a to b.
@@ -27,7 +27,7 @@ public:
* @param b A number greater than a
*/
[[nodiscard]] virtual uint32_t in_range(const uint32_t &a,
- const uint32_t &b) const = 0;
+ const uint32_t &b) const noexcept = 0;
};
using IRandomNumberGeneratorFactory =
diff --git a/src/randomization/generator.cpp b/src/randomization/generator.cpp
index 56fbbf1..6956eda 100644
--- a/src/randomization/generator.cpp
+++ b/src/randomization/generator.cpp
@@ -1,11 +1,12 @@
#include "generator.hpp"
-RandomNumberGenerator::RandomNumberGenerator(const uint32_t &seed)
+RandomNumberGenerator::RandomNumberGenerator(const uint32_t &seed) noexcept
{
this->_generator = std::make_unique<std::mt19937>(seed);
}
-uint32_t RandomNumberGenerator::in_range(const uint32_t &a, const uint32_t &b) const
+uint32_t RandomNumberGenerator::in_range(const uint32_t &a,
+ const uint32_t &b) const noexcept
{
auto random_distribution = std::uniform_int_distribution<uint32_t>(a, b);
diff --git a/src/randomization/generator.hpp b/src/randomization/generator.hpp
index 35bd9eb..4b002dd 100644
--- a/src/randomization/generator.hpp
+++ b/src/randomization/generator.hpp
@@ -8,9 +8,10 @@
class RandomNumberGenerator : public IRandomNumberGenerator
{
public:
- explicit RandomNumberGenerator(const uint32_t &seed);
+ explicit RandomNumberGenerator(const uint32_t &seed) noexcept;
- [[nodiscard]] uint32_t in_range(const uint32_t &a, const uint32_t &b) const override;
+ [[nodiscard]] uint32_t in_range(const uint32_t &a,
+ const uint32_t &b) const noexcept override;
private:
std::unique_ptr<std::mt19937> _generator;
diff --git a/src/randomization/seed_generator.cpp b/src/randomization/seed_generator.cpp
index 5d51e18..3afa275 100644
--- a/src/randomization/seed_generator.cpp
+++ b/src/randomization/seed_generator.cpp
@@ -1,11 +1,12 @@
#include "seed_generator.hpp"
-SeedGenerator::SeedGenerator(const std::shared_ptr<std::random_device> &random_device)
+SeedGenerator::SeedGenerator(
+ const std::shared_ptr<std::random_device> &random_device) noexcept
: _random_device(random_device)
{
}
-uint32_t SeedGenerator::random_seed() const
+uint32_t SeedGenerator::random_seed() const noexcept
{
return (*_random_device)();
}
diff --git a/src/randomization/seed_generator.hpp b/src/randomization/seed_generator.hpp
index 1447a8c..087ad6b 100644
--- a/src/randomization/seed_generator.hpp
+++ b/src/randomization/seed_generator.hpp
@@ -8,9 +8,10 @@
class SeedGenerator : public ISeedGenerator
{
public:
- explicit SeedGenerator(const std::shared_ptr<std::random_device> &random_device);
+ explicit SeedGenerator(
+ const std::shared_ptr<std::random_device> &random_device) noexcept;
- [[nodiscard]] uint32_t random_seed() const override;
+ [[nodiscard]] uint32_t random_seed() const noexcept override;
private:
const std::shared_ptr<std::random_device> &_random_device;