mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Parse the string in Settings. Also added an another getter.
This commit is contained in:
parent
b8442280dd
commit
2db1a0693e
@ -3,7 +3,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
String Settings::get_value(const String &key, const String &def) {
|
||||
Variant Settings::get_value(const String &key, const Variant &def) {
|
||||
std::map<String, Variant>::iterator e = _data.find(key);
|
||||
|
||||
if (e != _data.end()) {
|
||||
return e->second;
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
String Settings::get_value_string(const String &key, const String &def) {
|
||||
std::map<String, Variant>::iterator e = _data.find(key);
|
||||
|
||||
if (e != _data.end()) {
|
||||
@ -92,7 +101,7 @@ void Settings::parse_ini_file(const String &path) {
|
||||
String k = s.substr_index(0, eindex - 1);
|
||||
String v = s.substr_index(eindex + 1, s.size() - 1);
|
||||
|
||||
_data[k] = v;
|
||||
_data[k] = Variant::parse_string(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,8 @@
|
||||
|
||||
class Settings {
|
||||
public:
|
||||
String get_value(const String &key, const String &def = "");
|
||||
Variant get_value(const String &key, const Variant &def = Variant());
|
||||
String get_value_string(const String &key, const String &def = "");
|
||||
int get_value_int(const String &key, const int def = 0);
|
||||
float get_value_float(const String &key, const float def = 0);
|
||||
double get_value_double(const String &key, const double def = 0);
|
||||
|
Loading…
Reference in New Issue
Block a user