summaryrefslogtreecommitdiff
path: root/src/configuration.cpp
diff options
context:
space:
mode:
authorAlexander Baldeck <alexander@archlinux.org>2004-12-26 11:39:53 +0000
committerAlexander Baldeck <alexander@archlinux.org>2004-12-26 11:39:53 +0000
commit72a1107e594b1745026241d323f9fc44813bd91d (patch)
tree3c9760598495c373582659a18df322ab01a94778 /src/configuration.cpp
parent0c9ef7743aab89249f8fafdb44e362178fba988f (diff)
downloadmana-72a1107e594b1745026241d323f9fc44813bd91d.tar.gz
mana-72a1107e594b1745026241d323f9fc44813bd91d.tar.bz2
mana-72a1107e594b1745026241d323f9fc44813bd91d.tar.xz
mana-72a1107e594b1745026241d323f9fc44813bd91d.zip
- replaced default ini creation routine with new system
- testing version of write support for config system
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r--src/configuration.cpp55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 07e6005f..0b1f24a7 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -54,17 +54,64 @@ void Configuration::Init(std::string filename) {
#ifdef __DEBUG
for (iter = iniOptions.begin(); iter != iniOptions.end(); iter++) {
optionTmp = *iter;
- std::cout << "key=(" << optionTmp.key << ") stringValue=(" << optionTmp.stringValue << ") numericValue=(" << optionTmp.numericValue << ")\n";
+ std::cout << "Configuration::Init(" << optionTmp.key << ", \"" << optionTmp.stringValue << "\" / " << optionTmp.numericValue << ")\n";
}
#endif
}
-bool Configuration::Write() {
+bool Configuration::Write(std::string filename) {
+ std::ofstream out(filename.c_str(), std::ofstream::out | std::ofstream::trunc);
+ char tmp[20];
+
+ INI_OPTION optionTmp;
+ for (iter = iniOptions.begin(); iter != iniOptions.end(); iter++) {
+ optionTmp = *iter;
+ out.write(optionTmp.key.c_str(), optionTmp.key.length());
+ out.write("=", 1);
+
+ if(optionTmp.numericValue == 0) {
+ out.write(optionTmp.stringValue.c_str(), optionTmp.stringValue.length());
+ }else{
+ sprintf(tmp, "%19f", optionTmp.numericValue);
+ out.write(tmp, strlen(tmp));
+ strcpy(tmp, "");
+ }
+
+ out.write("\n", 1);
+ }
+
+ out.close();
return true;
}
-bool Configuration::setValue(std::string, std::string) {
- return true;
+void Configuration::setValue(std::string key, std::string value) {
+ if(getValue(key, value) == value) {
+ #ifdef __DEBUG
+ std::cout << "Configuration::setValue(" << key << ", \"" << value << "\")\n";
+ #endif
+ INI_OPTION optionTmp;
+
+ optionTmp.key = key;
+ optionTmp.stringValue = value;
+ optionTmp.numericValue = 0;
+
+ iniOptions.push_back(optionTmp);
+ }
+}
+
+void Configuration::setValue(std::string key, float value) {
+ if(getValue(key, value) == value) {
+ #ifdef __DEBUG
+ std::cout << "Configuration::setValue(" << key << ", " << value << ")\n";
+ #endif
+
+ INI_OPTION optionTmp;
+
+ optionTmp.key = key;
+ optionTmp.numericValue = value;
+
+ iniOptions.push_back(optionTmp);
+ }
}
/**