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__
57 IniLine(
const String& strKey,
const String& strValue)
91void IniFile::dump(
Writer& out)
const
94 out << L
"fileName: " <<
m_strName << L
"\n";
98 for(IniLineList::ConstIterator it = pLines->
begin();
99 it != pLines->
end(); it++)
131 while(in.readLine(s))
137 else if (s[(
size_t)0] == L
';' || s[(
size_t)0] == L
'#')
141 else if (s[(
size_t)0] == L
'[')
144 s = s.trim(L
"[]\t ");
150 size_t pos = s.indexOf(L
'=');
151 if (pos != (
size_t)-1)
153 String name = s.left(pos).trim();
154 String value = s.right(s.length() - pos - 1).trim();
173 catch (IOException* e)
194 OutputStreamWriter out(
197 for (IniLineList::Iterator it = pLines->
begin();
198 it != pLines->
end(); it++) {
202 catch (Exception* _e) {
229String IniFile::getString(
230 const String& strSection,
231 const String& strEntry,
232 const wchar_t* pszDefault
238 String strResult = __getValue(strSection, strEntry);
240 if (strResult.isEmpty() && pszDefault !=
NULL)
241 strResult = pszDefault;
246int IniFile::getInteger(
247 const String& strSection,
248 const String& strEntry,
255 String strResult = __getValue(strSection, strEntry);
256 if (!strResult.isEmpty())
270void IniFile::setValue(
271 const String& strSection,
272 const String& strEntry,
273 const String& strValue
279 __setValue(strSection, strEntry, strValue);
282void IniFile::setValue(
283 const String& strSection,
284 const String& strEntry,
294String IniFile::__getValue(
295 const String& strSection,
296 const String& strEntry
305 IniLineList::Iterator it = pLines->
begin();
306 for(; it != pLines->
end(); it++)
309 && ((*it).m_strName.compareNoCase(strSection) == 0))
316 && ((*it).m_strName.compareNoCase(strEntry) == 0))
318 strResult = (*it).m_strValue;
330void IniFile::__setValue(
331 const String& strSection,
332 const String& strEntry,
333 const String& strValue
340 for(IniLineList::Iterator it = pLines->
begin(); it != pLines->
end(); it++)
343 && ((*it).m_strName.compareNoCase(strSection) == 0))
350 && ((*it).m_strName.compareNoCase(strEntry) == 0))
353 (*it).m_strValue = strValue;
357 pLines->
insert(it, IniLine(strEntry, strValue));
364 pLines->
addTail(IniLine(strEntry, strValue));
373RegIniFile::RegIniFile(HKEY hParentKey,
const String& strKey)
379 m_reg.create(strKey, KEY_ALL_ACCESS);
384void RegIniFile::close()
391String RegIniFile::getString(
392 const String& strSection,
393 const String& strEntry,
394 const wchar_t* pszDefault
404 Registry section(m_reg.key(), strSection, KEY_READ);
405 strResult = section.getString(strEntry);
413 strResult = pszDefault;
419int RegIniFile::getInteger(
420 const String& strSection,
421 const String& strEntry,
432 Registry section(m_reg.key(), strSection, KEY_READ);
433 nResult = section.getInteger(strEntry);
446void RegIniFile::setValue(
447 const String& strSection,
448 const String& strEntry,
449 const String& strValue
456 section.create(strSection);
457 section.setValue(strEntry, strValue);
460void RegIniFile::setValue(
461 const String& strSection,
462 const String& strEntry,
470 section.create(strSection);
471 section.setValue(strEntry, nValue);
List< IniLine > IniLineList
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
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)