diff options
author | HampusM <hampus@hampusmat.com> | 2022-06-27 22:08:43 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-27 22:08:43 +0200 |
commit | 6b0e2a25cf1e98d3f11d4e6c0305dd327048bbb8 (patch) | |
tree | a62c23f4e66949fe109e07dec95ad3a3e5229a7c | |
parent | 9d0fe1b42c9f6a5c09bab444966d347a71a4b905 (diff) |
refactor: use int types from std namespace
25 files changed, 73 insertions, 73 deletions
diff --git a/src/engine/data/bounds.hpp b/src/engine/data/bounds.hpp index 731db5c..b122489 100644 --- a/src/engine/data/bounds.hpp +++ b/src/engine/data/bounds.hpp @@ -15,14 +15,14 @@ enum CoordsValidation struct BoundsOptions { - uint32_t width; - uint32_t height; + std::uint32_t width; + std::uint32_t height; }; class Bounds { public: - using Value = uint32_t; + using Value = std::uint32_t; explicit Bounds(const BoundsOptions &options) noexcept; diff --git a/src/engine/data/style.hpp b/src/engine/data/style.hpp index 50c1faa..6cb3fbd 100644 --- a/src/engine/data/style.hpp +++ b/src/engine/data/style.hpp @@ -7,14 +7,14 @@ class Style { public: // Colors - std::optional<uint32_t> fg_color{}; - std::optional<uint32_t> bg_color{}; + std::optional<std::uint32_t> fg_color{}; + std::optional<std::uint32_t> bg_color{}; // Toggles bool bold = false; bool reset_before = false; // Spacing - uint32_t padding_left = 0U; - uint32_t padding_right = 0U; + std::uint32_t padding_left = 0U; + std::uint32_t padding_right = 0U; }; diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp index 96ebf87..b83e924 100644 --- a/src/engine/data/vector2.hpp +++ b/src/engine/data/vector2.hpp @@ -5,8 +5,8 @@ struct Vector2Options { - int32_t x; - int32_t y; + std::int32_t x; + std::int32_t y; }; /** @@ -15,7 +15,7 @@ struct Vector2Options class Vector2 { public: - using Value = int32_t; + using Value = std::int32_t; constexpr explicit Vector2(const Vector2Options &options) noexcept : _x(options.x), _y(options.y) diff --git a/src/engine/graphics/matrix.hpp b/src/engine/graphics/matrix.hpp index 7b4d037..58905ee 100644 --- a/src/engine/graphics/matrix.hpp +++ b/src/engine/graphics/matrix.hpp @@ -28,9 +28,9 @@ public: void set(const Vector2 &pos, Element element) noexcept override; - [[nodiscard]] auto get_row_cnt() const noexcept -> uint32_t override; + [[nodiscard]] auto get_row_cnt() const noexcept -> std::uint32_t override; - [[nodiscard]] auto get_column_cnt() const noexcept -> uint32_t override; + [[nodiscard]] auto get_column_cnt() const noexcept -> std::uint32_t override; [[nodiscard]] auto begin() const noexcept -> MatrixIterator<Element> override; @@ -43,8 +43,8 @@ public: private: gsl::owner<Element **> _matrix; - uint32_t _row_cnt; - uint32_t _column_cnt; + std::uint32_t _row_cnt; + std::uint32_t _column_cnt; void _delete_matrix() noexcept; diff --git a/src/engine/graphics/matrix_impl.hpp b/src/engine/graphics/matrix_impl.hpp index 527c61f..9105149 100644 --- a/src/engine/graphics/matrix_impl.hpp +++ b/src/engine/graphics/matrix_impl.hpp @@ -70,13 +70,13 @@ void Matrix<Element>::set(const Vector2 &pos, Element element) noexcept } template <typename Element> -auto Matrix<Element>::get_row_cnt() const noexcept -> uint32_t +auto Matrix<Element>::get_row_cnt() const noexcept -> std::uint32_t { return _row_cnt; } template <typename Element> -auto Matrix<Element>::get_column_cnt() const noexcept -> uint32_t +auto Matrix<Element>::get_column_cnt() const noexcept -> std::uint32_t { return _column_cnt; } diff --git a/src/engine/graphics/matrix_iterator.hpp b/src/engine/graphics/matrix_iterator.hpp index 70a59bf..2d91ff1 100644 --- a/src/engine/graphics/matrix_iterator.hpp +++ b/src/engine/graphics/matrix_iterator.hpp @@ -28,7 +28,7 @@ class MatrixRow public: using RowPtr = gsl::owner<Element *>; - explicit MatrixRow(RowPtr row_ptr, const uint32_t &column_cnt) noexcept; + explicit MatrixRow(RowPtr row_ptr, const std::uint32_t &column_cnt) noexcept; [[nodiscard]] auto begin() const noexcept -> MatrixRowIterator<Element>; @@ -37,7 +37,7 @@ public: private: RowPtr _row_ptr; - const uint32_t &_column_cnt; + const std::uint32_t &_column_cnt; }; template <typename Element> @@ -46,7 +46,7 @@ class MatrixIterator public: using RowPtr = gsl::owner<Element **>; - explicit MatrixIterator(RowPtr row_ptr, const uint32_t &column_cnt) noexcept; + explicit MatrixIterator(RowPtr row_ptr, const std::uint32_t &column_cnt) noexcept; auto operator++() noexcept -> MatrixIterator &; auto operator++(int) noexcept -> MatrixIterator; @@ -59,7 +59,7 @@ public: private: RowPtr _row_ptr; - const uint32_t &_column_cnt; + const std::uint32_t &_column_cnt; }; #include "matrix_iterator_impl.hpp" diff --git a/src/engine/graphics/matrix_iterator_impl.hpp b/src/engine/graphics/matrix_iterator_impl.hpp index 4b2c785..95846fe 100644 --- a/src/engine/graphics/matrix_iterator_impl.hpp +++ b/src/engine/graphics/matrix_iterator_impl.hpp @@ -51,7 +51,7 @@ auto MatrixRowIterator<Element>::operator!=(const MatrixRowIterator &rhs) const // Matrix row template <typename Element> -MatrixRow<Element>::MatrixRow(RowPtr row_ptr, const uint32_t &column_cnt) noexcept +MatrixRow<Element>::MatrixRow(RowPtr row_ptr, const std::uint32_t &column_cnt) noexcept : _row_ptr(row_ptr), _column_cnt(column_cnt) { } @@ -73,7 +73,7 @@ auto MatrixRow<Element>::end() const noexcept -> MatrixRowIterator<Element> template <typename Element> MatrixIterator<Element>::MatrixIterator( RowPtr row_ptr, - const uint32_t &column_cnt) noexcept + const std::uint32_t &column_cnt) noexcept : _row_ptr(row_ptr), _column_cnt(column_cnt) { } diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp index e4bdb6e..ff64edd 100644 --- a/src/engine/graphics/scene.cpp +++ b/src/engine/graphics/scene.cpp @@ -39,7 +39,7 @@ void Scene::enter() noexcept // ICANON - Canonical mode (line by line input) // ISIG - Generate the corresponding signals for the characters // INTR, QUIT, SUSP and DSUSP - new_termios.c_lflag &= static_cast<uint32_t>(~(ECHO | ICANON | ISIG)); + new_termios.c_lflag &= static_cast<std::uint32_t>(~(ECHO | ICANON | ISIG)); // Set a new terminal state tcsetattr(STDIN_FILENO, TCSAFLUSH, &new_termios); diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp index e3ad56c..a372ca7 100644 --- a/src/engine/user/cursor.cpp +++ b/src/engine/user/cursor.cpp @@ -12,7 +12,7 @@ CursorController::CursorController() noexcept void CursorController::move( const Vector2 &direction, - const uint32_t &amount, + const std::uint32_t &amount, bool flush_cout) noexcept { auto direction_format = direction_format_map.at(direction); diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp index 8f352ef..06c6b88 100644 --- a/src/engine/user/cursor.hpp +++ b/src/engine/user/cursor.hpp @@ -39,7 +39,7 @@ class CursorController : public ICursorController, public: CursorController() noexcept; - void move(const Vector2 &direction, const uint32_t &amount, bool flush_cout) noexcept + void move(const Vector2 &direction, const std::uint32_t &amount, bool flush_cout) noexcept override; void move_to(const Vector2 &position, bool flush_cout) noexcept override; diff --git a/src/game/components/statusline.cpp b/src/game/components/statusline.cpp index 3903792..c2fe7ea 100644 --- a/src/game/components/statusline.cpp +++ b/src/game/components/statusline.cpp @@ -30,12 +30,12 @@ void StatusLine::set_need_render(bool need_render) noexcept _need_render = need_render; } -auto StatusLine::get_foreground_color() const noexcept -> uint32_t +auto StatusLine::get_foreground_color() const noexcept -> std::uint32_t { - return static_cast<uint32_t>(fmt::color::white); + return static_cast<std::uint32_t>(fmt::color::white); } -auto StatusLine::get_background_color() const noexcept -> uint32_t +auto StatusLine::get_background_color() const noexcept -> std::uint32_t { return STATUSLINE_COLOR; } @@ -43,7 +43,7 @@ auto StatusLine::get_background_color() const noexcept -> uint32_t void StatusLine::set_section_status( StatusLineSection section, const std::string_view &status, - int32_t start) noexcept + std::int32_t start) noexcept { if (status.length() == 0U) { @@ -56,11 +56,11 @@ void StatusLine::set_section_status( auto pos = Vector2({.x = section_start + start, .y = 0}); - const auto column_cnt = static_cast<int32_t>(_component_matrix->get_column_cnt()); + const auto column_cnt = static_cast<std::int32_t>(_component_matrix->get_column_cnt()); const auto section_length = _section_lengths[section]; - const auto status_len = static_cast<int32_t>(status.length()); + const auto status_len = static_cast<std::int32_t>(status.length()); const auto section_style = _section_styles.contains(section) ? _section_styles.at(section) : Style(); @@ -104,7 +104,7 @@ void StatusLine::set_section_status( _matrix_write_string( pos, - status.substr(status_offset_start, static_cast<uint32_t>(final_status_length))); + status.substr(status_offset_start, static_cast<std::uint32_t>(final_status_length))); pos = pos.to_direction(Vector2::right(), final_status_length); @@ -120,7 +120,7 @@ void StatusLine::set_section_status( set_need_render(true); } -void StatusLine::set_section_length(StatusLineSection section, int32_t length) noexcept +void StatusLine::set_section_length(StatusLineSection section, std::int32_t length) noexcept { _section_lengths[section] = length; } @@ -144,17 +144,17 @@ void StatusLine::_matrix_write_string( } } -auto StatusLine::_get_section_start_x(StatusLineSection section) const noexcept -> int32_t +auto StatusLine::_get_section_start_x(StatusLineSection section) const noexcept -> std::int32_t { - int32_t section_start = 0; + std::int32_t section_start = 0; - auto section_index = static_cast<int32_t>(section); + auto section_index = static_cast<std::int32_t>(section); while (section_index > 0) { const auto prev_section = static_cast<StatusLineSection>(section_index - 1); - section_start += static_cast<int32_t>(_section_lengths.at(prev_section)); + section_start += static_cast<std::int32_t>(_section_lengths.at(prev_section)); section_index--; } @@ -162,7 +162,7 @@ auto StatusLine::_get_section_start_x(StatusLineSection section) const noexcept return section_start; } -void StatusLine::_clear_section(StatusLineSection section, int32_t start) noexcept +void StatusLine::_clear_section(StatusLineSection section, std::int32_t start) noexcept { auto section_start = _get_section_start_x(section); diff --git a/src/game/components/statusline.hpp b/src/game/components/statusline.hpp index e009174..4451fde 100644 --- a/src/game/components/statusline.hpp +++ b/src/game/components/statusline.hpp @@ -10,7 +10,7 @@ #include <string_view> #include <unordered_map> -constexpr uint32_t STATUSLINE_COLOR = 0x1A1A1AU; +constexpr std::uint32_t STATUSLINE_COLOR = 0x1A1A1AU; class StatusLine : public IStatusLine { @@ -23,23 +23,23 @@ public: void set_need_render(bool need_render) noexcept override; - auto get_foreground_color() const noexcept -> uint32_t override; + auto get_foreground_color() const noexcept -> std::uint32_t override; - auto get_background_color() const noexcept -> uint32_t override; + auto get_background_color() const noexcept -> std::uint32_t override; void set_section_status( StatusLineSection section, const std::string_view &status, - int32_t start) noexcept override; + std::int32_t start) noexcept override; - void set_section_length(StatusLineSection section, int32_t length) noexcept override; + void set_section_length(StatusLineSection section, std::int32_t length) noexcept override; void set_section_style(StatusLineSection section, const Style &style) noexcept override; private: std::shared_ptr<ComponentMatrix> _component_matrix; - std::unordered_map<StatusLineSection, int32_t> _section_lengths; + std::unordered_map<StatusLineSection, std::int32_t> _section_lengths; std::unordered_map<StatusLineSection, Style> _section_styles; bool _need_render; @@ -47,7 +47,7 @@ private: _matrix_write_string(const Vector2 &position, const std::string_view &str) noexcept; [[nodiscard]] auto _get_section_start_x(StatusLineSection section) const noexcept - -> int32_t; + -> std::int32_t; - void _clear_section(StatusLineSection section, int32_t start) noexcept; + void _clear_section(StatusLineSection section, std::int32_t start) noexcept; }; diff --git a/src/game/game.cpp b/src/game/game.cpp index 2c00b4b..921f21d 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -82,7 +82,7 @@ void Game::on_start() statusline->set_section_style( StatusLineSection::A, - {.bg_color = static_cast<uint32_t>(fmt::color::green), + {.bg_color = static_cast<std::uint32_t>(fmt::color::green), .bold = true, .padding_left = 1U, .padding_right = 1U}); @@ -443,7 +443,7 @@ void Game::_on_command_mode_update() noexcept { const auto position = _cursor_controller->where(); - const auto input_pos_x = static_cast<uint32_t>(position.get_x()) - 1U; + const auto input_pos_x = static_cast<std::uint32_t>(position.get_x()) - 1U; if (input_pos_x == 0U) { @@ -480,7 +480,7 @@ void Game::_on_command_mode_update() noexcept break; case keycodes::RIGHT_ARROW: - if (static_cast<uint32_t>(_cursor_controller->where().get_x()) - 1U < + if (static_cast<std::uint32_t>(_cursor_controller->where().get_x()) - 1U < _command_mode_input.size()) { _cursor_controller->move(Vector2::right(), 1U, true); @@ -495,7 +495,7 @@ void Game::_on_command_mode_update() noexcept default: const auto position = _cursor_controller->where(); - const auto input_pos_x = static_cast<uint32_t>(position.get_x()) - 1U; + const auto input_pos_x = static_cast<std::uint32_t>(position.get_x()) - 1U; if (input_pos_x < _command_mode_input.length()) { diff --git a/src/game/game.hpp b/src/game/game.hpp index ed5a00f..da1ba11 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -86,7 +86,7 @@ private: CursorStyle _normal_mode_cursor_style; CursorStyle _command_mode_cursor_style; - int32_t _minimum_cursor_pos_y; + std::int32_t _minimum_cursor_pos_y; std::optional<Vector2> _last_pos_before_command_mode; @@ -96,7 +96,7 @@ private: std::chrono::system_clock::time_point _last_gen_update_time; - int64_t _generations_per_second = DEFAULT_GENERATIONS_PER_SECOND; + std::int64_t _generations_per_second = DEFAULT_GENERATIONS_PER_SECOND; std::list<Vector2> _living_cell_positions; diff --git a/src/game/generation_tracker.cpp b/src/game/generation_tracker.cpp index 15b4ce4..1a90d6b 100644 --- a/src/game/generation_tracker.cpp +++ b/src/game/generation_tracker.cpp @@ -2,12 +2,12 @@ GenerationTracker::GenerationTracker(bool is_paused) noexcept : _is_paused(is_paused) {} -auto GenerationTracker::get_current_generation() const noexcept -> uint32_t +auto GenerationTracker::get_current_generation() const noexcept -> std::uint32_t { return _current_generation; } -void GenerationTracker::set_current_generation(uint32_t current_generation) noexcept +void GenerationTracker::set_current_generation(std::uint32_t current_generation) noexcept { _current_generation = current_generation; } diff --git a/src/game/generation_tracker.hpp b/src/game/generation_tracker.hpp index 1a83d71..7c67280 100644 --- a/src/game/generation_tracker.hpp +++ b/src/game/generation_tracker.hpp @@ -9,16 +9,16 @@ class GenerationTracker : public IGenerationTracker public: explicit GenerationTracker(bool is_paused) noexcept; - [[nodiscard]] auto get_current_generation() const noexcept -> uint32_t override; + [[nodiscard]] auto get_current_generation() const noexcept -> std::uint32_t override; - void set_current_generation(uint32_t current_generation) noexcept override; + void set_current_generation(std::uint32_t current_generation) noexcept override; [[nodiscard]] auto get_is_paused() const noexcept -> bool override; void set_is_paused(bool is_paused) noexcept override; private: - uint32_t _current_generation = 0U; + std::uint32_t _current_generation = 0U; bool _is_paused; }; diff --git a/src/game/status_manager.hpp b/src/game/status_manager.hpp index 8224003..c101289 100644 --- a/src/game/status_manager.hpp +++ b/src/game/status_manager.hpp @@ -26,5 +26,5 @@ public: private: std::shared_ptr<IStatusLine> _statusline; - std::unordered_map<StatusLineSection, int32_t> _section_title_lengths; + std::unordered_map<StatusLineSection, std::int32_t> _section_title_lengths; }; diff --git a/src/interfaces/component.hpp b/src/interfaces/component.hpp index 2f62c95..bf0680a 100644 --- a/src/interfaces/component.hpp +++ b/src/interfaces/component.hpp @@ -29,7 +29,7 @@ public: virtual void set_need_render(bool need_render) noexcept = 0; - [[nodiscard]] virtual auto get_foreground_color() const noexcept -> uint32_t = 0; + [[nodiscard]] virtual auto get_foreground_color() const noexcept -> std::uint32_t = 0; - [[nodiscard]] virtual auto get_background_color() const noexcept -> uint32_t = 0; + [[nodiscard]] virtual auto get_background_color() const noexcept -> std::uint32_t = 0; }; diff --git a/src/interfaces/cursor.hpp b/src/interfaces/cursor.hpp index 90d45da..a21e7a2 100644 --- a/src/interfaces/cursor.hpp +++ b/src/interfaces/cursor.hpp @@ -24,7 +24,7 @@ public: virtual void move( const Vector2 &direction, - const uint32_t &amount, + const std::uint32_t &amount, bool flush_cout = false) noexcept = 0; virtual void move_to(const Vector2 &position, bool flush_cout = false) noexcept = 0; diff --git a/src/interfaces/generation_tracker.hpp b/src/interfaces/generation_tracker.hpp index c3f6a7e..5f9bd13 100644 --- a/src/interfaces/generation_tracker.hpp +++ b/src/interfaces/generation_tracker.hpp @@ -11,9 +11,9 @@ class IGenerationTracker public: virtual ~IGenerationTracker() noexcept = default; - [[nodiscard]] virtual auto get_current_generation() const noexcept -> uint32_t = 0; + [[nodiscard]] virtual auto get_current_generation() const noexcept -> std::uint32_t = 0; - virtual void set_current_generation(uint32_t current_generation) noexcept = 0; + virtual void set_current_generation(std::uint32_t current_generation) noexcept = 0; [[nodiscard]] virtual auto get_is_paused() const noexcept -> bool = 0; diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp index 10a3590..8edad80 100644 --- a/src/interfaces/matrix.hpp +++ b/src/interfaces/matrix.hpp @@ -23,9 +23,9 @@ public: virtual void set(const Vector2 &pos, Element element) noexcept = 0; - [[nodiscard]] virtual auto get_row_cnt() const noexcept -> uint32_t = 0; + [[nodiscard]] virtual auto get_row_cnt() const noexcept -> std::uint32_t = 0; - [[nodiscard]] virtual auto get_column_cnt() const noexcept -> uint32_t = 0; + [[nodiscard]] virtual auto get_column_cnt() const noexcept -> std::uint32_t = 0; [[nodiscard]] virtual auto begin() const noexcept -> MatrixIterator<Element> = 0; diff --git a/src/interfaces/statusline.hpp b/src/interfaces/statusline.hpp index ff6e1a9..c9fd392 100644 --- a/src/interfaces/statusline.hpp +++ b/src/interfaces/statusline.hpp @@ -30,10 +30,10 @@ public: virtual void set_section_status( StatusLineSection section, const std::string_view &status, - int32_t start = 1) noexcept = 0; + std::int32_t start = 1) noexcept = 0; virtual void - set_section_length(StatusLineSection section, int32_t length) noexcept = 0; + set_section_length(StatusLineSection section, std::int32_t length) noexcept = 0; virtual void set_section_style(StatusLineSection section, const Style &style) noexcept = 0; diff --git a/src/util/color.cpp b/src/util/color.cpp index 8ec3ad4..4d50cf5 100644 --- a/src/util/color.cpp +++ b/src/util/color.cpp @@ -2,13 +2,13 @@ #include <fmt/color.h> -auto get_foreground_esc_seq(const uint32_t &color) noexcept -> std::string +auto get_foreground_esc_seq(const std::uint32_t &color) noexcept -> std::string { return { fmt::detail::make_foreground_color<char>(fmt::detail::color_type(color)).begin()}; } -auto get_background_esc_seq(const uint32_t &color) noexcept -> std::string +auto get_background_esc_seq(const std::uint32_t &color) noexcept -> std::string { return { fmt::detail::make_background_color<char>(fmt::detail::color_type(color)).begin()}; diff --git a/src/util/color.hpp b/src/util/color.hpp index f7c38d2..2bb147c 100644 --- a/src/util/color.hpp +++ b/src/util/color.hpp @@ -5,6 +5,6 @@ constexpr fmt::string_view RESET_ALL_MODES = "{esc}[0m"; -auto get_foreground_esc_seq(const uint32_t &color) noexcept -> std::string; +auto get_foreground_esc_seq(const std::uint32_t &color) noexcept -> std::string; -auto get_background_esc_seq(const uint32_t &color) noexcept -> std::string; +auto get_background_esc_seq(const std::uint32_t &color) noexcept -> std::string; diff --git a/src/util/hash_impl.hpp b/src/util/hash_impl.hpp index 146cfa0..ea9e7d1 100644 --- a/src/util/hash_impl.hpp +++ b/src/util/hash_impl.hpp @@ -14,8 +14,8 @@ template <typename Value> void hash_combine(std::size_t &seed, const Value &value) noexcept { - constexpr uint32_t shift_left = 6; - constexpr uint32_t shift_right = 2; + constexpr std::uint32_t shift_left = 6; + constexpr std::uint32_t shift_right = 2; seed ^= std::hash<Value>()(value) + GOLDEN_RATIO + (seed << shift_left) + (seed >> shift_right); |