5#ifndef BITCOIN_TEST_UTIL_STR_H
6#define BITCOIN_TEST_UTIL_STR_H
16template <
typename CharType,
size_t StringLength>
17bool NextString(CharType (&
string)[StringLength], CharType min_char, CharType max_char)
19 for (CharType& elem :
string) {
20 bool has_next = elem != max_char;
21 elem = elem < min_char || elem >= max_char ? min_char : CharType(elem + 1);
22 if (has_next)
return true;
31template <
typename CharType,
size_t StringLength,
typename Fn>
32void ForEachNoDup(CharType (&
string)[StringLength], CharType min_char, CharType max_char, Fn&& fn) {
33 for (
bool has_next =
true; has_next; has_next =
NextString(
string, min_char, max_char)) {
35 bool skip_string =
false;
36 for (CharType c :
string) {
37 if (c == prev) skip_string =
true;
38 if (skip_string || c < min_char || c > max_char)
break;
41 if (!skip_string) fn();
void ForEachNoDup(CharType(&string)[StringLength], CharType min_char, CharType max_char, Fn &&fn)
Iterate over string values and call function for each string without successive duplicate characters.
bool NextString(CharType(&string)[StringLength], CharType min_char, CharType max_char)
Increment a string.
bool CaseInsensitiveEqual(const std::string &s1, const std::string &s2)