AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
anch::conf::Configuration Class Reference

Application configuration. More...

#include <configuration.hpp>

Collaboration diagram for anch::conf::Configuration:

Public Member Functions

 Configuration (const Configuration &conf)=delete
 Configuration (Configuration &&conf)=delete
Configuration & folders (const std::vector< std::filesystem::path > &folders) noexcept
Configuration & name (const std::string &name) noexcept
Configuration & profiles (const std::vector< std::string > &profiles) noexcept
Configuration & load ()
const anch::conf::Section * section (const std::string &path) const noexcept
std::optional< std::string > value (const std::string &path) const noexcept

Static Public Member Functions

static const Configuration & inst ()
static Configuration & loader () noexcept

Detailed Description

Application configuration.

Load and manage configuration for an application.
It provides profiles inspired by Spring framework.

Since
0.1
Author
Vincent Lachenal

Constructor & Destructor Documentation

◆ Configuration() [1/2]

anch::conf::Configuration::Configuration ( const Configuration & conf)
delete

Forbids Configuration copy constructor

Parameters
confthe Configuration not to copy

◆ Configuration() [2/2]

anch::conf::Configuration::Configuration ( Configuration && conf)
delete

Forbids Configuration move constructor

Parameters
confthe Configuration not to move

Member Function Documentation

◆ folders()

Configuration & anch::conf::Configuration::folders ( const std::vector< std::filesystem::path > & folders)
noexcept

Folders' setter

Parameters
foldersthe folders to inspect
Returns
this
Here is the call graph for this function:

◆ inst()

const Configuration & anch::conf::Configuration::inst ( )
static

Get Configuration unique instance

Returns
the reference of the Configuration
Exceptions
anch::conf::ConfErrorwhen configuration has not been loaded (code: NOT_LOADED)

◆ load()

Configuration & anch::conf::Configuration::load ( )

Parse Configuration from base name.
Configuration will load configuration files in this order:

  • look for <name> file with registered extenions (default name to application ; ini, conf, cnf and properties extensions will always been registered) in folders
  • raise error when file is not found
  • load the first file found (others will be ignored)
  • load includes files
  • for each active profiles, repeat the previous loading with <file>-<profile>.<extension>
Returns
the Configuration
Exceptions
anch::conf::ConfErroron file open or resolution error (codes: CONF_NOT_FOUND)
anch::ini::ParserErrorINI file parser error
Here is the call graph for this function:

◆ loader()

Configuration & anch::conf::Configuration::loader ( )
staticnoexcept

Initialize Configuration

Returns
the reference of the new Configuration

◆ name()

Configuration & anch::conf::Configuration::name ( const std::string & name)
noexcept

Configuration base name setter

Parameters
namethe name to set
Returns
this
Here is the call graph for this function:

◆ profiles()

Configuration & anch::conf::Configuration::profiles ( const std::vector< std::string > & profiles)
noexcept

Configuration profiles setter

Parameters
profilesthe profiles to set
Returns
this
Here is the call graph for this function:

◆ section()

const anch::conf::Section * anch::conf::Configuration::section ( const std::string & path) const
noexcept

Get section

Parameters
sectionthe section's path
Returns
the section when found, NULL otherwise.
Here is the call graph for this function:

◆ value()

std::optional< std::string > anch::conf::Configuration::value ( const std::string & path) const
noexcept

Get value

Parameters
paramthe value's path
Returns
the optional result
Here is the call graph for this function:

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