SerializableSectionPairRowProvider.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-17
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include "SerializableSectionPairRowProvider.hpp"
  11. using ls::standard::io::SectionPairRow;
  12. using ls::standard::io::SectionPairRowEnumType;
  13. using ls::standard::io::SectionPairRowListValue;
  14. using ls::standard::io::SectionPairRowSingleValue;
  15. using ls::standard::io::SerializableSectionPairParameter;
  16. using ls::standard::io::SerializableSectionPairRow;
  17. using std::dynamic_pointer_cast;
  18. using std::make_shared;
  19. using std::shared_ptr;
  20. using std::string;
  21. using test::io::SerializableSectionPairRowProvider;
  22. SerializableSectionPairRowProvider::SerializableSectionPairRowProvider() = default;
  23. SerializableSectionPairRowProvider::~SerializableSectionPairRowProvider() = default;
  24. shared_ptr<SerializableSectionPairRow> SerializableSectionPairRowProvider::createListValueForMarshal(const string &_newLine)
  25. {
  26. SerializableSectionPairParameter parameter{};
  27. parameter.setNewLine(_newLine);
  28. const auto row = make_shared<SectionPairRow>("favourite-colors", SectionPairRowEnumType::SECTION_PAIR_ROW_LIST_VALUE);
  29. parameter.setValue(row);
  30. const shared_ptr<SectionPairRowListValue> listValue = dynamic_pointer_cast<SectionPairRowListValue>(row->getValue());
  31. listValue->add("blue");
  32. listValue->add("red");
  33. listValue->add("purple");
  34. return make_shared<SerializableSectionPairRow>(parameter);
  35. }
  36. shared_ptr<SerializableSectionPairRow> SerializableSectionPairRowProvider::createListValueForUnmarshal(const string &_newLine)
  37. {
  38. SerializableSectionPairParameter parameter{};
  39. parameter.setNewLine(_newLine);
  40. const auto row = make_shared<SectionPairRow>("tmp-key", SectionPairRowEnumType::SECTION_PAIR_ROW_LIST_VALUE);
  41. parameter.setValue(row);
  42. return make_shared<SerializableSectionPairRow>(parameter);
  43. }
  44. shared_ptr<SerializableSectionPairRow> SerializableSectionPairRowProvider::createSingleValueForMarshal(const string &_newLine)
  45. {
  46. SerializableSectionPairParameter parameter{};
  47. parameter.setNewLine(_newLine);
  48. const auto row = make_shared<SectionPairRow>("favourite-color", SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  49. parameter.setValue(row);
  50. const shared_ptr<SectionPairRowSingleValue> singleValue = dynamic_pointer_cast<SectionPairRowSingleValue>(row->getValue());
  51. singleValue->set("blue");
  52. return make_shared<SerializableSectionPairRow>(parameter);
  53. }
  54. shared_ptr<SerializableSectionPairRow> SerializableSectionPairRowProvider::createSingleValueForUnmarshal(const string &_newLine)
  55. {
  56. SerializableSectionPairParameter parameter{};
  57. parameter.setNewLine(_newLine);
  58. const auto row = make_shared<SectionPairRow>("tmp-key", SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  59. parameter.setValue(row);
  60. return make_shared<SerializableSectionPairRow>(parameter);
  61. }