]>
Dogcows Code - chaz/openbox/blob - epist/config.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // config.cc for Epistrophy - a key handler for NETWM/EWMH window managers.
3 // Copyright (c) 2002 - 2002 Ben Jansens <ben at orodu.net>
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:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
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.
31 // deallocate memory for the 3 lists
32 BoolItemList::const_iterator b_it
, b_end
= bool_items
.end();
33 for (b_it
= bool_items
.begin(); b_it
!= b_end
; ++b_it
)
37 NumberItemList::const_iterator n_it
, n_end
= number_items
.end();
38 for (n_it
= number_items
.begin(); n_it
!= n_end
; ++n_it
)
42 StringItemList::const_iterator s_it
, s_end
= string_items
.end();
43 for (s_it
= string_items
.begin(); s_it
!= s_end
; ++s_it
)
49 bool Config::getValue(Config::StringType type
, string
&ret
) const
51 StringItemList::const_iterator it
= string_items
.begin(), end
= string_items
.end();
52 for (; it
!= end
; ++it
) {
53 if ((*it
)->type
== type
) {
62 bool Config::getValue(Config::NumberType type
, int &ret
) const
64 NumberItemList::const_iterator it
= number_items
.begin(), end
= number_items
.end();
65 for (; it
!= end
; ++it
) {
66 if ((*it
)->type
== type
) {
75 bool Config::getValue(Config::BoolType type
, bool &ret
) const
77 BoolItemList::const_iterator it
= bool_items
.begin(), end
= bool_items
.end();
78 for (; it
!= end
; ++it
) {
79 if ((*it
)->type
== type
) {
88 void Config::addOption(const std::string
&name
, const std::string
&value
)
92 Config::BoolType type
;
95 { "stackedcycling", Config::stackedCycling
},
96 { "", NUM_BOOL_TYPES
}
101 Config::StringType type
;
104 { "", NUM_STRING_TYPES
}
109 Config::NumberType type
;
112 { "chaintimeout", chainTimeout
},
113 { "workspacecolumns", workspaceColumns
},
114 { "", NUM_NUMBER_TYPES
}
117 // if it's bool option, add it to the bool_items list
119 while (bool_options
[i
].type
!= NUM_BOOL_TYPES
) {
120 if (strcasecmp(name
.c_str(), bool_options
[i
].name
) == 0) {
121 BoolItem
*item
= new BoolItem
;
122 const char *tmp
= value
.c_str();
124 item
->type
= bool_options
[i
].type
;
126 if (strcasecmp(tmp
, "true") == 0 || strcasecmp(tmp
, "1") == 0 ||
127 strcasecmp(tmp
, "on") == 0)
132 bool_items
.push_back(item
);
138 // if it's a string, add it to the string_items list
140 while (string_options
[i
].type
!= NUM_STRING_TYPES
) {
141 if (strcasecmp(name
.c_str(), string_options
[i
].name
) == 0) {
142 StringItem
*item
= new StringItem
;
143 item
->type
= string_options
[i
].type
;
146 string_items
.push_back(item
);
152 // if it's a number, add it to the number_items list
154 while (number_options
[i
].type
!= NUM_NUMBER_TYPES
) {
155 if (strcasecmp(name
.c_str(), number_options
[i
].name
) == 0) {
156 NumberItem
*item
= new NumberItem
;
157 item
->type
= number_options
[i
].type
;
158 item
->value
= atoi( value
.c_str() );
160 number_items
.push_back(item
);
This page took 0.041852 seconds and 4 git commands to generate.