SectionPairRowSingleValue.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-10
  6. * Changed: 2023-02-13
  7. *
  8. * */
  9. #include <ls-std/core/ConditionalFunctionExecutor.hpp>
  10. #include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.hpp>
  11. #include <ls-std/io/section-pair/evaluator/SectionPairRowValueArgumentEvaluator.hpp>
  12. #include <ls-std/io/section-pair/model/SectionPairRowSingleValue.hpp>
  13. #include <ls-std/io/section-pair/serialization/SerializableSectionPairRowSingleValue.hpp>
  14. ls::std::io::SectionPairRowSingleValue::SectionPairRowSingleValue(const ls::std::io::section_pair_row_value &_value) : ls::std::core::Class("SectionPairRowSingleValue"), ls::std::io::SectionPairRowValue(ls::std::io::SECTION_PAIR_ROW_SINGLE_VALUE)
  15. {
  16. this->_set(_value);
  17. }
  18. ls::std::io::SectionPairRowSingleValue::~SectionPairRowSingleValue() = default;
  19. ls::std::io::section_pair_row_value ls::std::io::SectionPairRowSingleValue::get()
  20. {
  21. return this->value;
  22. }
  23. ls::std::io::SectionPairRowEnumType ls::std::io::SectionPairRowSingleValue::getType()
  24. {
  25. return this->type;
  26. }
  27. ls::std::core::type::byte_field ls::std::io::SectionPairRowSingleValue::marshal()
  28. {
  29. ls::std::core::ConditionalFunctionExecutor{this->serializable == nullptr}.execute([this] { _createSerializable(); });
  30. return this->serializable->marshal();
  31. }
  32. void ls::std::io::SectionPairRowSingleValue::set(const ls::std::io::section_pair_row_value &_value)
  33. {
  34. this->_set(_value);
  35. }
  36. void ls::std::io::SectionPairRowSingleValue::unmarshal(const ls::std::core::type::byte_field &_data)
  37. {
  38. ls::std::core::ConditionalFunctionExecutor{this->serializable == nullptr}.execute([this] { _createSerializable(); });
  39. this->serializable->unmarshal(_data);
  40. }
  41. void ls::std::io::SectionPairRowSingleValue::_createSerializable()
  42. {
  43. this->serializable = ::std::make_shared<ls::std::io::SerializableSectionPairRowSingleValue>(shared_from_this());
  44. }
  45. void ls::std::io::SectionPairRowSingleValue::_set(const ls::std::io::section_pair_row_value &_value)
  46. {
  47. ls::std::core::EmptyStringArgumentEvaluator{_value}.evaluate();
  48. ls::std::io::SectionPairRowValueArgumentEvaluator(_value, "section pair single value \"" + _value + "\" contains invalid characters!").evaluate();
  49. this->value = _value;
  50. }