[Common] Get ini handling to use std::string instead of stdstr

This commit is contained in:
zilmar 2018-03-27 06:39:34 +11:00
parent 93ab869c3e
commit 4967242a11
3 changed files with 31 additions and 32 deletions

View File

@ -540,7 +540,7 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
return true;
}
bool CIniFileBase::GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault, stdstr & Value)
bool CIniFileBase::GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault, std::string & Value)
{
CGuard Guard(m_CS);
@ -562,9 +562,9 @@ bool CIniFileBase::GetString(const char * lpSectionName, const char * lpKeyName,
return false;
}
stdstr CIniFileBase::GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault)
std::string CIniFileBase::GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault)
{
stdstr Value;
std::string Value;
GetString(lpSectionName, lpKeyName, lpDefault, Value);
return Value;
}

View File

@ -22,21 +22,20 @@ class CIniFileBase
}
};
typedef std::string ansi_string;
typedef std::map<ansi_string, long> FILELOC;
typedef std::map<std::string, long> FILELOC;
typedef FILELOC::iterator FILELOC_ITR;
typedef std::map<ansi_string, ansi_string, insensitive_compare> KeyValueList;
typedef std::map<std::string, std::string, insensitive_compare> KeyValueList;
public:
typedef std::map<stdstr, stdstr> KeyValueData;
typedef std::vector<stdstr> SectionList;
typedef std::map<std::string, std::string> KeyValueData;
typedef std::vector<std::string> SectionList;
protected:
CFileBase & m_File;
stdstr m_FileName;
std::string m_FileName;
private:
ansi_string m_CurrentSection;
std::string m_CurrentSection;
bool m_CurrentSectionDirty;
int m_CurrentSectionFilePos; // Where in the file is the current Section
KeyValueList m_CurrentSectionData;
@ -68,8 +67,8 @@ public:
bool IsEmpty();
bool IsFileOpen(void);
bool DeleteSection(const char * lpSectionName);
bool GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault, stdstr & Value);
stdstr GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault);
bool GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault, std::string & Value);
std::string GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault);
uint32_t GetString(const char * lpSectionName, const char * lpKeyName, const char * lpDefault, char * lpReturnedString, uint32_t nSize);
uint32_t GetNumber(const char * lpSectionName, const char * lpKeyName, uint32_t nDefault);
bool GetNumber(const char * lpSectionName, const char * lpKeyName, uint32_t nDefault, uint32_t & Value);
@ -83,7 +82,7 @@ public:
void GetKeyValueData(const char * lpSectionName, KeyValueData & List);
void GetVectorOfSections(SectionList & sections);
const stdstr &GetFileName() { return m_FileName; }
const std::string &GetFileName() { return m_FileName; }
};
template <class CFileStorage>

View File

@ -314,7 +314,7 @@ DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPar
}
//RDB
CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
wcsncpy(String, RdbIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(RdbIniFile.GetString("Meta", "Author", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
if (wcslen(String) == 0)
{
EnableWindow(GetDlgItem(hDlg, IDC_RDB), FALSE);
@ -326,11 +326,11 @@ DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPar
set_about_field(hDlg, IDC_RDB_AUTHOR, wGS(INI_AUTHOR).c_str(), String);
wcsncpy(String, RdbIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(RdbIniFile.GetString("Meta", "Version", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
set_about_field(hDlg, IDC_RDB_VERSION, wGS(INI_VERSION).c_str(), String);
wcsncpy(String, RdbIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(RdbIniFile.GetString("Meta", "Date", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
set_about_field(hDlg, IDC_RDB_DATE, wGS(INI_DATE).c_str(), String);
wcsncpy(RDBHomePage, RdbIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDBHomePage) / sizeof(RDBHomePage[0]));
wcsncpy(RDBHomePage, stdstr(RdbIniFile.GetString("Meta", "Homepage", "")).ToUTF16().c_str(), sizeof(RDBHomePage) / sizeof(RDBHomePage[0]));
SetDlgItemTextW(hDlg, IDC_RDB_HOME, wGS(INI_HOMEPAGE).c_str());
if (wcslen(RDBHomePage) == 0)
{
@ -340,7 +340,7 @@ DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPar
//Cheat
SetDlgItemTextW(hDlg, IDC_CHT, wGS(INI_CURRENT_CHT).c_str());
CIniFile CheatIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str());
wcsncpy(String, CheatIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(CheatIniFile.GetString("Meta", "Author", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
if (wcslen(String) == 0)
{
EnableWindow(GetDlgItem(hDlg, IDC_CHT), FALSE);
@ -350,11 +350,11 @@ DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPar
EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE);
}
set_about_field(hDlg, IDC_CHT_AUTHOR, wGS(INI_AUTHOR).c_str(), String);
wcsncpy(String, CheatIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(CheatIniFile.GetString("Meta", "Version", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
set_about_field(hDlg, IDC_CHT_VERSION, wGS(INI_VERSION).c_str(), String);
wcsncpy(String, CheatIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(CheatIniFile.GetString("Meta", "Date", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
set_about_field(hDlg, IDC_CHT_DATE, wGS(INI_DATE).c_str(), String);
wcsncpy(CHTHomePage, CheatIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(CHTHomePage) / sizeof(CHTHomePage[0]));
wcsncpy(CHTHomePage, stdstr(CheatIniFile.GetString("Meta", "Homepage", "")).ToUTF16().c_str(), sizeof(CHTHomePage) / sizeof(CHTHomePage[0]));
SetDlgItemTextW(hDlg, IDC_CHT_HOME, wGS(INI_HOMEPAGE).c_str());
if (wcslen(CHTHomePage) == 0)
{
@ -364,7 +364,7 @@ DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPar
//Extended Info
SetDlgItemTextW(hDlg, IDC_RDX, wGS(INI_CURRENT_RDX).c_str());
CIniFile RdxIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str());
wcsncpy(String, RdxIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(RdxIniFile.GetString("Meta", "Author", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
if (wcslen(String) == 0)
{
EnableWindow(GetDlgItem(hDlg, IDC_RDX), FALSE);
@ -374,11 +374,11 @@ DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPar
EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE);
}
set_about_field(hDlg, IDC_RDX_AUTHOR, wGS(INI_AUTHOR).c_str(), String);
wcsncpy(String, RdxIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(RdxIniFile.GetString("Meta", "Version", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
set_about_field(hDlg, IDC_RDX_VERSION, wGS(INI_VERSION).c_str(), String);
wcsncpy(String, RdxIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
wcsncpy(String, stdstr(RdxIniFile.GetString("Meta", "Date", "")).ToUTF16().c_str(), sizeof(String) / sizeof(String[0]));
set_about_field(hDlg, IDC_RDX_DATE, wGS(INI_DATE).c_str(), String);
wcsncpy(RDXHomePage, RdxIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDXHomePage) / sizeof(RDXHomePage[0]));
wcsncpy(RDXHomePage, stdstr(RdxIniFile.GetString("Meta", "Homepage", "")).ToUTF16().c_str(), sizeof(RDXHomePage) / sizeof(RDXHomePage[0]));
SetDlgItemTextW(hDlg, IDC_RDX_HOME, wGS(INI_HOMEPAGE).c_str());
if (wcslen(RDXHomePage) == 0)
{