MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / parse

Method parse

src/sys/options/options_ini.cxx:183–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183void 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}

Callers

nothing calls this directly

Calls 1

trimFunction · 0.85

Tested by

no test coverage detected