KvParser.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-12-25
  6. * Changed: 2023-02-08
  7. *
  8. * */
  9. #ifndef LS_STD_KV_PARSER_HPP
  10. #define LS_STD_KV_PARSER_HPP
  11. #include "KvDocument.hpp"
  12. #include "KvParseParameter.hpp"
  13. #include <ls-std/core/Class.hpp>
  14. #include <ls-std/core/type/Types.hpp>
  15. #include <ls-std/os/dynamic-goal.hpp>
  16. #include <memory>
  17. namespace ls::std::io
  18. {
  19. class LS_STD_DYNAMIC_GOAL KvParser : public ls::std::core::Class
  20. {
  21. public:
  22. explicit KvParser(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  23. ~KvParser() override;
  24. [[nodiscard]] ::std::shared_ptr<ls::std::io::KvDocument> getDocument();
  25. void parse(const ls::std::core::type::byte_field &_data);
  26. void setDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  27. private:
  28. ::std::shared_ptr<ls::std::io::KvDocument> document{};
  29. void _assignDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  30. [[nodiscard]] static bool _contains(const ::std::string &_text, const ::std::string &_searchText);
  31. [[nodiscard]] static bool _lineHasPair(ls::std::io::KvParseParameter &_parseParameter);
  32. void _parse(const ls::std::core::type::byte_field &_data);
  33. void _parsePair(ls::std::io::KvParseParameter &_parseParameter);
  34. [[nodiscard]] static ls::std::io::KvParseParameter _readLine(const ls::std::core::type::byte_field &_data, ::std::string::size_type _index);
  35. static void _readLineWithUnixLineBreak(ls::std::io::KvParseParameter &_parseParameter);
  36. static void _readLineWithWindowsLineBreak(ls::std::io::KvParseParameter &_parseParameter);
  37. };
  38. }
  39. #endif