SectionPairDocumentProvider.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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-16
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include "SectionPairDocumentProvider.hpp"
  11. #include <classes/io/section-pair/SectionPairSectionProvider.hpp>
  12. #include <ls-std/ls-std-io.hpp>
  13. using ls::standard::core::type::byte_field;
  14. using ls::standard::io::NewLine;
  15. using ls::standard::io::SectionPairDocument;
  16. using ls::standard::io::SectionPairRow;
  17. using ls::standard::io::SectionPairRowEnumType;
  18. using ls::standard::io::SectionPairRowSingleValue;
  19. using ls::standard::io::SectionPairSection;
  20. using std::dynamic_pointer_cast;
  21. using std::make_shared;
  22. using std::shared_ptr;
  23. using std::string;
  24. using test::io::SectionPairDocumentProvider;
  25. using test::io::SectionPairSectionProvider;
  26. SectionPairDocumentProvider::SectionPairDocumentProvider() = default;
  27. SectionPairDocumentProvider::~SectionPairDocumentProvider() = default;
  28. shared_ptr<SectionPairDocument> SectionPairDocumentProvider::createDocument()
  29. {
  30. auto document = make_shared<SectionPairDocument>();
  31. // general section
  32. const shared_ptr<SectionPairSection> generalSection = SectionPairSectionProvider::createSectionWithSandraExample();
  33. document->add(generalSection);
  34. // physical
  35. const auto physicalSection = make_shared<SectionPairSection>("physical");
  36. const auto eyeColor = make_shared<SectionPairRow>("eye-color", SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  37. dynamic_pointer_cast<SectionPairRowSingleValue>(eyeColor->getValue())->set("blue");
  38. physicalSection->add(eyeColor);
  39. const auto hairColor = make_shared<SectionPairRow>("hair-color", SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  40. dynamic_pointer_cast<SectionPairRowSingleValue>(hairColor->getValue())->set("red");
  41. physicalSection->add(hairColor);
  42. const auto height = make_shared<SectionPairRow>("height", SectionPairRowEnumType::SECTION_PAIR_ROW_SINGLE_VALUE);
  43. dynamic_pointer_cast<SectionPairRowSingleValue>(height->getValue())->set("167");
  44. physicalSection->add(height);
  45. document->add(physicalSection);
  46. return document;
  47. }
  48. byte_field SectionPairDocumentProvider::createSerializedDocument(const string &_newLine)
  49. {
  50. byte_field serializedDocument = "# section-pair document" + _newLine;
  51. // general section
  52. serializedDocument += SectionPairSectionProvider::createSerializedSectionWithSandraExample(_newLine);
  53. // physical
  54. serializedDocument += _newLine + "[physical]" + _newLine + _newLine;
  55. serializedDocument += "eye-color=blue" + _newLine;
  56. serializedDocument += "hair-color=red" + _newLine;
  57. serializedDocument += "height=167" + _newLine;
  58. return serializedDocument;
  59. }
  60. byte_field SectionPairDocumentProvider::createSerializedDocumentColineExample(const string &_newLine)
  61. {
  62. const string paragraph = _newLine + _newLine;
  63. const string _resourcesFolderLocation = R"lit(C:\Users\Admin\CLionProjects\coline-documentation\test\resources)lit";
  64. byte_field fileContent = "# section-pair document" + paragraph;
  65. fileContent += "[general]" + paragraph;
  66. fileContent += "name=Lynar Studios - Standard Library" + _newLine;
  67. fileContent += "version=2023.2.0" + paragraph;
  68. fileContent += "[input]" + paragraph;
  69. fileContent += "directories:" + _newLine;
  70. fileContent += " " + _resourcesFolderLocation + "source" + _newLine;
  71. fileContent += "extensions:" + _newLine;
  72. fileContent += " .cpp" + paragraph;
  73. fileContent += "[output]" + paragraph;
  74. fileContent += "directory=" + _resourcesFolderLocation + "doc" + _newLine;
  75. return fileContent;
  76. }
  77. byte_field SectionPairDocumentProvider::createSerializedDocumentComputerExample(const string &_newLine)
  78. {
  79. byte_field serializedDocument = "# section-pair document" + _newLine;
  80. serializedDocument += _newLine + "[model]" + _newLine + _newLine;
  81. serializedDocument += "graphics-card=GTX 720" + _newLine;
  82. serializedDocument += "ram-size=4096" + _newLine;
  83. serializedDocument += "graphics-ram-size=4096" + _newLine;
  84. serializedDocument += "cpu=Intel i7" + _newLine;
  85. serializedDocument += _newLine + "[requirements]" + _newLine + _newLine;
  86. serializedDocument += "graphics-ram-size=2048" + _newLine;
  87. serializedDocument += "io-devices:" + _newLine;
  88. serializedDocument += " mouse" + _newLine;
  89. serializedDocument += " keyboard" + _newLine;
  90. serializedDocument += " screen" + _newLine;
  91. serializedDocument += " headset" + _newLine;
  92. return serializedDocument;
  93. }