cpp-hocon 0.3.0
Loading...
Searching...
No Matches
token.hpp
1#pragma once
2
3#include "simple_config_origin.hpp"
4
5#include <string>
6
7namespace hocon {
8
9 enum class token_type {
10 START, END, COMMA, EQUALS, COLON, OPEN_CURLY, CLOSE_CURLY, OPEN_SQUARE, CLOSE_SQUARE,
11 VALUE, NEWLINE, UNQUOTED_TEXT, IGNORED_WHITESPACE, SUBSTITUTION, PROBLEM, COMMENT, PLUS_EQUALS
12 };
13
14 struct unsupported_exception : std::runtime_error {
15 explicit unsupported_exception(std::string const& message);
16 };
17
18 class token {
19 public:
20 token(token_type type, shared_origin origin = nullptr,
21 std::string token_text = "", std::string debug_string = "");
22
23 virtual token_type get_token_type() const;
24 virtual std::string token_text() const;
25 virtual std::string to_string() const;
26 virtual shared_origin const& origin() const;
27
28 int line_number() const;
29
30 virtual bool operator==(const token& other) const;
31
32 private:
33 token_type _token_type;
34
36 shared_origin _origin;
37
38 std::string _token_text;
39 std::string _debug_string;
40 };
41
42 using shared_token = std::shared_ptr<const token>;
43 using token_list = std::vector<shared_token>;
44
45} // namespace hocon
Factory for creating config_document instances.
Definition: config.hpp:18