MCPcopy Create free account
hub / github.com/dhbloo/rapfi / parse_bare_key

Function parse_bare_key

Rapfi/external/cpptoml/include/cpptoml.h:2233–2270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2231 }
2232
2233 std::string parse_bare_key(std::string::iterator& it,
2234 const std::string::iterator& end)
2235 {
2236 if (it == end)
2237 {
2238 throw_parse_exception("Bare key missing name");
2239 }
2240
2241 auto key_end = end;
2242 --key_end;
2243 consume_backwards_whitespace(key_end, it);
2244 ++key_end;
2245 std::string key{it, key_end};
2246
2247 if (std::find(it, key_end, '#') != key_end)
2248 {
2249 throw_parse_exception("Bare key " + key + " cannot contain #");
2250 }
2251
2252 if (std::find_if(it, key_end,
2253 [](char c) { return c == ' ' || c == '\t'; })
2254 != key_end)
2255 {
2256 throw_parse_exception("Bare key " + key
2257 + " cannot contain whitespace");
2258 }
2259
2260 if (std::find_if(it, key_end,
2261 [](char c) { return c == '[' || c == ']'; })
2262 != key_end)
2263 {
2264 throw_parse_exception("Bare key " + key
2265 + " cannot contain '[' or ']'");
2266 }
2267
2268 it = end;
2269 return key;
2270 }
2271
2272 enum class parse_type
2273 {

Callers 1

parse_simple_keyFunction · 0.85

Calls 2

throw_parse_exceptionFunction · 0.85

Tested by

no test coverage detected