diff options
| author | nakeee <nakeee@gmail.com> | 2009-02-25 10:33:09 +0000 |
|---|---|---|
| committer | nakeee <nakeee@gmail.com> | 2009-02-25 10:33:09 +0000 |
| commit | bec2a115d80f0086da8b6868ea0482b2fa7a3d68 (patch) | |
| tree | 78aabd4ada9ad89c0d6c32fced4e3e5869af352e /Source/Core/Common/Src/IniFile.cpp | |
| parent | 04e54f92d20bdcbd6b09a8ff8b9203377f4a80b7 (diff) | |
Added set and get in ini for comma seperated list
Also merged the StripSpaces with StripNewline and
cleaned it up a bit.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2433 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/IniFile.cpp')
| -rw-r--r-- | Source/Core/Common/Src/IniFile.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/IniFile.cpp b/Source/Core/Common/Src/IniFile.cpp index 09a3aca415..1d4b112a5d 100644 --- a/Source/Core/Common/Src/IniFile.cpp +++ b/Source/Core/Common/Src/IniFile.cpp @@ -385,6 +385,22 @@ void IniFile::Set(const char* sectionName, const char* key, const char* newValue } } +void IniFile::Set(const char* sectionName, const char* key, const std::vector<std::string>& newValues) +{ + std::string temp; + + // Join the strings with , + std::vector<std::string>::const_iterator it; + for (it = newValues.begin(); it != newValues.end(); ++it) { + + temp = (*it) + ","; + } + + // remove last , + temp.resize(temp.length() - 1); + + Set(sectionName, key, temp.c_str()); +} void IniFile::Set(const char* sectionName, const char* key, u32 newValue) { @@ -433,6 +449,37 @@ bool IniFile::Get(const char* sectionName, const char* key, std::string* value, } +bool IniFile::Get(const char* sectionName, const char* key, std::vector<std::string>& values) +{ + + std::string temp; + bool retval = Get(sectionName, key, &temp, 0); + + if (! retval || temp.empty()) { + return false; + } + + u32 subEnd; + + // ignore starting , if any + u32 subStart = temp.find_first_not_of(","); + + // split by , + while (subStart != std::string::npos) { + + // Find next , + subEnd = temp.find_first_of(",", subStart); + if (subStart != subEnd) + // take from first char until next , + values.push_back(StripSpaces(temp.substr(subStart, subEnd - subStart))); + + // Find the next non , char + subStart = temp.find_first_not_of(",", subEnd); + } + + return true; +} + bool IniFile::Get(const char* sectionName, const char* key, int* value, int defaultValue) { std::string temp; |
