21 void IniFile::parse(std::istream &inputStream)
28 unsigned int whitespace = 0;
30 string scope, key, value;
36 const auto finishKeyValue = [&state, &scope, &key, &value, &whitespace,
this] {
37 if (key.empty() && value.empty() && state !=
Value) {
40 if (m_data.empty() || m_data.back().first != scope) {
41 m_data.emplace_back(make_pair(scope, decltype(m_data)::value_type::second_type()));
43 m_data.back().second.insert(make_pair(key, value));
49 const auto addChar = [&whitespace, &c](
string &to) {
65 inputStream.exceptions(ios_base::failbit | ios_base::badbit);
68 while (inputStream.get(c)) {
141 }
catch (
const std::ios_base::failure &) {
142 if (!inputStream.eof()) {
154 void IniFile::make(ostream &outputStream)
157 outputStream.exceptions(ios_base::failbit | ios_base::badbit);
158 for (
const auto &scope : m_data) {
159 outputStream <<
'[' << scope.first <<
']' <<
'\n';
160 for (
const auto &field : scope.second) {
161 outputStream << field.first <<
'=' << field.second <<
'\n';
163 outputStream <<
'\n';