MCPcopy Create free account
hub / github.com/clechasseur/pathcopycopy / GetMultiStringLineBeginningWith

Method GetMultiStringLineBeginningWith

PathCopyCopy/src/PluginUtils.cpp:451–477  ·  view source on GitHub ↗

Given a multi-line string read from a REG_MULTI_SZ registry value, finds a line that begins with a given prefix and returns it. @param p_MultiStringValue The multi-string value. @param p_Prefix Prefix of line to look for. @return The entire matching line (excluding prefix), or an empty string if line is not found.

Source from the content-addressed store, hash-verified

449 // @return The entire matching line (excluding prefix), or an empty string if line is not found.
450 //
451 std::wstring PluginUtils::GetMultiStringLineBeginningWith(const std::wstring& p_MultiStringValue,
452 const std::wstring& p_Prefix)
453 {
454 std::wstring line;
455
456 // Multi-line values contain embedded NULLs to separate the lines.
457 std::wstring::size_type offset = 0;
458 do {
459 const std::wstring::size_type endOffset = p_MultiStringValue.find_first_of(L'\0', offset);
460 if (endOffset == offset) {
461 // We're at the end of the value.
462 break;
463 }
464
465 if (p_MultiStringValue.find(p_Prefix, offset) == offset) {
466 // This is the line we're looking for.
467 const std::wstring::size_type prefixSize = p_Prefix.size();
468 line = p_MultiStringValue.substr(offset + prefixSize, endOffset - offset - prefixSize);
469 break;
470 } else {
471 // Not the line, go to next one.
472 offset = endOffset + 1;
473 }
474 } while (offset < p_MultiStringValue.size());
475
476 return line;
477 }
478
479 //
480 // Converts a string containing a list of plugin unique identifiers

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected