diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-07-02 23:10:11 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-07-02 23:10:11 +0000 |
commit | a7cd7425d9341cf8a2c3af80b84cc55e874515c6 (patch) | |
tree | c5547bf656f8d351cd647d0a8fb3507b6a178dd4 /src/libutil | |
parent | 2f93d9f2ba40760d82c189480f7a7de06e7ccb86 (diff) |
Move `getParsedTypeAndSRI` to a more suitable location
Also mark it static
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/hash.cc | 21 | ||||
-rw-r--r-- | src/libutil/parser.hh | 21 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 1150e74ed..76fa67086 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -144,6 +144,27 @@ Hash Hash::parseSRI(std::string_view original) { return Hash(rest, parsedType, true); } +// Mutates the string to eliminate the prefixes when found +static std::pair<std::optional<HashType>, bool> getParsedTypeAndSRI(std::string_view & rest) { + bool isSRI = false; + + // Parse the has type before the separater, if there was one. + std::optional<HashType> optParsedType; + { + auto hashRaw = splitPrefix(rest, ':'); + + if (!hashRaw) { + hashRaw = splitPrefix(rest, '-'); + if (hashRaw) + isSRI = true; + } + if (hashRaw) + optParsedType = parseHashType(*hashRaw); + } + + return {optParsedType, isSRI}; +} + Hash Hash::parseAnyPrefixed(std::string_view original) { auto rest = original; diff --git a/src/libutil/parser.hh b/src/libutil/parser.hh index d20e4dfc6..a6a83ce89 100644 --- a/src/libutil/parser.hh +++ b/src/libutil/parser.hh @@ -21,26 +21,5 @@ static inline std::optional<std::string_view> splitPrefix(std::string_view & str return std::nullopt; } -// Mutates the string to eliminate the prefixes when found -std::pair<std::optional<HashType>, bool> getParsedTypeAndSRI(std::string_view & rest) { - bool isSRI = false; - - // Parse the has type before the separater, if there was one. - std::optional<HashType> optParsedType; - { - auto hashRaw = splitPrefix(rest, ':'); - - if (!hashRaw) { - hashRaw = splitPrefix(rest, '-'); - if (hashRaw) - isSRI = true; - } - if (hashRaw) - optParsedType = parseHashType(*hashRaw); - } - - return std::make_pair(optParsedType, isSRI); -} - } |