]> Dogcows Code - chaz/openbox/blob - src/Configuration.hh
had an extra window placement menu
[chaz/openbox] / src / Configuration.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Configuration.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net)
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
22
23 #ifndef __Configuration_hh
24 #define __Configuration_hh
25
26 #include <X11/Xlib.h>
27 #include <X11/Xresource.h>
28 #include <string>
29
30 /*
31 * The Configuration class is a generic wrapper for configuration settings.
32 *
33 * This class is used for the global rc/config file, and for styles.
34 *
35 * This implementation of the Configuration class wraps an X resource database
36 * file.
37 */
38 class Configuration {
39 public:
40 explicit Configuration(const std::string &file, bool autosave = True);
41 Configuration(bool autosave = True);
42 virtual ~Configuration();
43
44 inline const std::string &file() const {
45 return static_cast<const std::string &>(_file);
46 }
47 void setFile(const std::string &file);
48
49 // defaults to true!
50 inline bool autoSave() const {
51 return _autosave;
52 }
53 void setAutoSave(bool);
54
55 inline bool isModified() const {
56 return _modified;
57 }
58
59 void save();
60 bool load();
61 bool merge(const std::string &file, bool overwrite = False);
62 void create();
63
64 void setValue(const std::string &rname, bool value);
65 inline void setValue(const std::string &rname, int value) {
66 setValue(rname, (long) value);
67 }
68 inline void setValue(const std::string &rname, unsigned int value) {
69 setValue(rname, (unsigned long) value);
70 }
71 void setValue(const std::string &rname, long value);
72 void setValue(const std::string &rname, unsigned long value);
73 void setValue(const std::string &rname, const std::string &value);
74 void setValue(const std::string &rname, const char *value);
75
76 bool getValue(const std::string &rname, bool &value) const;
77 inline bool getValue(const std::string &rname, int &value) const {
78 return getValue(rname, (long) value);
79 }
80 inline bool getValue(const std::string &rname, unsigned int &value) const {
81 return getValue(rname, (unsigned long) value);
82 }
83 bool getValue(const std::string &rname, long &value) const;
84 bool getValue(const std::string &rname, unsigned long &value) const;
85 bool getValue(const std::string &rname, std::string &value) const;
86
87 private:
88 std::string createClassName(const std::string &rname) const;
89 char toUpper(char) const;
90
91 static bool _initialized;
92 std::string _file;
93 bool _modified;
94 bool _autosave;
95 XrmDatabase _database;
96 };
97
98 #endif // __Configuration_hh
This page took 0.035154 seconds and 4 git commands to generate.