5#ifndef BITCOIN_UTIL_STRING_H
6#define BITCOIN_UTIL_STRING_H
24 return spanparsing::Split<std::string>(str,
sep);
29 std::string::size_type front = str.find_first_not_of(
pattern);
30 if (front == std::string::npos) {
33 std::string::size_type end = str.find_last_not_of(
pattern);
34 return str.substr(front, end - front + 1);
45 return str.substr(
prefix.size());
62template <
typename T,
typename BaseType,
typename UnaryOp>
66 for (
size_t i = 0; i < list.size(); ++i) {
75template <
typename T,
typename T2>
82inline std::string
Join(
const std::vector<std::string> &list,
92 if (
c == 0)
return false;
101 std::ostringstream
oss;
102 oss.imbue(std::locale::classic());
110template <
typename T1,
size_t PREFIX_LEN>
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
std::string TrimString(std::string_view str, std::string_view pattern=" \f\n\r\t\v")
std::string RemovePrefix(std::string_view str, std::string_view prefix)
std::vector< std::string > SplitString(std::string_view str, char sep)
void ReplaceAll(std::string &in_out, const std::string &search, const std::string &substitute)
std::string_view RemovePrefixView(std::string_view str, std::string_view prefix)
bool ContainsNoNUL(std::string_view str) noexcept
Check if a string does not contain any embedded NUL (\0) characters.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
std::string_view TrimStringView(std::string_view str, std::string_view pattern=" \f\n\r\t\v")
bool HasPrefix(const T1 &obj, const std::array< uint8_t, PREFIX_LEN > &prefix)
Check whether a container begins with the given prefix.