diff --git a/include/characteristic/adresse.hpp b/include/characteristic/adresse.hpp index ab2fdb2..0dda21e 100644 --- a/include/characteristic/adresse.hpp +++ b/include/characteristic/adresse.hpp @@ -2,6 +2,9 @@ #define BILLYSHEET_ADRESSE_HPP #include +#include + +using json = nlohmann::json; namespace character::characteristic { class Adresse final { @@ -15,7 +18,29 @@ namespace character::characteristic { Adresse() noexcept = default; ~Adresse() noexcept = default; + + [[nodiscard]] std::uint32_t get_base() const { return base; } + + [[nodiscard]] std::uint32_t get_carac() const { return carac; } + + [[nodiscard]] std::uint32_t get_materiel() const { return materiel; } + + [[nodiscard]] std::uint32_t get_additional() const { return additional; } + + friend void from_json(const json &j, Adresse &adresse) { + const_cast(adresse.base) = j.at("base"); + adresse.carac = j.at("carac"); + adresse.materiel =j.at("materiel"); + adresse.additional =j.at("additional"); + } }; + + void to_json(json &j, const Adresse &adresse) { + j.emplace("base", adresse.get_base()); + j.emplace("carac", adresse.get_carac()); + j.emplace("materiel", adresse.get_materiel()); + j.emplace("additional", adresse.get_additional()); + } }