alaCarte Maps
Renderer for OpenStreetMap tiles
Configuration Class Reference

Represents a set of options accessible via strings. More...

#include <configuration.hpp>

Inheritance diagram for Configuration:

Public Member Functions

 Configuration ()=default
 
 Configuration (boost::program_options::options_description &cmd_desc, boost::program_options::options_description &config_desc, boost::program_options::positional_options_description &pos_desc, int argc, char **argv)
 This file is part of alaCarte. More...
 
bool has (const string &key)
 Tests if a key was specified in the command line or in the config file. More...
 
template<typename T >
get (const string &key)
 Returns a value identified by a key. More...
 
template<typename T >
get (const string &key, const T &defaultValue)
 Returns a value identified by a key or a default value if the key does not exist. More...
 
void printConfigToLog ()
 Prints the given configurations to the log. More...
 
bool usedConfigFile () const
 Returns true if the configuration was loaded form a file. More...
 
const std::vector< string > & getSearchDirectories () const
 Returns a queue of strings. More...
 

Protected Member Functions

TESTABLE const boost::any & getValueByKey (const string &key) const
 

Protected Attributes

boost::program_options::variables_map options
 Internal map holding the options. More...
 
bool ConfigFileUsed
 
std::vector< stringsearchDirectories
 

Detailed Description

Represents a set of options accessible via strings.

Definition at line 128 of file configuration.hpp.

Constructor & Destructor Documentation

Configuration::Configuration ( )
default
Configuration::Configuration ( boost::program_options::options_description &  cmd_desc,
boost::program_options::options_description &  config_desc,
boost::program_options::positional_options_description &  pos_desc,
int  argc,
char **  argv 
)

This file is part of alaCarte.

alaCarte is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

alaCarte is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with alaCarte. If not, see http://www.gnu.org/licenses/.

Copyright alaCarte 2012-2013 Simon Dreher, Florian Jacob, Tobias Kahlert, Patrick Niklaus, Bernhard Scheirle, Lisa Winter Maintainer: Tobias Kahlert Creates a new config and parses the command line and config file.

Parses the command line arguments and stores them internally. If a config file is specified, the file will be loaded and parsed. If options are specified in both ways, the command line argument will be taken. This function will search for the config file in different locations:

  • current working directory
  • install location
Parameters
cmd_descOption descriptions for the command line parser
config_descOption descriptions for the config file parser
pos_descDescription for relative arguments in the command line
argcNumber of arguments
argvarguments

Definition at line 45 of file configuration.cpp.

Member Function Documentation

template<typename T >
T Configuration::get ( const string key)
inline

Returns a value identified by a key.

Parameters
keythe key identifying the value
Returns
the value in the identified by the key casted to the wanted type

Definition at line 146 of file configuration.hpp.

template<typename T >
T Configuration::get ( const string key,
const T &  defaultValue 
)
inline

Returns a value identified by a key or a default value if the key does not exist.

Parameters
keythe key identifying the value
defaultValuethe value that is returned if key does not exist
Returns
the value in the identified by the key casted to the wanted type or the default value

Definition at line 159 of file configuration.hpp.

const std::vector< string > & Configuration::getSearchDirectories ( ) const

Returns a queue of strings.

Each string is a folder in which we searched for a config file. If usedConfigFile() is true then the last entry is the folder in which we found the config file.

Returns
:queue< string, std::deque< string, std::allocator< string > > >

Definition at line 106 of file configuration.cpp.

const boost::any & Configuration::getValueByKey ( const string key) const
protected

Definition at line 151 of file configuration.cpp.

bool Configuration::has ( const string key)

Tests if a key was specified in the command line or in the config file.

Parameters
keythe key to test
Returns
weather the key was present or not

Definition at line 95 of file configuration.cpp.

void Configuration::printConfigToLog ( )

Prints the given configurations to the log.

Definition at line 114 of file configuration.cpp.

bool Configuration::usedConfigFile ( ) const

Returns true if the configuration was loaded form a file.

Returns
true if the configuration was loaded form a file.

Definition at line 101 of file configuration.cpp.

Member Data Documentation

bool Configuration::ConfigFileUsed
protected

Definition at line 185 of file configuration.hpp.

boost::program_options::variables_map Configuration::options
protected

Internal map holding the options.

Definition at line 183 of file configuration.hpp.

std::vector<string> Configuration::searchDirectories
protected

Definition at line 186 of file configuration.hpp.


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