cpp-hocon  0.3.0
Classes | Public Member Functions | Static Public Member Functions | List of all members
hocon::simple_includer Class Reference
Inheritance diagram for hocon::simple_includer:
hocon::config_includer hocon::config_includer_file

Public Member Functions

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

Static Public Member Functions

static shared_object include_file_without_fallback (shared_include_context context, std::string what)
 
static config_parse_options clear_for_include (config_parse_options const &options)
 
static shared_object from_basename (std::shared_ptr< name_source > source, std::string name, config_parse_options options)
 
static std::shared_ptr< const full_includermake_full (std::shared_ptr< const config_includer > includer)
 

Detailed Description

Definition at line 12 of file simple_includer.hpp.

Member Function Documentation

◆ include()

shared_object hocon::simple_includer::include ( shared_include_context  context,
std::string  what 
) const
overridevirtual

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

Implements hocon::config_includer.

◆ include_file()

shared_object hocon::simple_includer::include_file ( shared_include_context  context,
std::string  what 
) const
overridevirtual

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.

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

Implements hocon::config_includer_file.

◆ with_fallback()

shared_includer hocon::simple_includer::with_fallback ( shared_includer  fallback) const
overridevirtual

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

Implements hocon::config_includer.


The documentation for this class was generated from the following file: