KVParser.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-12-25
  6. * Changed: 2020-12-25
  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 "KVParseData.hpp"
  15. #include <memory>
  16. namespace ls_std {
  17. class KVParser : public ls_std::Class {
  18. public:
  19. explicit KVParser(const std::shared_ptr<ls_std::KVDocument>& _document);
  20. ~KVParser() override = default;
  21. std::shared_ptr<ls_std::KVDocument> getDocument();
  22. void parse(const ls_std::byte_field& _data);
  23. void setDocument(const std::shared_ptr<ls_std::KVDocument>& _document);
  24. private:
  25. std::shared_ptr<ls_std::KVDocument> document {};
  26. void _assignDocument(const std::shared_ptr<ls_std::KVDocument>& _document);
  27. static bool _lineHasPair(ls_std::KVParseData _parseData);
  28. void _parse(const ls_std::byte_field& _data);
  29. void _parsePair(ls_std::KVParseData _parseData);
  30. static ls_std::KVParseData _readLine(const ls_std::byte_field& _data, std::string::size_type _index);
  31. static void _readLineWithUnixLineBreak(ls_std::KVParseData& _parseData);
  32. static void _readLineWithWindowsLineBreak(ls_std::KVParseData& _parseData);
  33. };
  34. }
  35. #endif