aboutsummaryrefslogtreecommitdiff
path: root/include/cru/toml/TomlParser.hpp
blob: 52332506ef20371aa632d2fa34f0402b2b9fcb5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include "cru/common/Exception.hpp"
#include "cru/toml/TomlDocument.hpp"

#include <optional>

namespace cru::toml {
// A very simple and tolerant TOML parser.
class TomlParsingException : public Exception {
 public:
  using Exception::Exception;
};

class TomlParser {
 public:
  explicit TomlParser(String input);

  CRU_DELETE_COPY(TomlParser)
  CRU_DELETE_MOVE(TomlParser)

  ~TomlParser();

 public:
  TomlDocument Parse();

 private:
  // The document is empty to begin with.
  void DoParse(TomlDocument& document);

 private:
  String input_;

  std::optional<TomlDocument> cache_;
};
}  // namespace cru::toml