MCPcopy Create free account
hub / github.com/KDE/okular / parseString

Function parseString

part/DistinguishedNameParser.h:279–314  ·  view source on GitHub ↗

Parse a DN and return an array-ized one. This is not a validating parser and it does not support any old-stylish syntax; gpgme is expected to return only rfc2253 compatible strings. */

Source from the content-addressed store, hash-verified

277 parser and it does not support any old-stylish syntax; gpgme is
278 expected to return only rfc2253 compatible strings. */
279static Result parseString(std::string_view string)
280{
281 Result result;
282 while (!string.empty()) {
283 string = detail::removeLeadingSpaces(string);
284 if (string.empty()) {
285 break;
286 }
287
288 auto [partResult, dnPair] = detail::parse_dn_part(string);
289 if (!partResult.has_value()) {
290 return {};
291 }
292
293 string = partResult.value();
294 if (dnPair.first.size() && dnPair.second.size()) {
295 result.emplace_back(std::move(dnPair));
296 }
297
298 string = detail::removeLeadingSpaces(string);
299 if (string.empty()) {
300 break;
301 }
302 switch (string.front()) {
303 case ',':
304 case ';':
305 case '+':
306 string.remove_prefix(1);
307 break;
308 default:
309 // some unexpected characters here
310 return {};
311 }
312 }
313 return result;
314}
315
316/// returns the first value of a given key (note. there can be multiple)
317/// or nullopt if key is not available

Callers 2

testParserMethod · 0.85
splitDNAttributesFunction · 0.85

Calls 4

removeLeadingSpacesFunction · 0.85
parse_dn_partFunction · 0.85
valueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected