KvParser.hpp 1.4 KB

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