cpp-hocon  0.3.0
config_concatenation.hpp
1 #pragma once
2 
3 #include <hocon/config_value.hpp>
4 #include <internal/unmergeable.hpp>
5 #include <internal/container.hpp>
6 #include <string>
7 #include <vector>
8 
9 namespace hocon {
10 
11  struct config_exception;
12 
24  class config_concatenation : public config_value, public unmergeable, public container {
25  public:
26  config_concatenation(shared_origin origin, std::vector<shared_value> pieces);
27 
28  config_value::type value_type() const override;
29  std::vector<shared_value> unmerged_values() const override;
30 
31  resolve_status get_resolve_status() const override;
32 
33  shared_value replace_child(shared_value const& child, shared_value replacement) const override;
34  bool has_descendant(shared_value const& descendant) const override;
35  resolve_result<shared_value> resolve_substitutions(resolve_context const& context, resolve_source const& source) const override;
36 
37  static std::vector<shared_value> consolidate(std::vector<shared_value> pieces);
38  static shared_value concatenate(std::vector<shared_value> pieces);
39  shared_value relativized(std::string prefix) const override;
40 
41  unwrapped_value unwrapped() const override;
42 
43  bool operator==(config_value const& other) const override;
44 
45  protected:
46  shared_value new_copy(shared_origin origin) const override;
47  bool ignores_fallbacks() const override;
48  void render(std::string& result, int indent, bool at_root, config_render_options options) const override;
49 
50  private:
51  std::vector<shared_value> _pieces;
52 
53  config_exception not_resolved() const;
54  static bool is_ignored_whitespace(shared_value value);
55  static void join(std::vector<shared_value> & builder, shared_value right);
56  };
57 
58 } // namespace hocon
59 
hocon::config_value::origin
virtual shared_origin const & origin() const
The origin of the value (file, line number, etc.), for debugging and error messages.
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::resolve_context
Definition: resolve_context.hpp:16
hocon::config_value::render
virtual std::string render() const
Renders the config value as a HOCON string.
hocon::config_concatenation::replace_child
shared_value replace_child(shared_value const &child, shared_value replacement) const override
Replace a child of this value.
hocon::config_concatenation::has_descendant
bool has_descendant(shared_value const &descendant) const override
Super-expensive full traversal to see if descendant is anywhere underneath this container.
hocon::resolve_result< shared_value >
hocon::config_render_options
Definition: config_render_options.hpp:20
hocon::config_concatenation::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::config_exception
All exceptions thrown by the library are subclasses of config_exception.
Definition: config_exception.hpp:14
hocon::config_value
An immutable value, following the JSON type schema.
Definition: config_value.hpp:39
hocon::unmergeable
Interface that tags a config_value that is not mergeable until after substitutions are resolved.
Definition: unmergeable.hpp:14
hocon::container
An Abstractconfig_value which contains other values.
Definition: container.hpp:12
hocon::config_concatenation
A config_concatenation represents a list of values to be concatenated (see the spec).
Definition: config_concatenation.hpp:24
hocon::resolve_source
Definition: resolve_source.hpp:15
hocon::config_concatenation::relativized
shared_value relativized(std::string prefix) const override
This is used when including one file in another; the included file is relativized to the path it's in...