-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.hpp
67 lines (51 loc) · 2.08 KB
/
Config.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//============================================================================
// Name : TvGuideFetch
// Author : John Saunders
// Copyright : Copyright (c) 2009 John Saunders
// Description : Fetch Australian XMLTV guide data from oztivo
//============================================================================
#ifndef CONFIG_HPP
#define CONFIG_HPP
#include <string>
#include <vector>
#include <map>
#include "XmlDom.hpp"
//////////////////////////////////////////////////////////////////////////////
// Config - singleton used for accessing the grabber configuration
//////////////////////////////////////////////////////////////////////////////
class Config
{
public:
// Class types.
typedef std::map<std::string,std::string> MapOfConfigs;
// Return an instance of the Config singleton.
static Config& instance();
// Set the path to the configuration file.
bool setConfigPath(const std::string& path, bool dontLoad = false);
// Fetch the value of a specified configuration item.
bool getItem(const std::string& item, std::string& value);
// Set the value of a specified configuration item.
bool setItem(const std::string& item, const std::string& value);
// Fetch the value of a list of items.
bool getItemList(const std::string& parent, const std::string& item, std::vector<std::string>& values);
// Return an XML navigation object for browsing the config file.
XmlNav getConfigNav();
// Register a default configuration.
void registerDefaultConfig(const std::string& name, const std::string& config);
// Load a default configuration.
bool loadDefaultConfig(const std::string& listingsType);
// Load the configuration from a file if not already loaded.
bool loadConfig();
// Write the configuration to the config path.
bool writeConfig();
private:
// Singleton pattern _must_ make these methods private.
Config();
~Config();
Config(const Config&);
Config& operator=(const Config&);
std::string m_configPath;
XmlDoc m_configDoc;
MapOfConfigs m_defaultConfigs;
};
#endif