diff --git a/include/billy_objects.hpp b/include/billy_objects.hpp index c675a52..f20b9ec 100644 --- a/include/billy_objects.hpp +++ b/include/billy_objects.hpp @@ -46,9 +46,13 @@ namespace character { static std::string_view billy_object_to_string(const billyObjects &object) noexcept; - static void to_json(json &j, const container &billy); + static void to_json(json &j, const BillyObjects::container &billy); - static void from_json(const json &j, container &billy); + static void from_json(const json &j, BillyObjects::container &billy); + + BillyObjects() noexcept = default; + + ~BillyObjects() noexcept = default; [[nodiscard]] bool insert_object(CharacterSheet &sheet, const billyEnums objType) noexcept; diff --git a/src/billy_objects.cpp b/src/billy_objects.cpp index e737294..d1eb30d 100644 --- a/src/billy_objects.cpp +++ b/src/billy_objects.cpp @@ -3,7 +3,7 @@ #include "character_sheet.hpp" #include -constexpr std::uint32_t const_hash(const char *input) { +std::uint32_t constexpr const_hash(const char *input) { return *input ? static_cast(*input) + 33 * const_hash(input + 1) : 5381; } @@ -104,7 +104,7 @@ namespace character { return object->to_string(); } - void BillyObjects::from_json(const json &j, container &billy) { + void BillyObjects::from_json(const json &j, BillyObjects::container &billy) { for (const auto &element: j) { const std::uint32_t key = element[0].get(); const std::uint8_t value = element[1].get(); @@ -119,13 +119,11 @@ namespace character { case toolsHash: billy.emplace(static_cast(value), std::make_unique(static_cast(value))); break; - default: - throw std::logic_error("Wrong hash for from_json in BillyObjects::from_json"); } } } - void BillyObjects::to_json(json &j, const container &billy) { + void BillyObjects::to_json(json &j, const BillyObjects::container &billy) { for (const auto &[object_type, _]: billy) { std::visit(overloaded{ [&j](const weapons weapon) {