12#if __DCL_HAVE_ALLOC_DEBUG
13#undef __DCL_ALLOC_LEVEL
14#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
27#if __DCL_HAVE_THIS_FILE__
56 IniLine(
const String& strKey,
const String& strValue)
67 str = L
"[" +
__name + L
"]";
89void IniFile::dump(
Writer& out)
const
92 out << L
"fileName: " <<
__name << L
"\n";
95 for(IniLineList::ConstIterator it = lines->
begin();
96 it != lines->
end(); it++
128 while(in.readLine(s)) {
133 else if (s[(
size_t)0] == L
';' || s[(
size_t)0] == L
'#') {
136 else if (s[(
size_t)0] == L
'[') {
138 s = s.trim(L
"[]\t ");
143 size_t pos = s.indexOf(L
'=');
144 if (pos != (
size_t)-1) {
145 String name = s.left(pos).trim();
146 String value = s.right(s.length() - pos - 1).trim();
162 catch (IOException* e) {
181 OutputStreamWriter out(
182 new FileOutputStream(
__name,
true)
184 for (IniLineList::Iterator it = lines->
begin();
185 it != lines->
end(); it++) {
189 catch (Exception* _e) {
216String IniFile::getString(
217 const String& strSection,
218 const String& strEntry,
219 const wchar_t* pszDefault
225 String strResult = __getValue(strSection, strEntry);
226 if (strResult.isEmpty() && pszDefault !=
NULL)
227 strResult = pszDefault;
232int IniFile::getInteger(
233 const String& strSection,
234 const String& strEntry,
241 String strResult = __getValue(strSection, strEntry);
242 if (!strResult.isEmpty()) {
253void IniFile::setValue(
254 const String& strSection,
255 const String& strEntry,
256 const String& strValue
262 __setValue(strSection, strEntry, strValue);
265void IniFile::setValue(
266 const String& strSection,
267 const String& strEntry,
277String IniFile::__getValue(
278 const String& strSection,
279 const String& strEntry
287 IniLineList::Iterator it = lines->
begin();
288 for(; it != lines->
end(); it++) {
290 && ((*it).__name.compareNoCase(strSection) == 0)
298 && ((*it).__name.compareNoCase(strEntry) == 0)
300 strResult = (*it).__strValue;
312void IniFile::__setValue(
313 const String& strSection,
314 const String& strEntry,
315 const String& strValue
322 for(IniLineList::Iterator it = lines->
begin();
323 it != lines->
end(); it++
326 && ((*it).__name.compareNoCase(strSection) == 0)
334 && ((*it).__name.compareNoCase(strEntry) == 0)
337 (*it).__strValue = strValue;
341 lines->
insert(it, IniLine(strEntry, strValue));
347 lines->
addTail(IniLine(strEntry, strValue));
356RegIniFile::RegIniFile(HKEY hParentKey,
const String& strKey)
362 __reg.create(strKey, KEY_ALL_ACCESS);
367void RegIniFile::close()
374String RegIniFile::getString(
375 const String& strSection,
376 const String& strEntry,
377 const wchar_t* pszDefault
385 Registry section(__reg.key(), strSection, KEY_READ);
386 strResult = section.getString(strEntry);
393 strResult = pszDefault;
399int RegIniFile::getInteger(
400 const String& strSection,
401 const String& strEntry,
410 Registry section(__reg.key(), strSection, KEY_READ);
411 nResult = section.getInteger(strEntry);
422void RegIniFile::setValue(
423 const String& strSection,
424 const String& strEntry,
425 const String& strValue
432 section.create(strSection);
433 section.setValue(strEntry, strValue);
436void RegIniFile::setValue(
437 const String& strSection,
438 const String& strEntry,
446 section.create(strSection);
447 section.setValue(strEntry, nValue);
List< IniLine > IniLineList
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
DCLCVAR const struct __endl endl
virtual String toString() const
String toString(unsigned _base=10) const
static int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
ConstIterator end() const
Iterator insert(Iterator _pos, const ELEMENT &_element)
ConstIterator begin() const
List< ELEMENT > & addTail(const ELEMENT &_element)
virtual String toString() const
IniLine(const String &strKey, const String &strValue)
IniLine(IniLineType type, const String &str)