Debian Codegraph @

rudeconfig/src/config.cpp

raw
1 // config.cpp
2 //
3 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007 Matthew Flood
4 // See file AUTHORS for contact information
5 //
6 // This file is part of RudeConfig.
7 //
8 // RudeConfig is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12 //
13 // RudeConfig is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with RudeConfig; (see COPYING) if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 // 02111-1307, USA.
22 //------------------------------------------------------------------------
23
24 #include "../config.h"
25
26 #include "config.h"
27
28 #ifndef INCLUDED_RUDE_CONFIGIMPL_H
29 #include "ConfigImpl.h"
30 #endif
31
32 #ifndef INCLUDED_IOSTREAM
33 #include <iostream>
34 #define INCLUDED_IOSTREAM
35 #endif
36
37 #ifndef INCLUDED_STRING
38 #include <string>
39 #define INCLUDED_STRING
40 #endif
41
42 using namespace rude::config;
43
44 namespace rude{
45
46 //////////////////////////////////////////
47 // STATIC Methods
48 //////////////////////////////////////////
49
50 const char *Config::version()
51 {
52 static std::string ver="3.";
53 ver += ConfigImpl::version();
54 return ver.c_str();
55 }
56
57 void Config::setDefaultConfigFile(const char *filepath)
58 {
59 ConfigImpl::setDefaultConfigFile(filepath);
60 }
61
62 const char *Config::getDefaultConfigFile()
63 {
64 return ConfigImpl::getDefaultConfigFile();
65 }
66
67 void Config::setDefaultCommentCharacter(char c)
68 {
69 ConfigImpl::setDefaultCommentCharacter(c);
70 }
71
72 char Config::getDefaultCommentCharacter()
73 {
74 return ConfigImpl::getDefaultCommentCharacter();
75 }
76
77 void Config::setDefaultDelimiter(char c)
78 {
79 ConfigImpl::setDefaultDelimiter(c);
80 }
81
82 char Config::getDefaultDelimiter()
83 {
84 return ConfigImpl::getDefaultDelimiter();
85 }
86
87 void Config::setDefaultPreserveDeleted(bool shouldPreserve)
88 {
89 ConfigImpl::setDefaultPreserveDeleted(shouldPreserve);
90 }
91
92 bool Config::getDefaultPreserveDeleted()
93 {
94 return ConfigImpl::getDefaultPreserveDeleted();
95 }
96
97 //////////////////////////////////////////
98 // INSTANCE Methods
99 //////////////////////////////////////////
100
101 Config::Config()
102 {
103 d_implementation = new ConfigImpl();
104 }
105
106 Config::~Config()
107 {
108 delete d_implementation;
109 d_implementation = 0;
110 }
111
112 void Config::setConfigFile(const char *filepath)
113 {
114 d_implementation->setConfigFile(filepath);
115 }
116
117 const char * Config::getConfigFile()
118 {
119 return d_implementation->getConfigFile();
120 }
121
122 void Config::setCommentCharacter(char commentchar)
123 {
124 d_implementation->setCommentCharacter(commentchar);
125 }
126
127 void Config::preserveDeletedData(bool shouldPreserve)
128 {
129 d_implementation->preserveDeletedData(shouldPreserve);
130 }
131
132 void Config::setDelimiter(char delimiter)
133 {
134 d_implementation->setDelimiter(delimiter);
135 }
136
137 bool Config::load()
138 {
139 return d_implementation->load();
140 }
141
142 bool Config::load(const char *filename)
143 {
144 return d_implementation->load(filename);
145 }
146
147 bool Config::load(std::istream& file)
148 {
149 return d_implementation->load(file);
150 }
151
152
153 bool Config::save()
154 {
155 return d_implementation->save();
156 }
157
158 bool Config::save(const char *filepath)
159 {
160 return d_implementation->save(filepath);
161 }
162
163
164 void Config::clear()
165 {
166 d_implementation->clear();
167 }
168
169
170 const char *Config::getError()
171 {
172 return d_implementation->getError();
173 }
174
175
176 //////////////////////////////////////////
177 // Section Methods
178 //////////////////////////////////////////
179 int Config::getNumSections() const
180 {
181 return d_implementation->getNumSections();
182 }
183
184 const char *Config::getSectionNameAt(int index) const
185 {
186 return d_implementation->getSectionNameAt(index);
187 }
188
189 bool Config::setSection(const char *sectionname, bool shouldCreate)
190 {
191 return d_implementation->setSection(sectionname, shouldCreate);
192 }
193
194 bool Config::setSection(const char *sectionname)
195 {
196 return d_implementation->setSection(sectionname, true);
197 }
198
199 bool Config::deleteSection(const char *sectionname)
200 {
201 return d_implementation->deleteSection(sectionname);
202 }
203
204 //////////////////////////////////////////
205 // Data Methods
206 //////////////////////////////////////////
207
208
209 int Config::getNumSourceDestMembers() const
210 {
211 return d_implementation->getNumSourceDestMembers();
212 }
213
214 const char *Config::getSrcAppAt(int index) const
215 {
216 return d_implementation->getSrcAppAt(index);
217 }
218
219 const char *Config::getDestAppAt(int index) const
220 {
221 return d_implementation->getDestAppAt(index);
222 }
223
224 const char *Config::getSrcObjAt(int index) const
225 {
226 return d_implementation->getSrcObjAt(index);
227 }
228
229 const char *Config::getDestObjAt(int index) const
230 {
231 return d_implementation->getDestObjAt(index);
232 }
233
234 const char *Config::getWidthAt(int index) const
235 {
236 return d_implementation->getWidthAt(index);
237 }
238 const char *Config::getCommTypeAt(int index) const
239 {
240 return d_implementation->getCommTypeAt(index);
241 }
242 const char *Config::getProcMethodAt(int index) const
243 {
244 return d_implementation->getProcMethodAt(index);
245 }
246
247
248 int Config::getNumDataMembers() const
249 {
250 return d_implementation->getNumDataMembers();
251 }
252
253 const char *Config::getDataNameAt(int index) const
254 {
255 return d_implementation->getDataNameAt(index);
256 }
257
258 bool Config::exists(const char *name) const
259 {
260 return d_implementation->exists(name);
261 }
262
263 void Config::setBoolValue(const char *name, bool value)
264 {
265 d_implementation->setStringValue(name, ConfigImpl::boolToString(value));
266 // d_implementation->setBoolValue(name, value);
267 }
268
269 bool Config::getBoolValue(const char *name) const
270 {
271 return ConfigImpl::stringToBool(d_implementation->getStringValue(name));
272 //return d_implementation->getBoolValue(name);
273 }
274
275 void Config::setIntValue(const char *name, int value)
276 {
277 d_implementation->setStringValue(name, ConfigImpl::intToString(value));
278 // d_implementation->setIntValue(name, value);
279 }
280
281 int Config::getIntValue(const char *name) const
282 {
283 return ConfigImpl::stringToInt(d_implementation->getStringValue(name));
284 //return d_implementation->getIntValue(name);
285 }
286
287 void Config::setDoubleValue(const char *name, double value)
288 {
289 d_implementation->setStringValue(name, ConfigImpl::doubleToString(value));
290 // d_implementation->setDoubleValue(name, value);
291 }
292
293 double Config::getDoubleValue(const char *name) const
294 {
295 return ConfigImpl::stringToDouble(d_implementation->getStringValue(name));
296 //return d_implementation->getDoubleValue(name);
297 }
298
299 void Config::setStringValue(const char *name, const char *value)
300 {
301 d_implementation->setStringValue(name, value);
302 }
303
304 const char * Config::getStringValue(const char *name) const
305 {
306 return d_implementation->getStringValue(name);
307 }
308
309 void Config::setValue(const char *name, const char *value)
310 {
311 d_implementation->setStringValue(name, value);
312 }
313
314 const char * Config::getValue(const char *name) const
315 {
316 return d_implementation->getStringValue(name);
317 }
318
319 bool Config::deleteData(const char *name)
320 {
321 return d_implementation->deleteData(name);
322 }
323
324
325 } // end namespace rude