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: 2022-07-03
  7. *
  8. * */
  9. #ifndef LS_STD_KV_PARSER_HPP
  10. #define LS_STD_KV_PARSER_HPP
  11. #include <ls_std/core/Class.hpp>
  12. #include <ls_std/core/types/Types.hpp>
  13. #include "KvDocument.hpp"
  14. #include "KvParseParameter.hpp"
  15. #include <memory>
  16. #include <ls_std/os/dynamic_goal.hpp>
  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 = default;
  24. ::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. static bool _contains(const ::std::string &_text, const ::std::string &_searchText);
  31. static bool _lineHasPair(const ls::std::io::KvParseParameter &_parseParameter);
  32. void _parse(const ls::std::core::type::byte_field &_data);
  33. void _parsePair(const ls::std::io::KvParseParameter &_parseParameter);
  34. 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