HGIni增加查询keyName的接口
This commit is contained in:
parent
7cf63691ce
commit
d0d684a71b
|
@ -83,6 +83,7 @@ HGBase_SetProfileString
|
||||||
HGBase_RemoveProfileSection
|
HGBase_RemoveProfileSection
|
||||||
HGBase_RenameProfileSection
|
HGBase_RenameProfileSection
|
||||||
HGBase_RemoveProfileConfig
|
HGBase_RemoveProfileConfig
|
||||||
|
HGBase_SearchProfileConfig
|
||||||
HGBase_GetProfileInt
|
HGBase_GetProfileInt
|
||||||
HGBase_GetProfileString
|
HGBase_GetProfileString
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,41 @@ HGResult HGAPI HGBase_RemoveProfileConfig(const HGChar* fileName, const HGChar*
|
||||||
return SaveIni(fileName, sectList);
|
return SaveIni(fileName, sectList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGBase_SearchProfileConfig(const HGChar* fileName, const HGChar* appName, const HGChar* keyName)
|
||||||
|
{
|
||||||
|
if (NULL == fileName || NULL == appName || NULL == keyName)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult ret = HGBASE_ERR_FAIL;
|
||||||
|
|
||||||
|
char sect[256];
|
||||||
|
sprintf(sect, "[%s]", appName);
|
||||||
|
|
||||||
|
SectionList sectList;
|
||||||
|
LoadIni(fileName, sectList);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sectList.size(); ++i)
|
||||||
|
{
|
||||||
|
if (strcmp(sectList[i].first.c_str(), sect) == 0)
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < sectList[i].second.size(); ++j)
|
||||||
|
{
|
||||||
|
if (strcmp(sectList[i].second[j].first.c_str(), keyName) == 0)
|
||||||
|
{
|
||||||
|
ret = HGBASE_ERR_OK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static HGResult IniReadValue(const char* section, const char* key, char* val, unsigned int maxLen, const char* def, const char* file)
|
static HGResult IniReadValue(const char* section, const char* key, char* val, unsigned int maxLen, const char* def, const char* file)
|
||||||
{
|
{
|
||||||
#if defined(HG_CMP_MSC)
|
#if defined(HG_CMP_MSC)
|
||||||
|
|
|
@ -26,6 +26,10 @@ HGEXPORT HGResult HGAPI HGBase_RenameProfileSection(const HGChar* fileName, cons
|
||||||
*/
|
*/
|
||||||
HGEXPORT HGResult HGAPI HGBase_RemoveProfileConfig(const HGChar* fileName, const HGChar* appName, const HGChar* keyName);
|
HGEXPORT HGResult HGAPI HGBase_RemoveProfileConfig(const HGChar* fileName, const HGChar* appName, const HGChar* keyName);
|
||||||
|
|
||||||
|
/* 查询ini文件的config
|
||||||
|
*/
|
||||||
|
HGEXPORT HGResult HGAPI HGBase_SearchProfileConfig(const HGChar* fileName, const HGChar* appName, const HGChar* keyName);
|
||||||
|
|
||||||
/* 获取ini文件的值
|
/* 获取ini文件的值
|
||||||
*/
|
*/
|
||||||
HGEXPORT HGResult HGAPI HGBase_GetProfileInt(const HGChar* fileName, const HGChar* appName,
|
HGEXPORT HGResult HGAPI HGBase_GetProfileInt(const HGChar* fileName, const HGChar* appName,
|
||||||
|
@ -36,4 +40,4 @@ HGEXPORT HGResult HGAPI HGBase_GetProfileInt(const HGChar* fileName, const HGCha
|
||||||
HGEXPORT HGResult HGAPI HGBase_GetProfileString(const HGChar* fileName, const HGChar* appName,
|
HGEXPORT HGResult HGAPI HGBase_GetProfileString(const HGChar* fileName, const HGChar* appName,
|
||||||
const HGChar* keyName, const HGChar* def, HGChar* value, HGUInt maxLen);
|
const HGChar* keyName, const HGChar* def, HGChar* value, HGUInt maxLen);
|
||||||
|
|
||||||
#endif /* __HGINI_H__ */
|
#endif /* __HGINI_H__ */
|
||||||
|
|
Loading…
Reference in New Issue