crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Main::ConfigFile Class Reference

Configuration file. More...

#include <ConfigFile.hpp>

Classes

class  Exception
 Class for configuration file exceptions. More...
 

Protected Attributes

std::vector< std::pair< std::string, std::string > > entries
 

Construction

 ConfigFile (const std::string &name)
 Constructor reading the file. More...
 

Getters

bool getValue (const std::string &name, std::string &to) const
 Gets the string value of a configuration entry. More...
 
template<typename T >
bool getValue (const std::string &name, T &to) const
 Gets the converted value of a configuration entry. More...
 

Detailed Description

Configuration file.

In this text file, each line represents one entry and consists of a key=value pair.

Constructor & Destructor Documentation

◆ ConfigFile()

crawlservpp::Main::ConfigFile::ConfigFile ( const std::string &  name)
inlineexplicit

Constructor reading the file.

Parameters
nameConst reference to a string containing the name of the configuration file to read.
Exceptions
Main::Exceptionif the configuration file could not be opened for reading.

References entries.

Member Function Documentation

◆ getValue() [1/2]

bool crawlservpp::Main::ConfigFile::getValue ( const std::string &  name,
std::string &  to 
) const
inline

Gets the string value of a configuration entry.

Parameters
nameConstant reference to a string containing the name of the configuration entry to be retrieved.
toReference to a string to which the value of the entry should be written. Will not be changed, if the given configuration entry does not exist.
Returns
True, if the given configuration entry exists. False otherwise.

References entries.

Referenced by getValue(), and crawlservpp::Main::App::run().

◆ getValue() [2/2]

template<typename T >
bool crawlservpp::Main::ConfigFile::getValue ( const std::string &  name,
T &  to 
) const
inline

Gets the converted value of a configuration entry.

Parameters
nameConstant reference to a string containing the name of the configuration entry to be retrieved.
toReference to a variable to which the converted value of the entry should be written. Will not be changed, if the given configuration entry does not exist or its value is empty.
Returns
True, if the given configuration entry exists and is not empty. False otherwise.
Exceptions
ConfigFile::Exception,ifthe conversion of the configuration entry value failed.

References getValue().

Member Data Documentation

◆ entries

std::vector<std::pair<std::string, std::string> > crawlservpp::Main::ConfigFile::entries
protected

Referenced by ConfigFile(), and getValue().


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