Parent: [04a926] (diff)

Child: [511e51] (diff)

Download this file

rclconfig.h    62 lines (50 with data), 2.1 kB

 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
#ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.6 2005-11-05 14:40:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list>
#include "conftree.h"
class RclConfig {
int m_ok;
string reason; // Explanation for bad state
string confdir; // Directory where the files are stored
ConfTree *conf; // Parsed main configuration
string keydir; // Current directory used for parameter fetches.
ConfTree *mimemap; // These are independant of current keydir. We might
ConfTree *mimeconf; // want to change it one day.
// Parameters auto-fetched on setkeydir
string defcharset; // These are stored locally to avoid
string deflang; // a config lookup each time.
bool guesscharset; // They are fetched initially or on setKeydir()
public:
RclConfig();
~RclConfig() {delete conf;delete mimemap;delete mimeconf;}
bool ok() {return m_ok;}
const string &getReason() {return reason;}
string getConfDir() {return confdir;}
ConfTree *getConfig() {return m_ok ? conf : 0;}
/// Get generic configuration parameter according to current keydir
bool getConfParam(const string &name, string &value)
{
if (conf == 0)
return false;
return conf->get(name, value, keydir);
}
/// Set current directory reference, and fetch automatic parameters.
void setKeyDir(const string &dir)
{
keydir = dir;
conf->get("defaultcharset", defcharset, keydir);
conf->get("defaultlanguage", deflang, keydir);
string str;
conf->get("guesscharset", str, keydir);
guesscharset = ConfTree::stringToBool(str);
}
ConfTree *getMimeMap() {return m_ok ? mimemap : 0;}
ConfTree *getMimeConf() {return m_ok ? mimeconf : 0;}
const string &getDefCharset() {return defcharset;}
const string &getDefLang() {return deflang;}
bool getGuessCharset() {return guesscharset;}
std::list<string> getAllMimeTypes();
};
std::string find_filter(RclConfig *conf, const string& cmd);
#endif /* _RCLCONFIG_H_INCLUDED_ */