]>
Dogcows Code - chaz/openbox/blob - util/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.
24 # include "../../config.h"
25 #endif // HAVE_CONFIG_H
35 // deallocate memory for the 3 lists
36 BoolItemList::const_iterator b_it
, b_end
= bool_items
.end();
37 for (b_it
= bool_items
.begin(); b_it
!= b_end
; ++b_it
)
41 NumberItemList::const_iterator n_it
, n_end
= number_items
.end();
42 for (n_it
= number_items
.begin(); n_it
!= n_end
; ++n_it
)
46 StringItemList::const_iterator s_it
, s_end
= string_items
.end();
47 for (s_it
= string_items
.begin(); s_it
!= s_end
; ++s_it
)
53 bool Config::getValue(Config::StringType type
, string
&ret
) const
55 StringItemList::const_iterator it
= string_items
.begin(), end
= string_items
.end();
56 for (; it
!= end
; ++it
) {
57 if ((*it
)->type
== type
) {
66 bool Config::getValue(Config::NumberType type
, int &ret
) const
68 NumberItemList::const_iterator it
= number_items
.begin(), end
= number_items
.end();
69 for (; it
!= end
; ++it
) {
70 if ((*it
)->type
== type
) {
79 bool Config::getValue(Config::BoolType type
, bool &ret
) const
81 BoolItemList::const_iterator it
= bool_items
.begin(), end
= bool_items
.end();
82 for (; it
!= end
; ++it
) {
83 if ((*it
)->type
== type
) {
92 void Config::addOption(const std::string
&name
, const std::string
&value
)
96 Config::BoolType type
;
99 { "stackedcycling", Config::stackedCycling
},
100 { "stackedcyclingraise", Config::stackedCyclingRaise
},
101 { "", NUM_BOOL_TYPES
}
106 Config::StringType type
;
109 { "", NUM_STRING_TYPES
}
114 Config::NumberType type
;
117 { "chaintimeout", chainTimeout
},
118 { "workspacecolumns", workspaceColumns
},
119 { "", NUM_NUMBER_TYPES
}
122 // if it's bool option, add it to the bool_items list
124 while (bool_options
[i
].type
!= NUM_BOOL_TYPES
) {
125 if (strcasecmp(name
.c_str(), bool_options
[i
].name
) == 0) {
126 BoolItem
*item
= new BoolItem
;
127 const char *tmp
= value
.c_str();
129 item
->type
= bool_options
[i
].type
;
131 if (strcasecmp(tmp
, "true") == 0 || strcasecmp(tmp
, "1") == 0 ||
132 strcasecmp(tmp
, "on") == 0)
137 bool_items
.push_back(item
);
143 // if it's a string, add it to the string_items list
145 while (string_options
[i
].type
!= NUM_STRING_TYPES
) {
146 if (strcasecmp(name
.c_str(), string_options
[i
].name
) == 0) {
147 StringItem
*item
= new StringItem
;
148 item
->type
= string_options
[i
].type
;
151 string_items
.push_back(item
);
157 // if it's a number, add it to the number_items list
159 while (number_options
[i
].type
!= NUM_NUMBER_TYPES
) {
160 if (strcasecmp(name
.c_str(), number_options
[i
].name
) == 0) {
161 NumberItem
*item
= new NumberItem
;
162 item
->type
= number_options
[i
].type
;
163 item
->value
= atoi( value
.c_str() );
165 number_items
.push_back(item
);
This page took 0.0443 seconds and 4 git commands to generate.