SerializableJSONLong.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-25
  6. * Changed: 2020-11-26
  7. *
  8. * */
  9. #ifndef LS_STD_SERIALIZABLE_JSON_LONG_HPP
  10. #define LS_STD_SERIALIZABLE_JSON_LONG_HPP
  11. #include <ls_std/base/Class.hpp>
  12. #include <ls_std/serialization/ISerializable.hpp>
  13. #include <ls_std/boxing/Long.hpp>
  14. #include <ls_std/lib/nlohmann_json/include/nlohmann/json.hpp>
  15. namespace ls_std {
  16. class SerializableJSONLong : public Class, public ISerializable {
  17. public:
  18. explicit SerializableJSONLong(const std::shared_ptr<ls_std::Long>& _value);
  19. ~SerializableJSONLong() override = default;
  20. // implementation
  21. ls_std::byte_field marshal() override;
  22. void unmarshal(const ls_std::byte_field& _data) override;
  23. // additional functionality
  24. std::shared_ptr<ls_std::Long> getValue();
  25. void setValue(const std::shared_ptr<ls_std::Long>& _value);
  26. private:
  27. nlohmann::json jsonObject {};
  28. std::shared_ptr<ls_std::Long> value {};
  29. void _assignValue(const std::shared_ptr<ls_std::Long>& _value);
  30. void _update();
  31. };
  32. }
  33. #endif