SerializableJSONLong.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-25
  6. * Changed: 2021-05-01
  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. {
  17. class SerializableJSONLong : public ls_std::Class, public ls_std::ISerializable
  18. {
  19. public:
  20. explicit SerializableJSONLong(const std::shared_ptr<ls_std::Long> &_value);
  21. ~SerializableJSONLong() override = default;
  22. // implementation
  23. ls_std::byte_field marshal() override;
  24. void unmarshal(const ls_std::byte_field &_data) override;
  25. // additional functionality
  26. std::shared_ptr<ls_std::Long> getValue();
  27. void setValue(const std::shared_ptr<ls_std::Long> &_value);
  28. private:
  29. nlohmann::json jsonObject{};
  30. std::shared_ptr<ls_std::Long> value{};
  31. void _assignValue(const std::shared_ptr<ls_std::Long> &_value);
  32. void _update();
  33. };
  34. }
  35. #endif