本文整理汇总了C++中ConfigFile::GetEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::GetEntry方法的具体用法?C++ ConfigFile::GetEntry怎么用?C++ ConfigFile::GetEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::GetEntry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cfgLoadStr
void EXPORT_CALL cfgLoadStr(const wchar * Section, const wchar * Key, wchar * Return,const wchar* Default)
{
verify(Section!=0 && wcslen(Section)!=0);
verify(Key!=0 && wcslen(Key)!=0);
verify(Return!=0);
if (Default==0)
Default=L"";
ConfigSection* cs= cfgdb.GetEntry(Section);
ConfigEntry* ce=cs->FindEntry(Key);
if (!ce)
{
cs->SetEntry(Key,Default,CEM_SAVE);
wcscpy(Return,Default);
}
else
{
wcscpy(Return,ce->GetValue().c_str());
}
}
示例2: cfgOpen
bool cfgOpen()
{
wchar * tmpPath = GetEmuPath(L"");
wcscpy(appPath, tmpPath);
free(tmpPath);
if (cfgPath[0]==0)
swprintf(cfgPath,L"%snullDC.cfg", appPath);
swprintf(dataPath,L"%sdata\\", appPath);
swprintf(pluginPath,L"%splugins\\", appPath);
ConfigSection* cs= cfgdb.GetEntry(L"emu");
cs->SetEntry(L"AppPath",appPath,CEM_VIRTUAL | CEM_READONLY);
cs->SetEntry(L"PluginPath",pluginPath,CEM_VIRTUAL | CEM_READONLY);
cs->SetEntry(L"DataPath",dataPath,CEM_VIRTUAL | CEM_READONLY);
cs->SetEntry(L"FullName",VER_FULLNAME,CEM_VIRTUAL | CEM_READONLY);
cs->SetEntry(L"ShortName",VER_SHORTNAME,CEM_VIRTUAL | CEM_READONLY);
cs->SetEntry(L"Name",VER_EMUNAME,CEM_VIRTUAL | CEM_READONLY);
FILE* cfgfile = _tfopen(cfgPath,L"r");
if(!cfgfile) {
cfgfile = _tfopen(cfgPath,L"wt");
if(!cfgfile)
log("Unable to open the config file for reading or writing\nfile : %s\n",cfgPath);
else
{
fprintf(cfgfile,";; nullDC cfg file ;;\n\n");
fseek(cfgfile,0,SEEK_SET);
fclose(cfgfile);
cfgfile = _tfopen(cfgPath,L"r");
if(!cfgfile)
log("Unable to open the config file for reading\nfile : %s\n",cfgPath);
}
}
wchar line[512];
wchar cur_sect[512]={0};
int cline=0;
while(cfgfile && !feof(cfgfile))
{
cline++;
fgetws(line,512,cfgfile);
if (wcslen(line)<3)
continue;
if (line[wcslen(line)-1]=='\r' || line[wcslen(line)-1]=='\n')
line[wcslen(line)-1]=0;
wchar* tl=trim_ws(line);
if (tl[0]=='[' && tl[wcslen(tl)-1]==']')
{
tl[wcslen(tl)-1]=0;
wcscpy(cur_sect,tl+1);
trim_ws(cur_sect);
}
else
{
if (cur_sect[0]==0)
continue;//no open section
wchar* str1=wcsstr(tl,L"=");
if (!str1)
{
wprintf(L"Malformed entry on cfg, ignoring @ %d(%s)\n",cline,tl);
continue;
}
*str1=0;
str1++;
wchar* v=trim_ws(str1);
wchar* k=trim_ws(tl);
if (v && k)
{
ConfigSection*cs=cfgdb.GetEntry(cur_sect);
//if (!cs->FindEntry(k))
cs->SetEntry(k,v,CEM_SAVE|CEM_LOAD);
}
else
{
wprintf(L"Malformed entry on cfg, ignoring @ %d(%s)\n",cline,tl);
}
}
}
for (size_t i=0;i<vlist.size();i++)
{
cfgdb.GetEntry(vlist[i].s)->SetEntry(vlist[i].n,vlist[i].v,CEM_VIRTUAL);
}
if (cfgfile)
{
cfgdb.SaveFile(cfgfile);
fclose(cfgfile);
}
return true;
}
示例3: cfgSaveStr
void EXPORT_CALL cfgSaveStr(const wchar * Section, const wchar * Key, const wchar * String)
{
cfgdb.GetEntry(Section)->SetEntry(Key,String,CEM_SAVE);
savecfgf();
//WritePrivateProfileString(Section,Key,String,cfgPath);
}