SectionPairSectionProvider.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-15
  6. * Changed: 2023-02-15
  7. *
  8. * */
  9. #include "SectionPairSectionProvider.hpp"
  10. test::io::SectionPairSectionProvider::SectionPairSectionProvider() = default;
  11. test::io::SectionPairSectionProvider::~SectionPairSectionProvider() = default;
  12. ::std::shared_ptr<ls::std::io::SectionPairSection> test::io::SectionPairSectionProvider::createSection()
  13. {
  14. ::std::shared_ptr<ls::std::io::SectionPairSection> section = ::std::make_shared<ls::std::io::SectionPairSection>("general");
  15. ::std::shared_ptr<ls::std::io::SectionPairRow> name = ::std::make_shared<ls::std::io::SectionPairRow>("name", ls::std::io::SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  16. ::std::dynamic_pointer_cast<ls::std::io::SectionPairRowSingleValue>(name->getValue())->set("Tom");
  17. section->add(name);
  18. ::std::shared_ptr<ls::std::io::SectionPairRow> jobs = ::std::make_shared<ls::std::io::SectionPairRow>("jobs", ls::std::io::SectionPairRowEnumType::SECTION_PAIR_ROW_LIST_VALUE);
  19. ::std::shared_ptr<ls::std::io::SectionPairRowListValue> jobList = ::std::dynamic_pointer_cast<ls::std::io::SectionPairRowListValue>(jobs->getValue());
  20. jobList->add("Farmer");
  21. jobList->add("Bounty Hunter");
  22. section->add(jobs);
  23. ::std::shared_ptr<ls::std::io::SectionPairRow> age = ::std::make_shared<ls::std::io::SectionPairRow>("age", ls::std::io::SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  24. ::std::dynamic_pointer_cast<ls::std::io::SectionPairRowSingleValue>(age->getValue())->set("33");
  25. section->add(age);
  26. return section;
  27. }
  28. ls::std::core::type::byte_field test::io::SectionPairSectionProvider::createSerializedSection()
  29. {
  30. ::std::string newLine = ls::std::io::NewLine::get();
  31. ls::std::core::type::byte_field serializedSection = newLine + "[general]" + newLine;
  32. ls::std::core::type::byte_field serializedNameRow = "name=Tom" + newLine;
  33. ls::std::core::type::byte_field serializedJobsRow = "jobs:" + newLine + " Farmer" + newLine + " Bounty Hunter" + newLine;
  34. ls::std::core::type::byte_field serializedAgeRow = "age=33" + newLine;
  35. return serializedSection + serializedNameRow + serializedJobsRow + serializedAgeRow;
  36. }