aboutsummaryrefslogtreecommitdiff
path: root/include/cru/toml/TomlParser.h
blob: dcef2920ffa0793353866684041eff5ce37b7263 (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.h"
#include "cru/toml/TomlDocument.h"

#include <optional>

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

class CRU_TOML_API 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