cpp-hocon  0.3.0
config_object.hpp
1 #pragma once
2 
3 #include "config_value.hpp"
4 #include "config_mergeable.hpp"
5 #include "path.hpp"
6 #include <unordered_map>
7 #include "export.h"
8 
9 namespace hocon {
10 
11  class LIBCPP_HOCON_EXPORT config_object : public config_value {
12  friend class config;
13  friend class config_value;
14  friend class simple_config_object;
15  friend class resolve_source;
16  friend class config_delayed_merge_object;
17  public:
25  virtual std::shared_ptr<const config> to_config() const;
26 
27  config_object(shared_origin origin);
28 
29  config_value::type value_type() const override;
30 
31  virtual shared_object with_value(path raw_path, shared_value value) const = 0;
32  virtual shared_object with_value(std::string key, shared_value value) const = 0;
33 
46  virtual shared_value attempt_peek_with_partial_resolve(std::string const& key) const = 0;
47 
52  virtual std::vector<std::string> key_set() const = 0;
53 
54  // map interface
55  using iterator = std::unordered_map<std::string, shared_value>::const_iterator;
56  virtual bool is_empty() const = 0;
57  virtual size_t size() const = 0;
58  virtual shared_value operator[](std::string const& key) const = 0;
59  virtual shared_value get(std::string const& key) const = 0;
60  virtual iterator begin() const = 0;
61  virtual iterator end() const = 0;
62 
63  protected:
64  shared_value peek_path(path desired_path) const;
65  shared_value peek_assuming_resolved(std::string const& key, path original_path) const;
66 
67  virtual shared_object new_copy(resolve_status const& status, shared_origin origin) const = 0;
68  shared_value new_copy(shared_origin origin) const override;
69 
70  shared_value construct_delayed_merge(shared_origin origin, std::vector<shared_value> stack) const override;
71 
72  virtual std::unordered_map<std::string, shared_value> const& entry_set() const = 0;
73  virtual shared_object without_path(path raw_path) const = 0;
74  virtual shared_object with_only_path(path raw_path) const = 0;
75  virtual shared_object with_only_path_or_null(path raw_path) const = 0;
76 
77  static shared_value peek_path(const config_object* self, path desired_path);
78  static shared_origin merge_origins(std::vector<shared_value> const& stack);
79  };
80 
81 } // namespace hocon
hocon::config_delayed_merge_object
Definition: config_delayed_merge_object.hpp:10
hocon::config
An immutable map from config paths to config values.
Definition: config.hpp:172
hocon::config_object::attempt_peek_with_partial_resolve
virtual shared_value attempt_peek_with_partial_resolve(std::string const &key) const =0
Look up the key on an only-partially-resolved object, with no transformation or type conversion of an...
hocon::config_value::type
type
The type of a configuration value (following the JSON type schema).
Definition: config_value.hpp:56
hocon
Factory for creating config_document instances.
Definition: config.hpp:18
hocon::config_object::to_config
virtual std::shared_ptr< const config > to_config() const
Converts this object to a config instance, enabling you to use path expressions to find values in the...
hocon::simple_config_object
Definition: simple_config_object.hpp:11
hocon::config_object::value_type
config_value::type value_type() const override
The type of the value; matches the JSON type schema.
hocon::value
Definition: tokens.hpp:8
hocon::path
Definition: path.hpp:13
hocon::config_value
An immutable value, following the JSON type schema.
Definition: config_value.hpp:39
hocon::resolve_source
Definition: resolve_source.hpp:15
hocon::config_object::key_set
virtual std::vector< std::string > key_set() const =0
Construct a list of keys in the _value map.
hocon::config_object
Definition: config_object.hpp:11