KvParser.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-12-25
  6. * Changed: 2022-05-12
  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. namespace ls
  17. {
  18. namespace std
  19. {
  20. namespace io
  21. {
  22. class KvParser : public ls::std::core::Class
  23. {
  24. public:
  25. explicit KvParser(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  26. ~KvParser() override = default;
  27. ::std::shared_ptr<ls::std::io::KvDocument> getDocument();
  28. void parse(const ls::std::core::type::byte_field &_data);
  29. void setDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  30. private:
  31. ::std::shared_ptr<ls::std::io::KvDocument> document{};
  32. void _assignDocument(const ::std::shared_ptr<ls::std::io::KvDocument> &_document);
  33. static bool _lineHasPair(ls::std::io::KvParseParameter _parseParameter);
  34. void _parse(const ls::std::core::type::byte_field &_data);
  35. void _parsePair(ls::std::io::KvParseParameter _parseParameter);
  36. static ls::std::io::KvParseParameter _readLine(const ls::std::core::type::byte_field &_data, ::std::string::size_type _index);
  37. static void _readLineWithUnixLineBreak(ls::std::io::KvParseParameter &_parseParameter);
  38. static void _readLineWithWindowsLineBreak(ls::std::io::KvParseParameter &_parseParameter);
  39. };
  40. }
  41. }
  42. }
  43. #endif