Chatsync  bbffde5c0c672a526bdc83637acf66dc20a80fbf
config::ConfigParser Class Reference

#include <config.hpp>

Public Member Functions

 ConfigParser (const std::string &path)
 
const ConfigOption operator[] (const std::string &&option) const
 
const ConfigOption get (const std::string &&option, const ConfigOption &&defaultValue) const
 

Static Private Member Functions

static const std::string openConfig (const std::string &path)
 
static std::map< const std::string, const ConfigOption > * parseConfig (const std::string &data)
 

Private Attributes

const std::unique_ptr< std::map< const std::string, const ConfigOption > const > _config
 

Detailed Description

An object for parsing configuration file

Config file format is just like .ini files

Hub::Hub config: [hub] name = "Hub 1"

Channelling::Channel config: [channel] name = "Channel name" direction = in|out|both

Constructor & Destructor Documentation

§ ConfigParser()

config::ConfigParser::ConfigParser ( const std::string &  path)

Creates an object

Parameters
pathConfiguration file name and path

Member Function Documentation

§ get()

const ConfigOption config::ConfigParser::get ( const std::string &&  option,
const ConfigOption &&  defaultValue 
) const

Get option from storage or return default value

Parameters
optionOption name to request
defaultValueDefault value to return if no value found in map

§ openConfig()

const std::string config::ConfigParser::openConfig ( const std::string &  path)
staticprivate

Opens

Parameters
pathparsing scheme and returns a single line with configuration

Possible schemes:

  • file:// open a file, read it to memory and return
  • data:// raw data line, just cut the "data://" and return line
Parameters
pathpath to config
Return values
stringwith config lines separated with
Exceptions
config_errorif file can't be opened

§ operator[]()

const ConfigOption config::ConfigParser::operator[] ( const std::string &&  option) const

Get option from storage

Exceptions
option_errorif no option found in storage

§ parseConfig()

std::map< const std::string, const ConfigOption > * config::ConfigParser::parseConfig ( const std::string &  data)
staticprivate

Field Documentation

§ _config

const std::unique_ptr<std::map<const std::string, const ConfigOption> const> config::ConfigParser::_config
private

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