SectionPairDocumentProvider.cpp 4.3 KB

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