cpp-hocon 0.3.0
Loading...
Searching...
No Matches
resolve_context.hpp
1#pragma once
2
3#include <hocon/types.hpp>
4#include <hocon/config_resolve_options.hpp>
5#include <hocon/path.hpp>
6
7#include <unordered_map>
8
9namespace hocon {
10
11 class resolve_source;
12
13 template<typename T>
14 struct resolve_result;
15
17 public:
18 resolve_context(config_resolve_options options, path restrict_to_child, std::vector<shared_value> cycle_markers);
19 resolve_context(config_resolve_options options, path restrict_to_child);
20 bool is_restricted_to_child() const;
21 config_resolve_options options() const;
22
23 resolve_result<shared_value> resolve(shared_value original, resolve_source const& source) const;
24 path restrict_to_child() const;
25
26 resolve_context add_cycle_marker(shared_value value) const;
27 resolve_context remove_cycle_marker(shared_value value);
28 resolve_context restrict(path restrict_to) const;
29 resolve_context unrestricted() const;
30
31 static shared_value resolve(shared_value value, shared_object root, config_resolve_options options);
32
33 private:
34 struct memo_key {
35 shared_value value;
36 path restrict_to_child;
37 bool operator==(const memo_key& other) const {
38 return value == other.value && restrict_to_child == other.restrict_to_child;
39 }
40 };
41
42 struct memo_key_hash {
43 std::size_t operator()(const memo_key&) const;
44 };
45 using resolve_memos = std::unordered_map<memo_key, shared_value, memo_key_hash>;
47 path _restrict_to_child;
48 resolve_memos _memos;
49 std::vector<shared_value> _cycle_markers;
50
51 resolve_context memoize(const memo_key& key, const shared_value& value) const;
52 };
53} // namespace hocon
A set of options related to resolving substitutions.
Factory for creating config_document instances.
Definition: config.hpp:18
bool operator==(config_document const &lhs, config_document const &rhs)
Config documents compare via rendered strings.