[Common] Add EntryExists to IniFileClass.cpp

This commit is contained in:
zilmar 2016-04-28 17:22:59 +10:00
parent 0a161408be
commit d76a5ce7a2
2 changed files with 29 additions and 8 deletions

View File

@ -2,14 +2,14 @@
#include <stdlib.h> #include <stdlib.h>
CIniFileBase::CIniFileBase(CFileBase & FileObject, const char * FileName) : CIniFileBase::CIniFileBase(CFileBase & FileObject, const char * FileName) :
m_lastSectionSearch(0), m_lastSectionSearch(0),
m_CurrentSectionFilePos(0), m_CurrentSectionFilePos(0),
m_LineFeed("\r\n"), m_LineFeed("\r\n"),
m_ReadOnly(true), m_ReadOnly(true),
m_InstantFlush(true), m_InstantFlush(true),
m_File(FileObject), m_File(FileObject),
m_FileName(FileName), m_FileName(FileName),
m_CurrentSectionDirty(false) m_CurrentSectionDirty(false)
{ {
} }
@ -736,6 +736,26 @@ void CIniFileBase::SaveNumber(const char * lpSectionName, const char * lpKeyName
SaveString(lpSectionName, lpKeyName, stdstr_f("%d", Value).c_str()); SaveString(lpSectionName, lpKeyName, stdstr_f("%d", Value).c_str());
} }
bool CIniFileBase::EntryExists(const char * lpSectionName, const char * lpKeyName)
{
CGuard Guard(m_CS);
if (lpSectionName == NULL || strlen(lpSectionName) == 0)
{
lpSectionName = "default";
}
if (m_File.IsOpen() && MoveToSectionNameData(lpSectionName, true))
{
KeyValueList::iterator iter = m_CurrentSectionData.find(lpKeyName);
if (iter != m_CurrentSectionData.end())
{
return true;
}
}
return false;
}
void CIniFileBase::FlushChanges(void) void CIniFileBase::FlushChanges(void)
{ {
CGuard Guard(m_CS); CGuard Guard(m_CS);

View File

@ -90,6 +90,7 @@ public:
virtual void SaveNumber(const char * lpSectionName, const char * lpKeyName, uint32_t Value); virtual void SaveNumber(const char * lpSectionName, const char * lpKeyName, uint32_t Value);
void SetAutoFlush(bool AutoFlush); void SetAutoFlush(bool AutoFlush);
void FlushChanges(void); void FlushChanges(void);
bool EntryExists(const char * lpSectionName, const char * lpKeyName);
void GetKeyList(const char * lpSectionName, strlist &List); void GetKeyList(const char * lpSectionName, strlist &List);
void GetKeyValueData(const char * lpSectionName, KeyValueData & List); void GetKeyValueData(const char * lpSectionName, KeyValueData & List);