cpp-hocon  0.3.0
Public Member Functions | List of all members
hocon::config_includer Class Referenceabstract

Implement this interface and provide an instance to config_parse_options.set_includer() to customize handling of. More...

Inheritance diagram for hocon::config_includer:
hocon::full_includer hocon::simple_includer

Public Member Functions

virtual shared_includer with_fallback (shared_includer fallback) const =0
 Returns a new includer that falls back to the given includer. More...
 
virtual shared_object include (shared_include_context context, std::string what) const =0
 Parses another item to be included. More...
 

Detailed Description

Implement this interface and provide an instance to config_parse_options.set_includer() to customize handling of.

statements in config files. You may also want to implement config_includer_file and config_includer_URL, or not.

Definition at line 15 of file config_includer.hpp.

Member Function Documentation

◆ include()

virtual shared_object hocon::config_includer::include ( shared_include_context  context,
std::string  what 
) const
pure virtual

Parses another item to be included.

The returned object typically would not have substitutions resolved. You can throw a config_exception here to abort parsing, or return an empty object, but may not return null.

This method is used for a "heuristic" include statement that does not specify file, or URL resource. If the include statement does specify, then the same class implementing config_includer must also implement config_includer_file or config_includer_URL as needed, or a default includer will be used.

Parameters
contextsome info about the include context
whatthe include statement's argument
Returns
a non-null config_object

Implemented in hocon::simple_includer.

◆ with_fallback()

virtual shared_includer hocon::config_includer::with_fallback ( shared_includer  fallback) const
pure virtual

Returns a new includer that falls back to the given includer.

This is how you can obtain the default includer; it will be provided as a fallback. It's up to your includer to chain to it if you want to. You might want to merge any files found by the fallback includer with any objects you load yourself.

It's important to handle the case where you already have the fallback with a "return this", i.e. this method should not create a new object if the fallback is the same one you already have. The same fallback may be added repeatedly.

Parameters
fallbackthe previous includer for chaining
Returns
a new includer

Implemented in hocon::simple_includer.


The documentation for this class was generated from the following file:
hocon::config_includer::include
virtual shared_object include(shared_include_context context, std::string what) const =0
Parses another item to be included.