SectionPairDocumentProvider.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-16
  6. * Changed: 2023-02-21
  7. *
  8. * */
  9. #include "SectionPairDocumentProvider.hpp"
  10. #include <classes/io/section-pair/SectionPairSectionProvider.hpp>
  11. #include <ls-std/ls-std-io.hpp>
  12. test::io::SectionPairDocumentProvider::SectionPairDocumentProvider() = default;
  13. test::io::SectionPairDocumentProvider::~SectionPairDocumentProvider() = default;
  14. ::std::shared_ptr<ls::std::io::SectionPairDocument> test::io::SectionPairDocumentProvider::createDocument()
  15. {
  16. ::std::shared_ptr<ls::std::io::SectionPairDocument> document = ::std::make_shared<ls::std::io::SectionPairDocument>();
  17. // general section
  18. ::std::shared_ptr<ls::std::io::SectionPairSection> generalSection = test::io::SectionPairSectionProvider::createSectionWithSandraExample();
  19. document->add(generalSection);
  20. // physical
  21. ::std::shared_ptr<ls::std::io::SectionPairSection> physicalSection = ::std::make_shared<ls::std::io::SectionPairSection>("physical");
  22. ::std::shared_ptr<ls::std::io::SectionPairRow> eyeColor = ::std::make_shared<ls::std::io::SectionPairRow>("eye-color", ls::std::io::SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  23. ::std::dynamic_pointer_cast<ls::std::io::SectionPairRowSingleValue>(eyeColor->getValue())->set("blue");
  24. physicalSection->add(eyeColor);
  25. ::std::shared_ptr<ls::std::io::SectionPairRow> hairColor = ::std::make_shared<ls::std::io::SectionPairRow>("hair-color", ls::std::io::SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  26. ::std::dynamic_pointer_cast<ls::std::io::SectionPairRowSingleValue>(hairColor->getValue())->set("red");
  27. physicalSection->add(hairColor);
  28. ::std::shared_ptr<ls::std::io::SectionPairRow> height = ::std::make_shared<ls::std::io::SectionPairRow>("height", ls::std::io::SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  29. ::std::dynamic_pointer_cast<ls::std::io::SectionPairRowSingleValue>(height->getValue())->set("167");
  30. physicalSection->add(height);
  31. document->add(physicalSection);
  32. return document;
  33. }
  34. ls::std::core::type::byte_field test::io::SectionPairDocumentProvider::createSerializedDocument(const ::std::string &_newLine)
  35. {
  36. ls::std::core::type::byte_field serializedDocument = "# section-pair document" + _newLine;
  37. // general section
  38. serializedDocument += test::io::SectionPairSectionProvider::createSerializedSectionWithSandraExample(_newLine);
  39. // physical
  40. serializedDocument += _newLine + "[physical]" + _newLine + _newLine;
  41. serializedDocument += "eye-color=blue" + _newLine;
  42. serializedDocument += "hair-color=red" + _newLine;
  43. serializedDocument += "height=167" + _newLine;
  44. return serializedDocument;
  45. }
  46. ls::std::core::type::byte_field test::io::SectionPairDocumentProvider::createSerializedDocumentComputerExample(const ::std::string &_newLine)
  47. {
  48. ls::std::core::type::byte_field serializedDocument = "# section-pair document" + _newLine;
  49. serializedDocument += _newLine + "[model]" + _newLine + _newLine;
  50. serializedDocument += "graphics-card=GTX 720" + _newLine;
  51. serializedDocument += "ram-size=4096" + _newLine;
  52. serializedDocument += "graphics-ram-size=4096" + _newLine;
  53. serializedDocument += "cpu=Intel i7" + _newLine;
  54. serializedDocument += _newLine + "[requirements]" + _newLine + _newLine;
  55. serializedDocument += "graphics-ram-size=2048" + _newLine;
  56. serializedDocument += "io-devices:" + _newLine;
  57. serializedDocument += " mouse" + _newLine;
  58. serializedDocument += " keyboard" + _newLine;
  59. serializedDocument += " screen" + _newLine;
  60. serializedDocument += " headset" + _newLine;
  61. return serializedDocument;
  62. }