File: resolve_source.hpp

package info (click to toggle)
cpp-hocon 0.3.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,320 kB
  • sloc: cpp: 12,223; makefile: 4
file content (55 lines) | stat: -rw-r--r-- 2,087 bytes parent folder | download | duplicates (4)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once

#include <memory>
#include <list>
#include <hocon/types.hpp>
#include <internal/resolve_result.hpp>
#include <hocon/config_exception.hpp>

namespace hocon {

    class container;
    class resolve_context;
    class substitution_expression;

    class resolve_source {
    public:
        typedef std::list<std::shared_ptr<const container>> node;

        struct result_with_path {
            resolve_result<shared_value> result;
            node path_from_root;

            result_with_path(resolve_result<shared_value> result_value, node path_from_root_value);
        };

        resolve_source(shared_object root);
        resolve_source(shared_object root, node path_from_root);
        resolve_source push_parent(std::shared_ptr<const container> parent) const;
        result_with_path lookup_subst(resolve_context context, std::shared_ptr<substitution_expression> subst, int prefix_length) const;

        resolve_source replace_current_parent(std::shared_ptr<const container> old, std::shared_ptr<const container> replacement) const;
        resolve_source replace_within_current_parent(shared_value old, shared_value replacement) const;
        resolve_source reset_parents() const;

    private:
        struct value_with_path {
            shared_value value;
            node path_from_root;

            value_with_path(shared_value v, node path_from_root_value);
        };

        shared_object _root;
        node _path_from_root;

        static value_with_path find_in_object(shared_object obj, path the_path);
        static result_with_path find_in_object(shared_object obj, resolve_context context, path the_path);
        static value_with_path find_in_object(shared_object obj, path the_path, node parents);
        static not_resolved_exception improve_not_resolved(path what, not_resolved_exception const& original);

        shared_object root_must_be_obj(std::shared_ptr<const container> value) const;

        static node replace(const node& list, std::shared_ptr<const container> old, shared_value replacement);
    };
}  // namespace hocon