KvParser.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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
  18. {
  19. namespace std
  20. {
  21. namespace io
  22. {
  23. class LS_STD_DYNAMIC_GOAL KvParser : public ls::std::core::Class
  24. {
  25. public:
  26. explicit KvParser(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  27. ~KvParser() override = default;
  28. ::std::shared_ptr<ls::std::io::KvDocument> getDocument();
  29. void parse(const ls::std::core::type::byte_field &_data);
  30. void setDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  31. private:
  32. ::std::shared_ptr<ls::std::io::KvDocument> document{};
  33. void _assignDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  34. static bool _contains(const ::std::string &_text, const ::std::string &_searchText);
  35. static bool _lineHasPair(const ls::std::io::KvParseParameter& _parseParameter);
  36. void _parse(const ls::std::core::type::byte_field &_data);
  37. void _parsePair(const ls::std::io::KvParseParameter& _parseParameter);
  38. static ls::std::io::KvParseParameter _readLine(const ls::std::core::type::byte_field &_data, ::std::string::size_type _index);
  39. static void _readLineWithUnixLineBreak(ls::std::io::KvParseParameter &_parseParameter);
  40. static void _readLineWithWindowsLineBreak(ls::std::io::KvParseParameter &_parseParameter);
  41. };
  42. }
  43. }
  44. }
  45. #endif