cppcms::cppcms_config
Role:
This class is used to access global configuration of cppcms application that is loaded from configuration file.
Headers:
Include header is
#include <cppcms/global_config.h>
Public types
typedef std::map<string,boost::any> data_t; typedef std::pair<data_t::const_iterator,data_t::const_iterator> range_t;
The data is stored in std::map of string to boost::any, You can use these typedefs to access this data.
Public members
void load(char const *filename);
Loads configuration from file filename
void load(int argc,char *argv[],char const *def=NULL);
Parses command line and tries to load configuration file given with -c switch. If not found and def not null tries to loads from file which filename defined in def.
int ival(string m) const int ival(string m,int def) const double dval(string m) const double dval(string m,double def) const string const &sval(string m) const string sval(string m,string def) const
Load integer, double or string values of configuration using key m. One parameter throws cppcms_error if no such parameter defined, the second, returns def value as default.
vector<int> const &ilist(string m) const vector<double> const &dlist(string m) const vector<string> const &slist(string m) const
Return list using m as key. If key not found, empty list is returned.
For example:
string name=conf.sval("admin.name","nobody");
Access to range of values can be done using:
range_t prefix(string pref) const
Returns pair of iterators on all entries that have prefix pref.
You can also access directly to the data using:
data_t const &get_data() const
