| 181 | } |
| 182 | |
| 183 | void OptionINI::parse(const string& buffer, string& key, string& value) { |
| 184 | // A key/value pair, separated by a '=' |
| 185 | |
| 186 | size_t startpos = buffer.find_first_of('='); |
| 187 | |
| 188 | if (startpos == string::npos) { |
| 189 | // Just set a flag to true |
| 190 | // e.g. "restart" or "append" on command line |
| 191 | key = buffer; |
| 192 | value = string("true"); |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | key = trim(buffer.substr(0, startpos), " \t\r\n\""); |
| 197 | value = trim(buffer.substr(startpos + 1), " \t\r\n\""); |
| 198 | |
| 199 | if (key.empty()) { |
| 200 | throw BoutException(_("\tEmpty key\n\tLine: {:s}"), buffer); |
| 201 | } |
| 202 | |
| 203 | if (key.find(':') != std::string::npos) { |
| 204 | throw BoutException(_("\tKey must not contain ':' character\n\tLine: {:s}"), buffer); |
| 205 | } |
| 206 | } |