50 std::istream* is =
reinterpret_cast<std::istream*
>(stream);
55 std::istream::sentry se(*is,
true);
56 std::streambuf* sb = is->rdbuf();
67 if (sb->sgetc() ==
'\n') {
75 is->setstate(std::ios::eofbit);
84 if (out.empty() && (is->fail() || is->eof())) {
85 return (
char*)
nullptr;
88 strncpy(str, out.c_str(), num);
94 return (
char*)
nullptr;
103 string INIReader::Get(
const string& section,
const string& name,
const string& default_value)
const
105 string key =
MakeKey(section, name);
107 return _values.count(key) ?
_values.find(key)->second : default_value;
112 const string str =
Get(section, name,
"");
113 return str.empty() ? default_value : str;
118 string valstr =
Get(section, name,
"");
119 const char* value = valstr.c_str();
122 long n = strtol(value, &end, 0);
123 return end > value ? n : default_value;
128 string valstr =
Get(section, name,
"");
129 const char* value = valstr.c_str();
131 double n = strtod(value, &end);
132 return end > value ? n : default_value;
137 string valstr =
Get(section, name,
"");
139 std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower);
140 if (valstr ==
"true" || valstr ==
"yes" || valstr ==
"on" || valstr ==
"1")
142 else if (valstr ==
"false" || valstr ==
"no" || valstr ==
"off" || valstr ==
"0")
145 return default_value;
150 string key =
MakeKey(section, name);
156 string key = section +
"=" + name;
158 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
166 string key =
MakeKey(section, name);
167 if (reader->
_values[key].size() > 0)