Project64: In ini handling change SectionList from vector to set
This commit is contained in:
parent
f5c2c33149
commit
7e503dc192
|
@ -497,7 +497,7 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
|
||||||
CGuard Guard(m_CS);
|
CGuard Guard(m_CS);
|
||||||
|
|
||||||
if (!m_File.IsOpen()) { return false; }
|
if (!m_File.IsOpen()) { return false; }
|
||||||
|
|
||||||
SaveCurrentSection();
|
SaveCurrentSection();
|
||||||
if (!MoveToSectionNameData(lpSectionName, true))
|
if (!MoveToSectionNameData(lpSectionName, true))
|
||||||
{
|
{
|
||||||
|
@ -517,10 +517,10 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
|
||||||
if (result <= 1) { continue; }
|
if (result <= 1) { continue; }
|
||||||
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
||||||
|
|
||||||
if (Input[0] != '[')
|
if (Input[0] != '[')
|
||||||
{
|
{
|
||||||
NextLine = (m_File.GetPosition() - DataSize) + ReadPos;
|
NextLine = (m_File.GetPosition() - DataSize) + ReadPos;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NextSectionStart = NextLine != 0 ? NextLine : (m_File.GetPosition() - DataSize) + ReadPos;
|
NextSectionStart = NextLine != 0 ? NextLine : (m_File.GetPosition() - DataSize) + ReadPos;
|
||||||
break;
|
break;
|
||||||
|
@ -869,7 +869,7 @@ void CIniFileBase::GetVectorOfSections(SectionList & sections)
|
||||||
|
|
||||||
for (FILELOC::const_iterator iter = m_SectionsPos.begin(); iter != m_SectionsPos.end(); iter++)
|
for (FILELOC::const_iterator iter = m_SectionsPos.begin(); iter != m_SectionsPos.end(); iter++)
|
||||||
{
|
{
|
||||||
sections.push_back(iter->first);
|
sections.insert(iter->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,15 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <set>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class CIniFileBase
|
class CIniFileBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<std::string, std::string> KeyValueData;
|
typedef std::map<std::string, std::string> KeyValueData;
|
||||||
typedef std::vector<std::string> SectionList;
|
typedef std::set<std::string> SectionList;
|
||||||
typedef std::list<std::string> strlist;
|
typedef std::list<std::string> strlist;
|
||||||
typedef std::pair<const std::string *, const std::string *> KeyValueItem;
|
typedef std::pair<const std::string *, const std::string *> KeyValueItem;
|
||||||
typedef std::vector<KeyValueItem> KeyValueVector;
|
typedef std::vector<KeyValueItem> KeyValueVector;
|
||||||
typedef void(*SortData)(KeyValueVector &);
|
typedef void(*SortData)(KeyValueVector &);
|
||||||
|
@ -68,7 +69,7 @@ private:
|
||||||
typedef std::map<std::string, long> FILELOC;
|
typedef std::map<std::string, long> FILELOC;
|
||||||
typedef FILELOC::iterator FILELOC_ITR;
|
typedef FILELOC::iterator FILELOC_ITR;
|
||||||
typedef std::map<std::string, std::string, insensitive_compare> KeyValueList;
|
typedef std::map<std::string, std::string, insensitive_compare> KeyValueList;
|
||||||
|
|
||||||
std::string m_CurrentSection;
|
std::string m_CurrentSection;
|
||||||
bool m_CurrentSectionDirty;
|
bool m_CurrentSectionDirty;
|
||||||
int m_CurrentSectionFilePos; // Where in the file is the current Section
|
int m_CurrentSectionFilePos; // Where in the file is the current Section
|
||||||
|
|
|
@ -70,9 +70,9 @@ void SplitFile(const char * FileName, const char * Target)
|
||||||
CIniFile CheatIniFile(FileName);
|
CIniFile CheatIniFile(FileName);
|
||||||
CheatIniFile.GetVectorOfSections(Sections);
|
CheatIniFile.GetVectorOfSections(Sections);
|
||||||
|
|
||||||
for (size_t i = 0, n = Sections.size(); i < n; i++)
|
for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
|
||||||
{
|
{
|
||||||
const char * Section = Sections[i].c_str();
|
const char * Section = SectionItr->c_str();
|
||||||
|
|
||||||
CIniFile::KeyValueData data;
|
CIniFile::KeyValueData data;
|
||||||
CheatIniFile.GetKeyValueData(Section, data);
|
CheatIniFile.GetKeyValueData(Section, data);
|
||||||
|
@ -136,9 +136,9 @@ void RegionSection(CFile &TargetIniFile, Files &files, const char * Region, cons
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
stdstr_f searchStr(":%s", RegionCode);
|
stdstr_f searchStr(":%s", RegionCode);
|
||||||
for (size_t i = 0, n = Sections.size(); i < n; i++)
|
for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
|
||||||
{
|
{
|
||||||
const char * Section = Sections[i].c_str();
|
const char * Section = SectionItr->c_str();
|
||||||
const char * pos = strstr(Section, searchStr.c_str());
|
const char * pos = strstr(Section, searchStr.c_str());
|
||||||
if (pos == NULL)
|
if (pos == NULL)
|
||||||
{
|
{
|
||||||
|
@ -147,15 +147,15 @@ void RegionSection(CFile &TargetIniFile, Files &files, const char * Region, cons
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0, n = Sections.size(); i < n; i++)
|
for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
|
||||||
{
|
{
|
||||||
const char * Section = Sections[i].c_str();
|
const char * Section = SectionItr->c_str();
|
||||||
|
|
||||||
CIniFile::KeyValueData data;
|
CIniFile::KeyValueData data;
|
||||||
GameIniFile.GetKeyValueData(Section, data);
|
GameIniFile.GetKeyValueData(Section, data);
|
||||||
|
@ -200,9 +200,9 @@ void JoinFile(const char * Directory, const char * Target)
|
||||||
|
|
||||||
CIniFile::SectionList Sections;
|
CIniFile::SectionList Sections;
|
||||||
GameIniFile.GetVectorOfSections(Sections);
|
GameIniFile.GetVectorOfSections(Sections);
|
||||||
for (size_t i = 0, n = Sections.size(); i < n; i++)
|
for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
|
||||||
{
|
{
|
||||||
const char * Section = Sections[i].c_str();
|
const char * Section = SectionItr->c_str();
|
||||||
stdstr Name = GameIniFile.GetString(Section, "Name", Section);
|
stdstr Name = GameIniFile.GetString(Section, "Name", Section);
|
||||||
Name.Trim("\t =");
|
Name.Trim("\t =");
|
||||||
if (Name.size() > 0)
|
if (Name.size() > 0)
|
||||||
|
@ -239,7 +239,7 @@ void JoinFile(const char * Directory, const char * Target)
|
||||||
{
|
{
|
||||||
CIniFile::KeyValueData data;
|
CIniFile::KeyValueData data;
|
||||||
MetaIniFile.GetKeyValueData("Meta", data);
|
MetaIniFile.GetKeyValueData("Meta", data);
|
||||||
|
|
||||||
LineData = stdstr_f("[Meta]\r\n");
|
LineData = stdstr_f("[Meta]\r\n");
|
||||||
TargetIniFile.Write(LineData.c_str(), (int)LineData.length());
|
TargetIniFile.Write(LineData.c_str(), (int)LineData.length());
|
||||||
for (CIniFile::KeyValueData::const_iterator itr = data.begin(); itr != data.end(); itr++)
|
for (CIniFile::KeyValueData::const_iterator itr = data.begin(); itr != data.end(); itr++)
|
||||||
|
@ -282,9 +282,9 @@ void UpdateNames(const char* Directory, const char* RdbFile)
|
||||||
CIniFile::SectionList Sections;
|
CIniFile::SectionList Sections;
|
||||||
CheatFile.GetVectorOfSections(Sections);
|
CheatFile.GetVectorOfSections(Sections);
|
||||||
CheatFile.SetCustomSort(CustomSortData);
|
CheatFile.SetCustomSort(CustomSortData);
|
||||||
for (size_t i = 0, n = Sections.size(); i < n; i++)
|
for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
|
||||||
{
|
{
|
||||||
const char * Section = Sections[i].c_str();
|
const char * Section = SectionItr->c_str();
|
||||||
std::string Name = RdbIni.GetString(Section, "Good Name", "");
|
std::string Name = RdbIni.GetString(Section, "Good Name", "");
|
||||||
if (Name.empty())
|
if (Name.empty())
|
||||||
{
|
{
|
||||||
|
@ -616,9 +616,9 @@ void convertGS(const char* Directory)
|
||||||
CIniFile::SectionList Sections;
|
CIniFile::SectionList Sections;
|
||||||
CheatFile.GetVectorOfSections(Sections);
|
CheatFile.GetVectorOfSections(Sections);
|
||||||
CheatFile.SetCustomSort(CustomSortData);
|
CheatFile.SetCustomSort(CustomSortData);
|
||||||
for (size_t i = 0, n = Sections.size(); i < n; i++)
|
for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
|
||||||
{
|
{
|
||||||
const char * Section = Sections[i].c_str();
|
const char * Section = SectionItr->c_str();
|
||||||
for (uint32_t cheat = 0; cheat < MaxCheats; cheat++)
|
for (uint32_t cheat = 0; cheat < MaxCheats; cheat++)
|
||||||
{
|
{
|
||||||
std::string CheatEntry = CheatFile.GetString(Section, stdstr_f("Cheat%d", cheat).c_str(), "");
|
std::string CheatEntry = CheatFile.GetString(Section, stdstr_f("Cheat%d", cheat).c_str(), "");
|
||||||
|
@ -846,9 +846,9 @@ void ConvertNew(const char * Src, const char * Dest)
|
||||||
MaxCheats = 50000,
|
MaxCheats = 50000,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0, n = Sections.size(); i < n; i++)
|
for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
|
||||||
{
|
{
|
||||||
const char * Section = Sections[i].c_str();
|
const char * Section = SectionItr->c_str();
|
||||||
std::string GameName = SrcIniFile.GetString(Section, "Name", "");
|
std::string GameName = SrcIniFile.GetString(Section, "Name", "");
|
||||||
DstCheatFile.SetName(Section, GameName.c_str());
|
DstCheatFile.SetName(Section, GameName.c_str());
|
||||||
for (uint32_t cheat = 0; cheat < MaxCheats; cheat++)
|
for (uint32_t cheat = 0; cheat < MaxCheats; cheat++)
|
||||||
|
|
|
@ -121,9 +121,9 @@ void CSettingTypeApplication::ResetAll()
|
||||||
}
|
}
|
||||||
CIniFile::SectionList sections;
|
CIniFile::SectionList sections;
|
||||||
m_SettingsIniFile->GetVectorOfSections(sections);
|
m_SettingsIniFile->GetVectorOfSections(sections);
|
||||||
for (size_t i = 0; i < sections.size(); i++)
|
for (CIniFile::SectionList::const_iterator itr = sections.begin(); itr != sections.end(); itr++)
|
||||||
{
|
{
|
||||||
m_SettingsIniFile->DeleteSection(sections[i].c_str());
|
m_SettingsIniFile->DeleteSection(itr->c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,14 +156,14 @@ bool CSettingTypeApplication::Load(uint32_t Index, bool & Value) const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->LoadBoolIndex(m_DefaultSetting, Index, Value);
|
g_Settings->LoadBoolIndex(m_DefaultSetting, Index, Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_Settings->LoadBool(m_DefaultSetting, Value);
|
g_Settings->LoadBool(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bRes;
|
return bRes;
|
||||||
|
@ -203,13 +203,13 @@ void CSettingTypeApplication::LoadDefault(uint32_t Index, bool & Value) const
|
||||||
{
|
{
|
||||||
Value = m_DefaultValue != 0;
|
Value = m_DefaultValue != 0;
|
||||||
}
|
}
|
||||||
else if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
else if (g_Settings->IndexBasedSetting(m_DefaultSetting))
|
||||||
{
|
{
|
||||||
g_Settings->LoadBoolIndex(m_DefaultSetting, Index, Value);
|
g_Settings->LoadBoolIndex(m_DefaultSetting, Index, Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_Settings->LoadBool(m_DefaultSetting, Value);
|
g_Settings->LoadBool(m_DefaultSetting, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ void CSettingTypeApplication::LoadDefault(uint32_t /*Index*/, std::string & Valu
|
||||||
//Update the settings
|
//Update the settings
|
||||||
void CSettingTypeApplication::Save(uint32_t Index, bool Value)
|
void CSettingTypeApplication::Save(uint32_t Index, bool Value)
|
||||||
{
|
{
|
||||||
bool indexed = g_Settings->IndexBasedSetting(m_DefaultSetting);
|
bool indexed = g_Settings->IndexBasedSetting(m_DefaultSetting);
|
||||||
|
|
||||||
if (m_DefaultSetting != Default_None &&
|
if (m_DefaultSetting != Default_None &&
|
||||||
((m_DefaultSetting == Default_Constant && m_DefaultValue == (uint32_t)Value) ||
|
((m_DefaultSetting == Default_Constant && m_DefaultValue == (uint32_t)Value) ||
|
||||||
|
|
|
@ -118,10 +118,8 @@
|
||||||
<ClCompile Include="UserInterface\WTLControls\wtl-BitmapPicture.cpp" />
|
<ClCompile Include="UserInterface\WTLControls\wtl-BitmapPicture.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="DiscordRPC.h" />
|
|
||||||
<ClInclude Include="UserInterface\Debugger\CPULog.h" />
|
<ClInclude Include="UserInterface\Debugger\CPULog.h" />
|
||||||
<ClInclude Include="UserInterface\Debugger\Debugger-CPULogView.h" />
|
<ClInclude Include="UserInterface\Debugger\Debugger-CPULogView.h" />
|
||||||
<ClInclude Include="N64System\Debugger\OpInfo.h" />
|
|
||||||
<ClInclude Include="N64System.h" />
|
<ClInclude Include="N64System.h" />
|
||||||
<ClInclude Include="Settings\GuiSettings.h" />
|
<ClInclude Include="Settings\GuiSettings.h" />
|
||||||
<ClInclude Include="Settings\NotificationSettings.h" />
|
<ClInclude Include="Settings\NotificationSettings.h" />
|
||||||
|
@ -157,7 +155,6 @@
|
||||||
<ClInclude Include="UserInterface\Debugger\ScriptHook.h" />
|
<ClInclude Include="UserInterface\Debugger\ScriptHook.h" />
|
||||||
<ClInclude Include="UserInterface\Debugger\ScriptInstance.h" />
|
<ClInclude Include="UserInterface\Debugger\ScriptInstance.h" />
|
||||||
<ClInclude Include="UserInterface\Debugger\ScriptSystem.h" />
|
<ClInclude Include="UserInterface\Debugger\ScriptSystem.h" />
|
||||||
<ClInclude Include="UserInterface\Debugger\stdafx.h" />
|
|
||||||
<ClInclude Include="UserInterface\Debugger\Symbols.h" />
|
<ClInclude Include="UserInterface\Debugger\Symbols.h" />
|
||||||
<ClInclude Include="UserInterface\EnhancementConfig.h" />
|
<ClInclude Include="UserInterface\EnhancementConfig.h" />
|
||||||
<ClInclude Include="UserInterface\MainWindow.h" />
|
<ClInclude Include="UserInterface\MainWindow.h" />
|
||||||
|
|
|
@ -353,9 +353,6 @@
|
||||||
<ClInclude Include="UserInterface\SupportWindow.h">
|
<ClInclude Include="UserInterface\SupportWindow.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="N64System\Debugger\OpInfo.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="UserInterface\WTLControls\TooltipDialog.h">
|
<ClInclude Include="UserInterface\WTLControls\TooltipDialog.h">
|
||||||
<Filter>Header Files\User Interface Headers\WTL Controls Headers</Filter>
|
<Filter>Header Files\User Interface Headers\WTL Controls Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -428,9 +425,6 @@
|
||||||
<ClInclude Include="UserInterface\Debugger\ScriptSystem.h">
|
<ClInclude Include="UserInterface\Debugger\ScriptSystem.h">
|
||||||
<Filter>Header Files\User Interface Headers\Debugger Headers</Filter>
|
<Filter>Header Files\User Interface Headers\Debugger Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="UserInterface\Debugger\stdafx.h">
|
|
||||||
<Filter>Header Files\User Interface Headers\Debugger Headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="UserInterface\Debugger\Symbols.h">
|
<ClInclude Include="UserInterface\Debugger\Symbols.h">
|
||||||
<Filter>Header Files\User Interface Headers\Debugger Headers</Filter>
|
<Filter>Header Files\User Interface Headers\Debugger Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -461,9 +455,6 @@
|
||||||
<ClInclude Include="UserInterface\Settings\SettingsPage-DiskDrive.h">
|
<ClInclude Include="UserInterface\Settings\SettingsPage-DiskDrive.h">
|
||||||
<Filter>Header Files\User Interface Headers\Settings Header</Filter>
|
<Filter>Header Files\User Interface Headers\Settings Header</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="DiscordRPC.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="UserInterface\WTLControls\HexEditCtrl.h">
|
<ClInclude Include="UserInterface\WTLControls\HexEditCtrl.h">
|
||||||
<Filter>Header Files\User Interface Headers\WTL Controls Headers</Filter>
|
<Filter>Header Files\User Interface Headers\WTL Controls Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
Loading…
Reference in New Issue