summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/IniFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Src/IniFile.cpp')
-rw-r--r--Source/Core/Common/Src/IniFile.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/Source/Core/Common/Src/IniFile.cpp b/Source/Core/Common/Src/IniFile.cpp
index b9e46feb28..244d06a161 100644
--- a/Source/Core/Common/Src/IniFile.cpp
+++ b/Source/Core/Common/Src/IniFile.cpp
@@ -60,21 +60,6 @@ static void ParseLine(const std::string& line, std::string* keyOut, std::string*
}
-IniFile::Section::Section()
- : lines(), name(""), comment("") {}
-
-
-IniFile::Section::Section(const std::string& _name)
- : lines(), name(_name), comment("") {}
-
-
-IniFile::Section::Section(const Section& other)
-{
- name = other.name;
- comment = other.comment;
- lines = other.lines;
-}
-
std::string* IniFile::Section::GetLine(const char* key, std::string* valueOut, std::string* commentOut)
{
for (std::vector<std::string>::iterator iter = lines.begin(); iter != lines.end(); ++iter)
@@ -104,6 +89,14 @@ 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)
+{
+ if (newValue != defaultValue)
+ Set(key, newValue);
+ else
+ Delete(key);
+}
+
bool IniFile::Section::Get(const char* key, std::string* value, const char* defaultValue)
{
std::string* line = GetLine(key, value, 0);
@@ -118,6 +111,14 @@ bool IniFile::Section::Get(const char* key, std::string* value, const char* defa
return true;
}
+void IniFile::Section::Set(const char* key, const float newValue, const float defaultValue)
+{
+ if (newValue != defaultValue)
+ Set(key, newValue);
+ else
+ Delete(key);
+}
+
void IniFile::Section::Set(const char* key, const std::vector<std::string>& newValues)
{
std::string temp;
@@ -222,12 +223,22 @@ bool IniFile::Section::Exists(const char *key) const
return false;
}
+bool IniFile::Section::Delete(const char *key)
+{
+ std::string* line = GetLine(key, 0, 0);
+ for (std::vector<std::string>::iterator liter = lines.begin(); liter != lines.end(); ++liter)
+ {
+ if (line == &*liter)
+ {
+ lines.erase(liter);
+ return true;
+ }
+ }
+ return false;
+}
// IniFile
-IniFile::IniFile() {}
-IniFile::~IniFile() {}
-
const IniFile::Section* IniFile::GetSection(const char* sectionName) const
{
for (std::vector<Section>::const_iterator iter = sections.begin(); iter != sections.end(); ++iter)