Fix IniFile to use string& instead of char*
Also removes .c_str() usages where found.
This commit is contained in:
parent
079b1ba93d
commit
3fe05e0a9f
|
@ -37,7 +37,9 @@ void ParseLine(const std::string& line, std::string* keyOut, std::string* valueO
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::Section::Set(const char* key, const char* newValue)
|
const std::string& IniFile::NULL_STRING = "";
|
||||||
|
|
||||||
|
void IniFile::Section::Set(const std::string& key, const std::string& newValue)
|
||||||
{
|
{
|
||||||
auto it = values.find(key);
|
auto it = values.find(key);
|
||||||
if (it != values.end())
|
if (it != values.end())
|
||||||
|
@ -49,7 +51,7 @@ void IniFile::Section::Set(const char* key, const char* newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::Section::Set(const char* key, const std::string& newValue, const std::string& defaultValue)
|
void IniFile::Section::Set(const std::string& key, const std::string& newValue, const std::string& defaultValue)
|
||||||
{
|
{
|
||||||
if (newValue != defaultValue)
|
if (newValue != defaultValue)
|
||||||
Set(key, newValue);
|
Set(key, newValue);
|
||||||
|
@ -57,7 +59,7 @@ void IniFile::Section::Set(const char* key, const std::string& newValue, const s
|
||||||
Delete(key);
|
Delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::Section::Set(const char* key, const float newValue, const float defaultValue)
|
void IniFile::Section::Set(const std::string& key, const float newValue, const float defaultValue)
|
||||||
{
|
{
|
||||||
if (newValue != defaultValue)
|
if (newValue != defaultValue)
|
||||||
Set(key, newValue);
|
Set(key, newValue);
|
||||||
|
@ -65,7 +67,7 @@ void IniFile::Section::Set(const char* key, const float newValue, const float de
|
||||||
Delete(key);
|
Delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::Section::Set(const char* key, int newValue, int defaultValue)
|
void IniFile::Section::Set(const std::string& key, int newValue, int defaultValue)
|
||||||
{
|
{
|
||||||
if (newValue != defaultValue)
|
if (newValue != defaultValue)
|
||||||
Set(key, newValue);
|
Set(key, newValue);
|
||||||
|
@ -73,7 +75,7 @@ void IniFile::Section::Set(const char* key, int newValue, int defaultValue)
|
||||||
Delete(key);
|
Delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::Section::Set(const char* key, bool newValue, bool defaultValue)
|
void IniFile::Section::Set(const std::string& key, bool newValue, bool defaultValue)
|
||||||
{
|
{
|
||||||
if (newValue != defaultValue)
|
if (newValue != defaultValue)
|
||||||
Set(key, newValue);
|
Set(key, newValue);
|
||||||
|
@ -81,7 +83,7 @@ void IniFile::Section::Set(const char* key, bool newValue, bool defaultValue)
|
||||||
Delete(key);
|
Delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::Section::Set(const char* key, const std::vector<std::string>& newValues)
|
void IniFile::Section::Set(const std::string& key, const std::vector<std::string>& newValues)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
// Join the strings with ,
|
// Join the strings with ,
|
||||||
|
@ -92,10 +94,10 @@ void IniFile::Section::Set(const char* key, const std::vector<std::string>& newV
|
||||||
}
|
}
|
||||||
// remove last ,
|
// remove last ,
|
||||||
temp.resize(temp.length() - 1);
|
temp.resize(temp.length() - 1);
|
||||||
Set(key, temp.c_str());
|
Set(key, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const char* key, std::string* value, const char* defaultValue)
|
bool IniFile::Section::Get(const std::string& key, std::string* value, const std::string& defaultValue)
|
||||||
{
|
{
|
||||||
auto it = values.find(key);
|
auto it = values.find(key);
|
||||||
if (it != values.end())
|
if (it != values.end())
|
||||||
|
@ -103,7 +105,7 @@ bool IniFile::Section::Get(const char* key, std::string* value, const char* defa
|
||||||
*value = it->second;
|
*value = it->second;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (defaultValue)
|
else if (&defaultValue != &NULL_STRING)
|
||||||
{
|
{
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return true;
|
return true;
|
||||||
|
@ -112,10 +114,10 @@ bool IniFile::Section::Get(const char* key, std::string* value, const char* defa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const char* key, std::vector<std::string>& out)
|
bool IniFile::Section::Get(const std::string& key, std::vector<std::string>& out)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp, 0);
|
bool retval = Get(key, &temp);
|
||||||
if (!retval || temp.empty())
|
if (!retval || temp.empty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -138,62 +140,62 @@ bool IniFile::Section::Get(const char* key, std::vector<std::string>& out)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const char* key, int* value, int defaultValue)
|
bool IniFile::Section::Get(const std::string& key, int* value, int defaultValue)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp, 0);
|
bool retval = Get(key, &temp);
|
||||||
if (retval && TryParse(temp.c_str(), value))
|
|
||||||
return true;
|
|
||||||
*value = defaultValue;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IniFile::Section::Get(const char* key, u32* value, u32 defaultValue)
|
|
||||||
{
|
|
||||||
std::string temp;
|
|
||||||
bool retval = Get(key, &temp, 0);
|
|
||||||
if (retval && TryParse(temp, value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const char* key, bool* value, bool defaultValue)
|
bool IniFile::Section::Get(const std::string& key, u32* value, u32 defaultValue)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp, 0);
|
bool retval = Get(key, &temp);
|
||||||
if (retval && TryParse(temp.c_str(), value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const char* key, float* value, float defaultValue)
|
bool IniFile::Section::Get(const std::string& key, bool* value, bool defaultValue)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp, 0);
|
bool retval = Get(key, &temp);
|
||||||
if (retval && TryParse(temp.c_str(), value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const char* key, double* value, double defaultValue)
|
bool IniFile::Section::Get(const std::string& key, float* value, float defaultValue)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp, 0);
|
bool retval = Get(key, &temp);
|
||||||
if (retval && TryParse(temp.c_str(), value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Exists(const char *key) const
|
bool IniFile::Section::Get(const std::string& key, double* value, double defaultValue)
|
||||||
|
{
|
||||||
|
std::string temp;
|
||||||
|
bool retval = Get(key, &temp);
|
||||||
|
if (retval && TryParse(temp, value))
|
||||||
|
return true;
|
||||||
|
*value = defaultValue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IniFile::Section::Exists(const std::string& key) const
|
||||||
{
|
{
|
||||||
return values.find(key) != values.end();
|
return values.find(key) != values.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Delete(const char *key)
|
bool IniFile::Section::Delete(const std::string& key)
|
||||||
{
|
{
|
||||||
auto it = values.find(key);
|
auto it = values.find(key);
|
||||||
if (it == values.end())
|
if (it == values.end())
|
||||||
|
@ -206,23 +208,23 @@ bool IniFile::Section::Delete(const char *key)
|
||||||
|
|
||||||
// IniFile
|
// IniFile
|
||||||
|
|
||||||
const IniFile::Section* IniFile::GetSection(const char* sectionName) const
|
const IniFile::Section* IniFile::GetSection(const std::string& sectionName) const
|
||||||
{
|
{
|
||||||
for (const auto& sect : sections)
|
for (const auto& sect : sections)
|
||||||
if (!strcasecmp(sect.name.c_str(), sectionName))
|
if (!strcasecmp(sect.name.c_str(), sectionName.c_str()))
|
||||||
return (&(sect));
|
return (&(sect));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile::Section* IniFile::GetSection(const char* sectionName)
|
IniFile::Section* IniFile::GetSection(const std::string& sectionName)
|
||||||
{
|
{
|
||||||
for (auto& sect : sections)
|
for (auto& sect : sections)
|
||||||
if (!strcasecmp(sect.name.c_str(), sectionName))
|
if (!strcasecmp(sect.name.c_str(), sectionName.c_str()))
|
||||||
return (&(sect));
|
return (&(sect));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile::Section* IniFile::GetOrCreateSection(const char* sectionName)
|
IniFile::Section* IniFile::GetOrCreateSection(const std::string& sectionName)
|
||||||
{
|
{
|
||||||
Section* section = GetSection(sectionName);
|
Section* section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
@ -233,7 +235,7 @@ IniFile::Section* IniFile::GetOrCreateSection(const char* sectionName)
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::DeleteSection(const char* sectionName)
|
bool IniFile::DeleteSection(const std::string& sectionName)
|
||||||
{
|
{
|
||||||
Section* s = GetSection(sectionName);
|
Section* s = GetSection(sectionName);
|
||||||
if (!s)
|
if (!s)
|
||||||
|
@ -249,7 +251,7 @@ bool IniFile::DeleteSection(const char* sectionName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Exists(const char* sectionName, const char* key) const
|
bool IniFile::Exists(const std::string& sectionName, const std::string& key) const
|
||||||
{
|
{
|
||||||
const Section* section = GetSection(sectionName);
|
const Section* section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
@ -257,13 +259,13 @@ bool IniFile::Exists(const char* sectionName, const char* key) const
|
||||||
return section->Exists(key);
|
return section->Exists(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::SetLines(const char* sectionName, const std::vector<std::string> &lines)
|
void IniFile::SetLines(const std::string& sectionName, const std::vector<std::string> &lines)
|
||||||
{
|
{
|
||||||
Section* section = GetOrCreateSection(sectionName);
|
Section* section = GetOrCreateSection(sectionName);
|
||||||
section->lines = lines;
|
section->lines = lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::DeleteKey(const char* sectionName, const char* key)
|
bool IniFile::DeleteKey(const std::string& sectionName, const std::string& key)
|
||||||
{
|
{
|
||||||
Section* section = GetSection(sectionName);
|
Section* section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
@ -272,7 +274,7 @@ bool IniFile::DeleteKey(const char* sectionName, const char* key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of all keys in a section
|
// Return a list of all keys in a section
|
||||||
bool IniFile::GetKeys(const char* sectionName, std::vector<std::string>& keys) const
|
bool IniFile::GetKeys(const std::string& sectionName, std::vector<std::string>& keys) const
|
||||||
{
|
{
|
||||||
const Section* section = GetSection(sectionName);
|
const Section* section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
@ -282,7 +284,7 @@ bool IniFile::GetKeys(const char* sectionName, std::vector<std::string>& keys) c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of all lines in a section
|
// Return a list of all lines in a section
|
||||||
bool IniFile::GetLines(const char* sectionName, std::vector<std::string>& lines, const bool remove_comments) const
|
bool IniFile::GetLines(const std::string& sectionName, std::vector<std::string>& lines, const bool remove_comments) const
|
||||||
{
|
{
|
||||||
const Section* section = GetSection(sectionName);
|
const Section* section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
@ -319,7 +321,7 @@ void IniFile::SortSections()
|
||||||
std::sort(sections.begin(), sections.end());
|
std::sort(sections.begin(), sections.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Load(const char* filename, bool keep_current_data)
|
bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||||
{
|
{
|
||||||
// Maximum number of letters in a line
|
// Maximum number of letters in a line
|
||||||
static const int MAX_BYTES = 1024*32;
|
static const int MAX_BYTES = 1024*32;
|
||||||
|
@ -359,7 +361,7 @@ bool IniFile::Load(const char* filename, bool keep_current_data)
|
||||||
{
|
{
|
||||||
// New section!
|
// New section!
|
||||||
std::string sub = line.substr(1, endpos - 1);
|
std::string sub = line.substr(1, endpos - 1);
|
||||||
current_section = GetOrCreateSection(sub.c_str());
|
current_section = GetOrCreateSection(sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -374,9 +376,9 @@ bool IniFile::Load(const char* filename, bool keep_current_data)
|
||||||
// INI is a hack anyway.
|
// INI is a hack anyway.
|
||||||
if ((key == "" && value == "")
|
if ((key == "" && value == "")
|
||||||
|| (line.size() >= 1 && (line[0] == '$' || line[0] == '+' || line[0] == '*')))
|
|| (line.size() >= 1 && (line[0] == '$' || line[0] == '+' || line[0] == '*')))
|
||||||
current_section->lines.push_back(line.c_str());
|
current_section->lines.push_back(line);
|
||||||
else
|
else
|
||||||
current_section->Set(key, value.c_str());
|
current_section->Set(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,7 +388,7 @@ bool IniFile::Load(const char* filename, bool keep_current_data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Save(const char* filename)
|
bool IniFile::Save(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::ofstream out;
|
std::ofstream out;
|
||||||
std::string temp = File::GetTempFilenameForAtomicWrite(filename);
|
std::string temp = File::GetTempFilenameForAtomicWrite(filename);
|
||||||
|
@ -422,20 +424,7 @@ bool IniFile::Save(const char* filename)
|
||||||
return File::RenameSync(temp, filename);
|
return File::RenameSync(temp, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IniFile::Get(const std::string& sectionName, const std::string& key, std::vector<std::string>& values)
|
||||||
bool IniFile::Get(const char* sectionName, const char* key, std::string* value, const char* defaultValue)
|
|
||||||
{
|
|
||||||
Section* section = GetSection(sectionName);
|
|
||||||
if (!section) {
|
|
||||||
if (defaultValue) {
|
|
||||||
*value = defaultValue;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return section->Get(key, value, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IniFile::Get(const char *sectionName, const char* key, std::vector<std::string>& values)
|
|
||||||
{
|
{
|
||||||
Section *section = GetSection(sectionName);
|
Section *section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
@ -443,7 +432,7 @@ bool IniFile::Get(const char *sectionName, const char* key, std::vector<std::str
|
||||||
return section->Get(key, values);
|
return section->Get(key, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Get(const char* sectionName, const char* key, int* value, int defaultValue)
|
bool IniFile::Get(const std::string& sectionName, const std::string& key, int* value, int defaultValue)
|
||||||
{
|
{
|
||||||
Section *section = GetSection(sectionName);
|
Section *section = GetSection(sectionName);
|
||||||
if (!section) {
|
if (!section) {
|
||||||
|
@ -454,7 +443,7 @@ bool IniFile::Get(const char* sectionName, const char* key, int* value, int defa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Get(const char* sectionName, const char* key, u32* value, u32 defaultValue)
|
bool IniFile::Get(const std::string& sectionName, const std::string& key, u32* value, u32 defaultValue)
|
||||||
{
|
{
|
||||||
Section *section = GetSection(sectionName);
|
Section *section = GetSection(sectionName);
|
||||||
if (!section) {
|
if (!section) {
|
||||||
|
@ -465,7 +454,7 @@ bool IniFile::Get(const char* sectionName, const char* key, u32* value, u32 defa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Get(const char* sectionName, const char* key, bool* value, bool defaultValue)
|
bool IniFile::Get(const std::string& sectionName, const std::string& key, bool* value, bool defaultValue)
|
||||||
{
|
{
|
||||||
Section *section = GetSection(sectionName);
|
Section *section = GetSection(sectionName);
|
||||||
if (!section) {
|
if (!section) {
|
||||||
|
@ -476,6 +465,19 @@ bool IniFile::Get(const char* sectionName, const char* key, bool* value, bool de
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IniFile::Get(const std::string& sectionName, const std::string& key, std::string* value, const std::string& defaultValue)
|
||||||
|
{
|
||||||
|
Section* section = GetSection(sectionName);
|
||||||
|
if (!section) {
|
||||||
|
if (&defaultValue != &NULL_STRING) {
|
||||||
|
*value = defaultValue;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return section->Get(key, value, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Unit test. TODO: Move to the real unit test framework.
|
// Unit test. TODO: Move to the real unit test framework.
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -32,45 +32,42 @@ public:
|
||||||
Section() {}
|
Section() {}
|
||||||
Section(const std::string& _name) : name(_name) {}
|
Section(const std::string& _name) : name(_name) {}
|
||||||
|
|
||||||
bool Exists(const char *key) const;
|
bool Exists(const std::string& key) const;
|
||||||
bool Delete(const char *key);
|
bool Delete(const std::string& key);
|
||||||
|
|
||||||
void Set(const char* key, const char* newValue);
|
void Set(const std::string& key, const std::string& newValue);
|
||||||
void Set(const char* key, const std::string& newValue, const std::string& defaultValue);
|
void Set(const std::string& key, const std::string& newValue, const std::string& defaultValue);
|
||||||
|
|
||||||
void Set(const std::string &key, const std::string &value) {
|
bool Get(const std::string& key, std::string* value, const std::string& defaultValue = NULL_STRING);
|
||||||
Set(key.c_str(), value.c_str());
|
|
||||||
}
|
|
||||||
bool Get(const char* key, std::string* value, const char* defaultValue);
|
|
||||||
|
|
||||||
void Set(const char* key, u32 newValue) {
|
void Set(const std::string& key, u32 newValue) {
|
||||||
Set(key, StringFromFormat("0x%08x", newValue).c_str());
|
Set(key, StringFromFormat("0x%08x", newValue));
|
||||||
}
|
}
|
||||||
void Set(const char* key, float newValue) {
|
void Set(const std::string& key, float newValue) {
|
||||||
Set(key, StringFromFormat("%f", newValue).c_str());
|
Set(key, StringFromFormat("%f", newValue));
|
||||||
}
|
}
|
||||||
void Set(const char* key, const float newValue, const float defaultValue);
|
void Set(const std::string& key, const float newValue, const float defaultValue);
|
||||||
void Set(const char* key, double newValue) {
|
void Set(const std::string& key, double newValue) {
|
||||||
Set(key, StringFromFormat("%f", newValue).c_str());
|
Set(key, StringFromFormat("%f", newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const char* key, int newValue, int defaultValue);
|
void Set(const std::string& key, int newValue, int defaultValue);
|
||||||
void Set(const char* key, int newValue) {
|
void Set(const std::string& key, int newValue) {
|
||||||
Set(key, StringFromInt(newValue).c_str());
|
Set(key, StringFromInt(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const char* key, bool newValue, bool defaultValue);
|
void Set(const std::string& key, bool newValue, bool defaultValue);
|
||||||
void Set(const char* key, bool newValue) {
|
void Set(const std::string& key, bool newValue) {
|
||||||
Set(key, StringFromBool(newValue).c_str());
|
Set(key, StringFromBool(newValue));
|
||||||
}
|
}
|
||||||
void Set(const char* key, const std::vector<std::string>& newValues);
|
void Set(const std::string& key, const std::vector<std::string>& newValues);
|
||||||
|
|
||||||
bool Get(const char* key, int* value, int defaultValue = 0);
|
bool Get(const std::string& key, int* value, int defaultValue = 0);
|
||||||
bool Get(const char* key, u32* value, u32 defaultValue = 0);
|
bool Get(const std::string& key, u32* value, u32 defaultValue = 0);
|
||||||
bool Get(const char* key, bool* value, bool defaultValue = false);
|
bool Get(const std::string& key, bool* value, bool defaultValue = false);
|
||||||
bool Get(const char* key, float* value, float defaultValue = false);
|
bool Get(const std::string& key, float* value, float defaultValue = false);
|
||||||
bool Get(const char* key, double* value, double defaultValue = false);
|
bool Get(const std::string& key, double* value, double defaultValue = false);
|
||||||
bool Get(const char* key, std::vector<std::string>& values);
|
bool Get(const std::string& key, std::vector<std::string>& values);
|
||||||
|
|
||||||
bool operator < (const Section& other) const {
|
bool operator < (const Section& other) const {
|
||||||
return name < other.name;
|
return name < other.name;
|
||||||
|
@ -92,72 +89,65 @@ public:
|
||||||
* @warning Using any other operations than "Get*" and "Exists" is untested and will behave unexpectedly
|
* @warning Using any other operations than "Get*" and "Exists" is untested and will behave unexpectedly
|
||||||
* @todo This really is just a hack to support having two levels of gameinis (defaults and user-specified) and should eventually be replaced with a less stupid system.
|
* @todo This really is just a hack to support having two levels of gameinis (defaults and user-specified) and should eventually be replaced with a less stupid system.
|
||||||
*/
|
*/
|
||||||
bool Load(const char* filename, bool keep_current_data = false);
|
bool Load(const std::string& filename, bool keep_current_data = false);
|
||||||
bool Load(const std::string &filename, bool keep_current_data = false) { return Load(filename.c_str(), keep_current_data); }
|
|
||||||
|
|
||||||
bool Save(const char* filename);
|
bool Save(const std::string& filename);
|
||||||
bool Save(const std::string &filename) { return Save(filename.c_str()); }
|
|
||||||
|
|
||||||
// Returns true if key exists in section
|
// Returns true if key exists in section
|
||||||
bool Exists(const char* sectionName, const char* key) const;
|
bool Exists(const std::string& sectionName, const std::string& key) const;
|
||||||
|
|
||||||
// TODO: Get rid of these, in favor of the Section ones.
|
// TODO: Get rid of these, in favor of the Section ones.
|
||||||
void Set(const char* sectionName, const char* key, const char* newValue) {
|
void Set(const std::string& sectionName, const std::string& key, const std::string& newValue) {
|
||||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||||
}
|
}
|
||||||
void Set(const char* sectionName, const char* key, const std::string& newValue) {
|
void Set(const std::string& sectionName, const std::string& key, int newValue) {
|
||||||
GetOrCreateSection(sectionName)->Set(key, newValue.c_str());
|
|
||||||
}
|
|
||||||
void Set(const char* sectionName, const char* key, int newValue) {
|
|
||||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||||
}
|
}
|
||||||
void Set(const char* sectionName, const char* key, u32 newValue) {
|
void Set(const std::string& sectionName, const std::string& key, u32 newValue) {
|
||||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||||
}
|
}
|
||||||
void Set(const char* sectionName, const char* key, bool newValue) {
|
void Set(const std::string& sectionName, const std::string& key, bool newValue) {
|
||||||
GetOrCreateSection(sectionName)->Set(key, newValue);
|
GetOrCreateSection(sectionName)->Set(key, newValue);
|
||||||
}
|
}
|
||||||
void Set(const char* sectionName, const char* key, const std::vector<std::string>& newValues) {
|
void Set(const std::string& sectionName, const std::string& key, const std::vector<std::string>& newValues) {
|
||||||
GetOrCreateSection(sectionName)->Set(key, newValues);
|
GetOrCreateSection(sectionName)->Set(key, newValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Get rid of these, in favor of the Section ones.
|
// TODO: Get rid of these, in favor of the Section ones.
|
||||||
bool Get(const char* sectionName, const char* key, std::string* value, const char* defaultValue = "");
|
bool Get(const std::string& sectionName, const std::string& key, int* value, int defaultValue = 0);
|
||||||
bool Get(const char* sectionName, const char* key, int* value, int defaultValue = 0);
|
bool Get(const std::string& sectionName, const std::string& key, u32* value, u32 defaultValue = 0);
|
||||||
bool Get(const char* sectionName, const char* key, u32* value, u32 defaultValue = 0);
|
bool Get(const std::string& sectionName, const std::string& key, bool* value, bool defaultValue = false);
|
||||||
bool Get(const char* sectionName, const char* key, bool* value, bool defaultValue = false);
|
bool Get(const std::string& sectionName, const std::string& key, std::vector<std::string>& values);
|
||||||
bool Get(const char* sectionName, const char* key, std::vector<std::string>& values);
|
bool Get(const std::string& sectionName, const std::string& key, std::string* value, const std::string& defaultValue = NULL_STRING);
|
||||||
|
|
||||||
template<typename T> bool GetIfExists(const char* sectionName, const char* key, T value)
|
template<typename T> bool GetIfExists(const std::string& sectionName, const std::string& key, T value)
|
||||||
{
|
{
|
||||||
if (Exists(sectionName, key))
|
if (Exists(sectionName, key))
|
||||||
return Get(sectionName, key, value);
|
return Get(sectionName, key, value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetKeys(const char* sectionName, std::vector<std::string>& keys) const;
|
bool GetKeys(const std::string& sectionName, std::vector<std::string>& keys) const;
|
||||||
|
|
||||||
void SetLines(const char* sectionName, const std::vector<std::string> &lines);
|
void SetLines(const std::string& sectionName, const std::vector<std::string> &lines);
|
||||||
bool GetLines(const char* sectionName, std::vector<std::string>& lines, const bool remove_comments = true) const;
|
bool GetLines(const std::string& sectionName, std::vector<std::string>& lines, const bool remove_comments = true) const;
|
||||||
|
|
||||||
inline bool DeleteKey(const char* sectionName, const std::string& key)
|
bool DeleteKey(const std::string& sectionName, const std::string& key);
|
||||||
{
|
bool DeleteSection(const std::string& sectionName);
|
||||||
return DeleteKey(sectionName, key.c_str());
|
|
||||||
}
|
|
||||||
bool DeleteKey(const char* sectionName, const char* key);
|
|
||||||
bool DeleteSection(const char* sectionName);
|
|
||||||
|
|
||||||
void SortSections();
|
void SortSections();
|
||||||
|
|
||||||
Section* GetOrCreateSection(const char* section);
|
Section* GetOrCreateSection(const std::string& section);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Section> sections;
|
std::vector<Section> sections;
|
||||||
|
|
||||||
const Section* GetSection(const char* section) const;
|
const Section* GetSection(const std::string& section) const;
|
||||||
Section* GetSection(const char* section);
|
Section* GetSection(const std::string& section);
|
||||||
std::string* GetLine(const char* section, const char* key);
|
std::string* GetLine(const std::string& section, const std::string& key);
|
||||||
void CreateSection(const char* section);
|
void CreateSection(const std::string& section);
|
||||||
|
|
||||||
|
static const std::string& NULL_STRING;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _INIFILE_H_
|
#endif // _INIFILE_H_
|
||||||
|
|
|
@ -28,7 +28,7 @@ const u8* SettingsHandler::GetData() const
|
||||||
return m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string SettingsHandler::GetValue(const std::string key)
|
const std::string SettingsHandler::GetValue(const std::string& key)
|
||||||
{
|
{
|
||||||
std::string delim = std::string("\r\n");
|
std::string delim = std::string("\r\n");
|
||||||
std::string toFind = delim + key + "=";
|
std::string toFind = delim + key + "=";
|
||||||
|
@ -79,20 +79,16 @@ void SettingsHandler::Reset()
|
||||||
memset(m_buffer, 0, SETTINGS_SIZE);
|
memset(m_buffer, 0, SETTINGS_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsHandler::AddSetting(const char *key, const char *value)
|
void SettingsHandler::AddSetting(const std::string& key, const std::string& value)
|
||||||
{
|
{
|
||||||
while (*key != 0)
|
for(const char& c : key) {
|
||||||
{
|
WriteByte(c);
|
||||||
WriteByte(*key);
|
|
||||||
key++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteByte('=');
|
WriteByte('=');
|
||||||
|
|
||||||
while (*value != 0)
|
for(const char& c : value) {
|
||||||
{
|
WriteByte(c);
|
||||||
WriteByte(*value);
|
|
||||||
value++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteByte(13);
|
WriteByte(13);
|
||||||
|
|
|
@ -22,14 +22,10 @@ public:
|
||||||
INITIAL_SEED = 0x73B5DBFA
|
INITIAL_SEED = 0x73B5DBFA
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void AddSetting(const char *key, const std::string& value)
|
void AddSetting(const std::string& key, const std::string& value);
|
||||||
{
|
|
||||||
AddSetting(key, value.c_str());
|
|
||||||
}
|
|
||||||
void AddSetting(const char *key, const char *value);
|
|
||||||
|
|
||||||
const u8 *GetData() const;
|
const u8 *GetData() const;
|
||||||
const std::string GetValue(const std::string key);
|
const std::string GetValue(const std::string& key);
|
||||||
|
|
||||||
void Decrypt();
|
void Decrypt();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
|
@ -246,7 +246,7 @@ void LogInfo(const char *format, ...)
|
||||||
{
|
{
|
||||||
std::string text = temp;
|
std::string text = temp;
|
||||||
text += '\n';
|
text += '\n';
|
||||||
arLog.push_back(text.c_str());
|
arLog.push_back(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ bool BootCore(const std::string& _rFilename)
|
||||||
game_ini.Get("Core", "BlockMerging", &StartUp.bMergeBlocks, StartUp.bMergeBlocks);
|
game_ini.Get("Core", "BlockMerging", &StartUp.bMergeBlocks, StartUp.bMergeBlocks);
|
||||||
game_ini.Get("Core", "DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
|
game_ini.Get("Core", "DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
|
||||||
game_ini.Get("Core", "DSPThread", &StartUp.bDSPThread, StartUp.bDSPThread);
|
game_ini.Get("Core", "DSPThread", &StartUp.bDSPThread, StartUp.bDSPThread);
|
||||||
game_ini.Get("Core", "GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend.c_str());
|
game_ini.Get("Core", "GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend);
|
||||||
game_ini.Get("Core", "CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore);
|
game_ini.Get("Core", "CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore);
|
||||||
game_ini.Get("Core", "HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
|
game_ini.Get("Core", "HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
|
||||||
if (game_ini.Get("Core", "FrameLimit", &SConfig::GetInstance().m_Framelimit, SConfig::GetInstance().m_Framelimit))
|
if (game_ini.Get("Core", "FrameLimit", &SConfig::GetInstance().m_Framelimit, SConfig::GetInstance().m_Framelimit))
|
||||||
|
@ -155,13 +155,13 @@ bool BootCore(const std::string& _rFilename)
|
||||||
if (game_ini.Get("DSP", "Volume", &SConfig::GetInstance().m_Volume, SConfig::GetInstance().m_Volume))
|
if (game_ini.Get("DSP", "Volume", &SConfig::GetInstance().m_Volume, SConfig::GetInstance().m_Volume))
|
||||||
config_cache.bSetVolume = true;
|
config_cache.bSetVolume = true;
|
||||||
game_ini.Get("DSP", "EnableJIT", &SConfig::GetInstance().m_EnableJIT, SConfig::GetInstance().m_EnableJIT);
|
game_ini.Get("DSP", "EnableJIT", &SConfig::GetInstance().m_EnableJIT, SConfig::GetInstance().m_EnableJIT);
|
||||||
game_ini.Get("DSP", "Backend", &SConfig::GetInstance().sBackend, SConfig::GetInstance().sBackend.c_str());
|
game_ini.Get("DSP", "Backend", &SConfig::GetInstance().sBackend, SConfig::GetInstance().sBackend);
|
||||||
VideoBackend::ActivateBackend(StartUp.m_strVideoBackend);
|
VideoBackend::ActivateBackend(StartUp.m_strVideoBackend);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAX_SI_CHANNELS; ++i)
|
for (unsigned int i = 0; i < MAX_SI_CHANNELS; ++i)
|
||||||
{
|
{
|
||||||
int source;
|
int source;
|
||||||
game_ini.Get("Controls", StringFromFormat("PadType%u", i).c_str(), &source, -1);
|
game_ini.Get("Controls", StringFromFormat("PadType%u", i), &source, -1);
|
||||||
if (source >= (int) SIDEVICE_NONE && source <= (int) SIDEVICE_AM_BASEBOARD)
|
if (source >= (int) SIDEVICE_NONE && source <= (int) SIDEVICE_AM_BASEBOARD)
|
||||||
{
|
{
|
||||||
SConfig::GetInstance().m_SIDevice[i] = (SIDevices) source;
|
SConfig::GetInstance().m_SIDevice[i] = (SIDevices) source;
|
||||||
|
@ -178,7 +178,7 @@ bool BootCore(const std::string& _rFilename)
|
||||||
int source;
|
int source;
|
||||||
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
||||||
{
|
{
|
||||||
game_ini.Get("Controls", StringFromFormat("WiimoteSource%u", i).c_str(), &source, -1);
|
game_ini.Get("Controls", StringFromFormat("WiimoteSource%u", i), &source, -1);
|
||||||
if (source != -1 && g_wiimote_sources[i] != (unsigned) source && source >= WIIMOTE_SRC_NONE && source <= WIIMOTE_SRC_HYBRID)
|
if (source != -1 && g_wiimote_sources[i] != (unsigned) source && source >= WIIMOTE_SRC_NONE && source <= WIIMOTE_SRC_HYBRID)
|
||||||
{
|
{
|
||||||
config_cache.bSetWiimoteSource[i] = true;
|
config_cache.bSetWiimoteSource[i] = true;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
#include "NANDContentLoader.h"
|
#include "NANDContentLoader.h"
|
||||||
|
#include "HW/SI.h"
|
||||||
|
|
||||||
SConfig* SConfig::m_Instance;
|
SConfig* SConfig::m_Instance;
|
||||||
|
|
||||||
|
@ -158,7 +159,7 @@ void SConfig::SaveSettings()
|
||||||
|
|
||||||
for (int i = 0; i < numPaths; i++)
|
for (int i = 0; i < numPaths; i++)
|
||||||
{
|
{
|
||||||
ini.Set("General", StringFromFormat("GCMPath%i", i).c_str(), m_ISOFolder[i]);
|
ini.Set("General", StringFromFormat("GCMPath%i", i), m_ISOFolder[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ini.Set("General", "RecursiveGCMPaths", m_RecursiveISOFolder);
|
ini.Set("General", "RecursiveGCMPaths", m_RecursiveISOFolder);
|
||||||
|
@ -190,7 +191,7 @@ void SConfig::SaveSettings()
|
||||||
for (int i = 0; i < NUM_HOTKEYS; i++)
|
for (int i = 0; i < NUM_HOTKEYS; i++)
|
||||||
{
|
{
|
||||||
ini.Set("Hotkeys", g_HKData[i].IniText, m_LocalCoreStartupParameter.iHotkey[i]);
|
ini.Set("Hotkeys", g_HKData[i].IniText, m_LocalCoreStartupParameter.iHotkey[i]);
|
||||||
ini.Set("Hotkeys", (std::string(g_HKData[i].IniText) + "Modifier").c_str(),
|
ini.Set("Hotkeys", std::string(g_HKData[i].IniText) + "Modifier",
|
||||||
m_LocalCoreStartupParameter.iHotkeyModifier[i]);
|
m_LocalCoreStartupParameter.iHotkeyModifier[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,9 +246,9 @@ void SConfig::SaveSettings()
|
||||||
ini.Set("Core", "SlotB", m_EXIDevice[1]);
|
ini.Set("Core", "SlotB", m_EXIDevice[1]);
|
||||||
ini.Set("Core", "SerialPort1", m_EXIDevice[2]);
|
ini.Set("Core", "SerialPort1", m_EXIDevice[2]);
|
||||||
ini.Set("Core", "BBA_MAC", m_bba_mac);
|
ini.Set("Core", "BBA_MAC", m_bba_mac);
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < MAX_SI_CHANNELS; ++i)
|
||||||
{
|
{
|
||||||
ini.Set("Core", StringFromFormat("SIDevice%i", i).c_str(), m_SIDevice[i]);
|
ini.Set("Core", StringFromFormat("SIDevice%i", i), m_SIDevice[i]);
|
||||||
}
|
}
|
||||||
ini.Set("Core", "WiiSDCard", m_WiiSDCard);
|
ini.Set("Core", "WiiSDCard", m_WiiSDCard);
|
||||||
ini.Set("Core", "WiiKeyboard", m_WiiKeyboard);
|
ini.Set("Core", "WiiKeyboard", m_WiiKeyboard);
|
||||||
|
@ -301,7 +302,7 @@ void SConfig::LoadSettings()
|
||||||
for (int i = 0; i < numGCMPaths; i++)
|
for (int i = 0; i < numGCMPaths; i++)
|
||||||
{
|
{
|
||||||
std::string tmpPath;
|
std::string tmpPath;
|
||||||
ini.Get("General", StringFromFormat("GCMPath%i", i).c_str(), &tmpPath, "");
|
ini.Get("General", StringFromFormat("GCMPath%i", i), &tmpPath, "");
|
||||||
m_ISOFolder.push_back(std::move(tmpPath));
|
m_ISOFolder.push_back(std::move(tmpPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,7 +340,7 @@ void SConfig::LoadSettings()
|
||||||
{
|
{
|
||||||
ini.Get("Hotkeys", g_HKData[i].IniText,
|
ini.Get("Hotkeys", g_HKData[i].IniText,
|
||||||
&m_LocalCoreStartupParameter.iHotkey[i], g_HKData[i].DefaultKey);
|
&m_LocalCoreStartupParameter.iHotkey[i], g_HKData[i].DefaultKey);
|
||||||
ini.Get("Hotkeys", (std::string(g_HKData[i].IniText) + "Modifier").c_str(),
|
ini.Get("Hotkeys", std::string(g_HKData[i].IniText) + "Modifier",
|
||||||
&m_LocalCoreStartupParameter.iHotkeyModifier[i], g_HKData[i].DefaultModifier);
|
&m_LocalCoreStartupParameter.iHotkeyModifier[i], g_HKData[i].DefaultModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,9 +402,9 @@ void SConfig::LoadSettings()
|
||||||
ini.Get("Core", "BBA_MAC", &m_bba_mac);
|
ini.Get("Core", "BBA_MAC", &m_bba_mac);
|
||||||
ini.Get("Core", "TimeProfiling",&m_LocalCoreStartupParameter.bJITILTimeProfiling, false);
|
ini.Get("Core", "TimeProfiling",&m_LocalCoreStartupParameter.bJITILTimeProfiling, false);
|
||||||
ini.Get("Core", "OutputIR", &m_LocalCoreStartupParameter.bJITILOutputIR, false);
|
ini.Get("Core", "OutputIR", &m_LocalCoreStartupParameter.bJITILOutputIR, false);
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < MAX_SI_CHANNELS; ++i)
|
||||||
{
|
{
|
||||||
ini.Get("Core", StringFromFormat("SIDevice%i", i).c_str(), (u32*)&m_SIDevice[i], (i == 0) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE);
|
ini.Get("Core", StringFromFormat("SIDevice%i", i), (u32*)&m_SIDevice[i], (i == 0) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE);
|
||||||
}
|
}
|
||||||
ini.Get("Core", "WiiSDCard", &m_WiiSDCard, false);
|
ini.Get("Core", "WiiSDCard", &m_WiiSDCard, false);
|
||||||
ini.Get("Core", "WiiKeyboard", &m_WiiKeyboard, false);
|
ini.Get("Core", "WiiKeyboard", &m_WiiKeyboard, false);
|
||||||
|
|
|
@ -134,7 +134,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
|
||||||
bootDrive)
|
bootDrive)
|
||||||
{
|
{
|
||||||
m_BootType = BOOT_ISO;
|
m_BootType = BOOT_ISO;
|
||||||
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str());
|
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename);
|
||||||
if (pVolume == NULL)
|
if (pVolume == NULL)
|
||||||
{
|
{
|
||||||
if (bootDrive)
|
if (bootDrive)
|
||||||
|
@ -210,7 +210,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
|
||||||
bNTSC = true;
|
bNTSC = true;
|
||||||
m_BootType = BOOT_DFF;
|
m_BootType = BOOT_DFF;
|
||||||
|
|
||||||
FifoDataFile *ddfFile = FifoDataFile::Load(m_strFilename.c_str(), true);
|
FifoDataFile *ddfFile = FifoDataFile::Load(m_strFilename, true);
|
||||||
|
|
||||||
if (ddfFile)
|
if (ddfFile)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
|
||||||
}
|
}
|
||||||
else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid())
|
else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid())
|
||||||
{
|
{
|
||||||
const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str());
|
const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename);
|
||||||
const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);
|
const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);
|
||||||
|
|
||||||
if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == NULL)
|
if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == NULL)
|
||||||
|
|
|
@ -565,13 +565,13 @@ void LoadSettings()
|
||||||
{
|
{
|
||||||
std::string secname("Wiimote");
|
std::string secname("Wiimote");
|
||||||
secname += (char)('1' + i);
|
secname += (char)('1' + i);
|
||||||
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
|
IniFile::Section& sec = *inifile.GetOrCreateSection(secname);
|
||||||
|
|
||||||
sec.Get("Source", &g_wiimote_sources[i], i ? WIIMOTE_SRC_NONE : WIIMOTE_SRC_EMU);
|
sec.Get("Source", &g_wiimote_sources[i], i ? WIIMOTE_SRC_NONE : WIIMOTE_SRC_EMU);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string secname("BalanceBoard");
|
std::string secname("BalanceBoard");
|
||||||
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
|
IniFile::Section& sec = *inifile.GetOrCreateSection(secname);
|
||||||
sec.Get("Source", &g_wiimote_sources[WIIMOTE_BALANCE_BOARD], WIIMOTE_SRC_NONE);
|
sec.Get("Source", &g_wiimote_sources[WIIMOTE_BALANCE_BOARD], WIIMOTE_SRC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches,
|
||||||
std::string enabledSectionName = std::string(section) + "_Enabled";
|
std::string enabledSectionName = std::string(section) + "_Enabled";
|
||||||
std::vector<std::string> enabledLines;
|
std::vector<std::string> enabledLines;
|
||||||
std::set<std::string> enabledNames;
|
std::set<std::string> enabledNames;
|
||||||
localIni.GetLines(enabledSectionName.c_str(), enabledLines);
|
localIni.GetLines(enabledSectionName, enabledLines);
|
||||||
for (auto& line : enabledLines)
|
for (auto& line : enabledLines)
|
||||||
{
|
{
|
||||||
if (line.size() != 0 && line[0] == '$')
|
if (line.size() != 0 && line[0] == '$')
|
||||||
|
@ -140,7 +140,7 @@ static void LoadSpeedhacks(const char *section, std::map<u32, int> &hacks, IniFi
|
||||||
{
|
{
|
||||||
std::string key = *iter;
|
std::string key = *iter;
|
||||||
std::string value;
|
std::string value;
|
||||||
ini.Get(section, key.c_str(), &value, "BOGUS");
|
ini.Get(section, key, &value, "BOGUS");
|
||||||
if (value != "BOGUS")
|
if (value != "BOGUS")
|
||||||
{
|
{
|
||||||
u32 address;
|
u32 address;
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace ButtonManager
|
||||||
bool hasbind = false;
|
bool hasbind = false;
|
||||||
char modifier = 0;
|
char modifier = 0;
|
||||||
std::string value;
|
std::string value;
|
||||||
ini.Get("Android", config.str().c_str(), &value, "None");
|
ini.Get("Android", config.str(), &value, "None");
|
||||||
if (value == "None")
|
if (value == "None")
|
||||||
continue;
|
continue;
|
||||||
if (std::string::npos != value.find("Axis"))
|
if (std::string::npos != value.find("Axis"))
|
||||||
|
|
|
@ -82,7 +82,7 @@ void CCodeWindow::Load()
|
||||||
? Parent->Perspectives[Parent->ActivePerspective].Name : "Perspective 1");
|
? Parent->Perspectives[Parent->ActivePerspective].Name : "Perspective 1");
|
||||||
|
|
||||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||||
ini.Get(_Section.c_str(), SettingName[i], &iNbAffiliation[i], 0);
|
ini.Get(_Section, SettingName[i], &iNbAffiliation[i], 0);
|
||||||
|
|
||||||
// Get floating setting
|
// Get floating setting
|
||||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||||
|
@ -121,7 +121,7 @@ void CCodeWindow::Save()
|
||||||
// Save notebook affiliations
|
// Save notebook affiliations
|
||||||
std::string _Section = "P - " + Parent->Perspectives[Parent->ActivePerspective].Name;
|
std::string _Section = "P - " + Parent->Perspectives[Parent->ActivePerspective].Name;
|
||||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||||
ini.Set(_Section.c_str(), SettingName[i], iNbAffiliation[i]);
|
ini.Set(_Section, SettingName[i], iNbAffiliation[i]);
|
||||||
|
|
||||||
// Save floating setting
|
// Save floating setting
|
||||||
for (int i = IDM_LOGWINDOW_PARENT; i <= IDM_CODEWINDOW_PARENT; i++)
|
for (int i = IDM_LOGWINDOW_PARENT; i <= IDM_CODEWINDOW_PARENT; i++)
|
||||||
|
|
|
@ -917,13 +917,13 @@ void CFrame::LoadIniPerspectives()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
|
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
|
||||||
ini.Get(_Section.c_str(), "Perspective", &_Perspective,
|
ini.Get(_Section, "Perspective", &_Perspective,
|
||||||
"layout2|"
|
"layout2|"
|
||||||
"name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|"
|
"name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|"
|
||||||
"name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|"
|
"name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|"
|
||||||
"dock_size(5,0,0)=22|dock_size(4,0,0)=333|");
|
"dock_size(5,0,0)=22|dock_size(4,0,0)=333|");
|
||||||
ini.Get(_Section.c_str(), "Width", &_Widths, "70,25");
|
ini.Get(_Section, "Width", &_Widths, "70,25");
|
||||||
ini.Get(_Section.c_str(), "Height", &_Heights, "80,80");
|
ini.Get(_Section, "Height", &_Heights, "80,80");
|
||||||
|
|
||||||
Tmp.Perspective = StrToWxStr(_Perspective);
|
Tmp.Perspective = StrToWxStr(_Perspective);
|
||||||
|
|
||||||
|
@ -988,14 +988,14 @@ void CFrame::SaveIniPerspectives()
|
||||||
STmp += Perspective.Name + ",";
|
STmp += Perspective.Name + ",";
|
||||||
}
|
}
|
||||||
STmp = STmp.substr(0, STmp.length()-1);
|
STmp = STmp.substr(0, STmp.length()-1);
|
||||||
ini.Set("Perspectives", "Perspectives", STmp.c_str());
|
ini.Set("Perspectives", "Perspectives", STmp);
|
||||||
ini.Set("Perspectives", "Active", ActivePerspective);
|
ini.Set("Perspectives", "Active", ActivePerspective);
|
||||||
|
|
||||||
// Save the perspectives
|
// Save the perspectives
|
||||||
for (auto& Perspective : Perspectives)
|
for (auto& Perspective : Perspectives)
|
||||||
{
|
{
|
||||||
std::string _Section = "P - " + Perspective.Name;
|
std::string _Section = "P - " + Perspective.Name;
|
||||||
ini.Set(_Section.c_str(), "Perspective", WxStrToStr(Perspective.Perspective));
|
ini.Set(_Section, "Perspective", WxStrToStr(Perspective.Perspective));
|
||||||
|
|
||||||
std::string SWidth = "", SHeight = "";
|
std::string SWidth = "", SHeight = "";
|
||||||
for (u32 j = 0; j < Perspective.Width.size(); j++)
|
for (u32 j = 0; j < Perspective.Width.size(); j++)
|
||||||
|
@ -1007,8 +1007,8 @@ void CFrame::SaveIniPerspectives()
|
||||||
SWidth = SWidth.substr(0, SWidth.length()-1);
|
SWidth = SWidth.substr(0, SWidth.length()-1);
|
||||||
SHeight = SHeight.substr(0, SHeight.length()-1);
|
SHeight = SHeight.substr(0, SHeight.length()-1);
|
||||||
|
|
||||||
ini.Set(_Section.c_str(), "Width", SWidth.c_str());
|
ini.Set(_Section, "Width", SWidth);
|
||||||
ini.Set(_Section.c_str(), "Height", SHeight.c_str());
|
ini.Set(_Section, "Height", SHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||||
|
|
|
@ -252,13 +252,13 @@ void WiimoteConfigDiag::Save(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
std::string secname("Wiimote");
|
std::string secname("Wiimote");
|
||||||
secname += (char)('1' + i);
|
secname += (char)('1' + i);
|
||||||
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
|
IniFile::Section& sec = *inifile.GetOrCreateSection(secname);
|
||||||
|
|
||||||
sec.Set("Source", (int)g_wiimote_sources[i]);
|
sec.Set("Source", (int)g_wiimote_sources[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string secname("BalanceBoard");
|
std::string secname("BalanceBoard");
|
||||||
IniFile::Section& sec = *inifile.GetOrCreateSection(secname.c_str());
|
IniFile::Section& sec = *inifile.GetOrCreateSection(secname);
|
||||||
sec.Set("Source", (int)g_wiimote_sources[WIIMOTE_BALANCE_BOARD]);
|
sec.Set("Source", (int)g_wiimote_sources[WIIMOTE_BALANCE_BOARD]);
|
||||||
|
|
||||||
inifile.Save(ini_filename);
|
inifile.Save(ini_filename);
|
||||||
|
|
|
@ -47,17 +47,17 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
|
||||||
// settings
|
// settings
|
||||||
for (auto& s : settings)
|
for (auto& s : settings)
|
||||||
{
|
{
|
||||||
sec->Get((group + s->name).c_str(), &s->value, s->default_value * 100);
|
sec->Get(group + s->name, &s->value, s->default_value * 100);
|
||||||
s->value /= 100;
|
s->value /= 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : controls)
|
for (auto& c : controls)
|
||||||
{
|
{
|
||||||
// control expression
|
// control expression
|
||||||
sec->Get((group + c->name).c_str(), &c->control_ref->expression, "");
|
sec->Get(group + c->name, &c->control_ref->expression, "");
|
||||||
|
|
||||||
// range
|
// range
|
||||||
sec->Get((group + c->name + "/Range").c_str(), &c->control_ref->range, 100.0f);
|
sec->Get(group + c->name + "/Range", &c->control_ref->range, 100.0f);
|
||||||
c->control_ref->range /= 100;
|
c->control_ref->range /= 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,12 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
|
||||||
// extensions
|
// extensions
|
||||||
if (type == GROUP_TYPE_EXTENSION)
|
if (type == GROUP_TYPE_EXTENSION)
|
||||||
{
|
{
|
||||||
Extension* const ext = ((Extension*)this);
|
Extension* const ext = (Extension*)this;
|
||||||
|
|
||||||
ext->switch_extension = 0;
|
ext->switch_extension = 0;
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
std::string extname;
|
std::string extname;
|
||||||
sec->Get((base + name).c_str(), &extname, "");
|
sec->Get(base + name, &extname, "");
|
||||||
|
|
||||||
for (auto& ai : ext->attachments)
|
for (auto& ai : ext->attachments)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ void ControllerEmu::LoadConfig(IniFile::Section *sec, const std::string& base)
|
||||||
std::string defdev = default_device.ToString();
|
std::string defdev = default_device.ToString();
|
||||||
if (base.empty())
|
if (base.empty())
|
||||||
{
|
{
|
||||||
sec->Get((base + "Device").c_str(), &defdev, "");
|
sec->Get(base + "Device", &defdev, "");
|
||||||
default_device.FromString(defdev);
|
default_device.FromString(defdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,22 +103,22 @@ void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::s
|
||||||
std::string group(base + name); group += "/";
|
std::string group(base + name); group += "/";
|
||||||
|
|
||||||
for (auto& s : settings)
|
for (auto& s : settings)
|
||||||
sec->Set((group + s->name).c_str(), s->value*100.0f, s->default_value*100.0f);
|
sec->Set(group + s->name, s->value*100.0f, s->default_value*100.0f);
|
||||||
|
|
||||||
for (auto& c : controls)
|
for (auto& c : controls)
|
||||||
{
|
{
|
||||||
// control expression
|
// control expression
|
||||||
sec->Set((group + c->name).c_str(), c->control_ref->expression, "");
|
sec->Set(group + c->name, c->control_ref->expression, "");
|
||||||
|
|
||||||
// range
|
// range
|
||||||
sec->Set((group + c->name + "/Range").c_str(), c->control_ref->range*100.0f, 100.0f);
|
sec->Set(group + c->name + "/Range", c->control_ref->range*100.0f, 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// extensions
|
// extensions
|
||||||
if (type == GROUP_TYPE_EXTENSION)
|
if (type == GROUP_TYPE_EXTENSION)
|
||||||
{
|
{
|
||||||
Extension* const ext = ((Extension*)this);
|
Extension* const ext = (Extension*)this;
|
||||||
sec->Set((base + name).c_str(), ext->attachments[ext->switch_extension]->GetName(), "None");
|
sec->Set(base + name, ext->attachments[ext->switch_extension]->GetName(), "None");
|
||||||
|
|
||||||
for (auto& ai : ext->attachments)
|
for (auto& ai : ext->attachments)
|
||||||
ai->SaveConfig(sec, base + ai->GetName() + "/");
|
ai->SaveConfig(sec, base + ai->GetName() + "/");
|
||||||
|
@ -129,7 +129,7 @@ void ControllerEmu::SaveConfig(IniFile::Section *sec, const std::string& base)
|
||||||
{
|
{
|
||||||
const std::string defdev = default_device.ToString();
|
const std::string defdev = default_device.ToString();
|
||||||
if (base.empty())
|
if (base.empty())
|
||||||
sec->Set((/*std::string(" ") +*/ base + "Device").c_str(), defdev, "");
|
sec->Set(/*std::string(" ") +*/ base + "Device", defdev, "");
|
||||||
|
|
||||||
for (auto& ctrlGroup : groups)
|
for (auto& ctrlGroup : groups)
|
||||||
ctrlGroup->SaveConfig(sec, defdev, base);
|
ctrlGroup->SaveConfig(sec, defdev, base);
|
||||||
|
|
|
@ -40,9 +40,10 @@ bool InputPlugin::LoadConfig(bool isGC)
|
||||||
game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini", true);
|
game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini", true);
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (game_ini.Exists("Controls", (type + "Profile" + num[i]).c_str()))
|
if (game_ini.Exists("Controls", type + "Profile" + num[i]))
|
||||||
|
{
|
||||||
|
if (game_ini.Get("Controls", type + "Profile" + num[i], &profile[i]))
|
||||||
{
|
{
|
||||||
game_ini.Get("Controls", (type + "Profile" + num[i]).c_str(), &profile[i]);
|
|
||||||
if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + path + profile[i] + ".ini"))
|
if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + path + profile[i] + ".ini"))
|
||||||
useProfile[i] = true;
|
useProfile[i] = true;
|
||||||
else
|
else
|
||||||
|
@ -53,6 +54,7 @@ bool InputPlugin::LoadConfig(bool isGC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini"))
|
if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini"))
|
||||||
{
|
{
|
||||||
|
@ -68,7 +70,7 @@ bool InputPlugin::LoadConfig(bool isGC)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pad->LoadConfig(inifile.GetOrCreateSection(pad->GetName().c_str()));
|
pad->LoadConfig(inifile.GetOrCreateSection(pad->GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update refs
|
// Update refs
|
||||||
|
@ -95,7 +97,7 @@ void InputPlugin::SaveConfig()
|
||||||
inifile.Load(ini_filename);
|
inifile.Load(ini_filename);
|
||||||
|
|
||||||
for (ControllerEmu* pad : controllers)
|
for (ControllerEmu* pad : controllers)
|
||||||
pad->SaveConfig(inifile.GetOrCreateSection(pad->GetName().c_str()));
|
pad->SaveConfig(inifile.GetOrCreateSection(pad->GetName()));
|
||||||
|
|
||||||
inifile.Save(ini_filename);
|
inifile.Save(ini_filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
const char* DefaultPort(const int index)
|
const std::string DefaultPort(const int index)
|
||||||
{
|
{
|
||||||
static std::string s;
|
static std::string s;
|
||||||
s = "443";
|
s = "443";
|
||||||
s += (char)('2' + index);
|
s += (char)('2' + index);
|
||||||
return s.c_str();
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPWrapper::UDPWrapper(int indx, const char* const _name) :
|
UDPWrapper::UDPWrapper(int indx, const char* const _name) :
|
||||||
|
@ -29,13 +29,13 @@ void UDPWrapper::LoadConfig(IniFile::Section *sec, const std::string& defdev, co
|
||||||
std::string group( base + name ); group += "/";
|
std::string group( base + name ); group += "/";
|
||||||
|
|
||||||
int _updAccel,_updIR,_updButt,_udpEn,_updNun,_updNunAccel;
|
int _updAccel,_updIR,_updButt,_udpEn,_updNun,_updNunAccel;
|
||||||
sec->Get((group + "Enable").c_str(),&_udpEn, 0);
|
sec->Get(group + "Enable",&_udpEn, 0);
|
||||||
sec->Get((group + "Port").c_str(), &port, DefaultPort(index));
|
sec->Get(group + "Port", &port, DefaultPort(index));
|
||||||
sec->Get((group + "Update_Accel").c_str(), &_updAccel, 1);
|
sec->Get(group + "Update_Accel", &_updAccel, 1);
|
||||||
sec->Get((group + "Update_IR").c_str(), &_updIR, 1);
|
sec->Get(group + "Update_IR", &_updIR, 1);
|
||||||
sec->Get((group + "Update_Butt").c_str(), &_updButt, 1);
|
sec->Get(group + "Update_Butt", &_updButt, 1);
|
||||||
sec->Get((group + "Update_Nunchuk").c_str(), &_updNun, 1);
|
sec->Get(group + "Update_Nunchuk", &_updNun, 1);
|
||||||
sec->Get((group + "Update_NunchukAccel").c_str(), &_updNunAccel, 0);
|
sec->Get(group + "Update_NunchukAccel", &_updNunAccel, 0);
|
||||||
|
|
||||||
udpEn=(_udpEn>0);
|
udpEn=(_udpEn>0);
|
||||||
updAccel=(_updAccel>0);
|
updAccel=(_updAccel>0);
|
||||||
|
@ -52,13 +52,13 @@ void UDPWrapper::SaveConfig(IniFile::Section *sec, const std::string& defdev, co
|
||||||
{
|
{
|
||||||
ControlGroup::SaveConfig(sec,defdev,base);
|
ControlGroup::SaveConfig(sec,defdev,base);
|
||||||
std::string group( base + name ); group += "/";
|
std::string group( base + name ); group += "/";
|
||||||
sec->Set((group + "Enable").c_str(), (int)udpEn, 0);
|
sec->Set(group + "Enable", (int)udpEn, 0);
|
||||||
sec->Set((group + "Port").c_str(), port, DefaultPort(index));
|
sec->Set(group + "Port", port, DefaultPort(index));
|
||||||
sec->Set((group + "Update_Accel").c_str(), (int)updAccel, 1);
|
sec->Set(group + "Update_Accel", (int)updAccel, 1);
|
||||||
sec->Set((group + "Update_IR").c_str(), (int)updIR, 1);
|
sec->Set(group + "Update_IR", (int)updIR, 1);
|
||||||
sec->Set((group + "Update_Butt").c_str(), (int)updButt, 1);
|
sec->Set(group + "Update_Butt", (int)updButt, 1);
|
||||||
sec->Set((group + "Update_Nunchuk").c_str(), (int)updNun, 1);
|
sec->Set(group + "Update_Nunchuk", (int)updNun, 1);
|
||||||
sec->Set((group + "Update_NunchukAccel").c_str(), (int)updNunAccel, 0);
|
sec->Set(group + "Update_NunchukAccel", (int)updNunAccel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue