]> git.stg.codes - stg.git/blob - include/stg/module_settings.h
Merge branch 'stg-2.409' into stg-2.409-radius
[stg.git] / include / stg / module_settings.h
1  /*
2  $Revision: 1.5 $
3  $Date: 2010/03/04 11:49:52 $
4  $Author: faust $
5  */
6
7 #ifndef MODULE_SETTINGS_H
8 #define MODULE_SETTINGS_H
9
10 #include <cstring> // strcasecmp
11 #include <string>
12 #include <vector>
13
14 //-----------------------------------------------------------------------------
15 struct PARAM_VALUE
16 {
17     PARAM_VALUE() {}
18     PARAM_VALUE(const std::string& p, const std::vector<std::string>& vs)
19         : param(p),
20           value(vs)
21     {}
22     PARAM_VALUE(const std::string& p, const std::vector<std::string>& vs, const std::vector<PARAM_VALUE>& ss)
23         : param(p),
24           value(vs),
25           sections(ss)
26     {}
27     bool operator==(const PARAM_VALUE & rhs) const
28         { return !strcasecmp(param.c_str(), rhs.param.c_str()); }
29
30     bool operator<(const PARAM_VALUE & rhs) const
31         { return strcasecmp(param.c_str(), rhs.param.c_str()) < 0; }
32
33     std::string param;
34     std::vector<std::string> value;
35     std::vector<PARAM_VALUE> sections;
36 };
37 //-----------------------------------------------------------------------------
38 struct MODULE_SETTINGS
39 {
40     MODULE_SETTINGS()
41         : moduleName(),
42           moduleParams()
43     {}
44     MODULE_SETTINGS(const std::string& name, const std::vector<PARAM_VALUE>& params)
45         : moduleName(name),
46           moduleParams(params)
47     {}
48     bool operator==(const MODULE_SETTINGS & rhs) const
49         { return !strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()); }
50
51     bool operator<(const MODULE_SETTINGS & rhs) const
52         { return strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()) < 0; }
53
54     std::string              moduleName;
55     std::vector<PARAM_VALUE> moduleParams;
56 };
57 //-----------------------------------------------------------------------------
58 #endif