1 /***************************************************************************
3 * Copyright (C) 2006 David Brodsky *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Library General Public *
7 * License as published by the Free Software Foundation and appearing *
8 * in the file LICENSE.LGPL included in the packaging of this file. *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * Library General Public License for more details. *
15 ***************************************************************************/
17 #ifndef _tairon_core_config_h
18 #define _tairon_core_config_h
30 /** \brief Class that holds configuration.
32 * It loads a configuration file with simple key-value based structure and then
33 * provides loaded informations to the rest of the program. This class is a
39 /** Loads a configuration file. It is an XML file with "config" as the
40 * root element's name. Names of root's direct children are used as
41 * keys and their texts are treated as values.
43 * \param filename Path to the configuration file. If it is pure
44 * filename without any directory then it is searched in following
45 * paths: . (current directory), /etc, /usr/etc and /usr/local/etc.
47 Config(const String
&filename
);
49 /** Standard destructor.
53 /** Returns the key's value. Default value is returned when the key
56 const String
&operator[](const String
&key
);
58 /** Returns pointer to the instance of this class.
60 static Config
*self() {
65 /** Loads the configuration file and stores data from it into the
66 * internal dictionary.
68 void loadConfigFile(const String
&filename
);
70 /** Holds pointer to the instance of this class.
72 static Config
*config
;
74 /** Dictionary holding configuration.
76 std::map
<String
, String
> data
;
81 }; // namespace Tairon
85 // vim: ai sw=4 ts=4 noet fdm=marker