SerializableSectionPairRowSingleValue.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-11
  6. * Changed: 2023-05-18
  7. *
  8. * */
  9. #include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
  10. #include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
  11. #include <ls-std/io/section-pair/model/SectionPairRowSingleValue.hpp>
  12. #include <ls-std/io/section-pair/serialization/SerializableSectionPairRowSingleValue.hpp>
  13. using ls::std::core::Class;
  14. using ls::std::core::EmptyStringArgumentEvaluator;
  15. using ls::std::core::NullPointerArgumentEvaluator;
  16. using ls::std::core::type::byte_field;
  17. using ls::std::io::SectionPairRowSingleValue;
  18. using ls::std::io::SerializableSectionPairParameter;
  19. using ls::std::io::SerializableSectionPairRowSingleValue;
  20. using std::dynamic_pointer_cast;
  21. using std::shared_ptr;
  22. using std::string;
  23. SerializableSectionPairRowSingleValue::SerializableSectionPairRowSingleValue(const SerializableSectionPairParameter &_parameter) : Class("SerializableSectionPairRowSingleValue"), parameter(_parameter)
  24. {
  25. string message = this->getClassName() + ": model reference is null!";
  26. NullPointerArgumentEvaluator{_parameter.getValue(), message}.evaluate();
  27. }
  28. SerializableSectionPairRowSingleValue::~SerializableSectionPairRowSingleValue() noexcept = default;
  29. shared_ptr<Class> SerializableSectionPairRowSingleValue::getValue() const
  30. {
  31. return this->parameter.getValue();
  32. }
  33. byte_field SerializableSectionPairRowSingleValue::marshal()
  34. {
  35. return dynamic_pointer_cast<SectionPairRowSingleValue>(this->parameter.getValue())->get() + this->parameter.getNewLine();
  36. }
  37. void SerializableSectionPairRowSingleValue::unmarshal(const byte_field &_data)
  38. {
  39. EmptyStringArgumentEvaluator{_data}.evaluate();
  40. dynamic_pointer_cast<SectionPairRowSingleValue>(this->parameter.getValue())->set(_data);
  41. }