Bitcoin Core  27.99.0
P2P Digital Currency
Functions
string.h File Reference
#include <util/spanparsing.h>
#include <array>
#include <cstdint>
#include <cstring>
#include <locale>
#include <sstream>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for string.h:

Go to the source code of this file.

Functions

void ReplaceAll (std::string &in_out, const std::string &search, const std::string &substitute)
 
std::vector< std::string > SplitString (std::string_view str, char sep)
 
std::vector< std::string > SplitString (std::string_view str, std::string_view separators)
 
std::string_view TrimStringView (std::string_view str, std::string_view pattern=" \f\n\r\t\v")
 
std::string TrimString (std::string_view str, std::string_view pattern=" \f\n\r\t\v")
 
std::string_view RemovePrefixView (std::string_view str, std::string_view prefix)
 
std::string RemovePrefix (std::string_view str, std::string_view prefix)
 
template<typename C , typename S , typename UnaryOp >
auto Join (const C &container, const S &separator, UnaryOp unary_op)
 Join all container items. More...
 
template<typename C , typename S >
auto Join (const C &container, const S &separator)
 
std::string MakeUnorderedList (const std::vector< std::string > &items)
 Create an unordered multi-line list of items. More...
 
bool ContainsNoNUL (std::string_view str) noexcept
 Check if a string does not contain any embedded NUL (\0) characters. More...
 
template<typename T >
std::string ToString (const T &t)
 Locale-independent version of std::to_string. More...
 
template<typename T1 , size_t PREFIX_LEN>
bool HasPrefix (const T1 &obj, const std::array< uint8_t, PREFIX_LEN > &prefix)
 Check whether a container begins with the given prefix. More...
 

Function Documentation

◆ ContainsNoNUL()

bool ContainsNoNUL ( std::string_view  str)
inlinenoexcept

Check if a string does not contain any embedded NUL (\0) characters.

Definition at line 97 of file string.h.

Here is the caller graph for this function:

◆ HasPrefix()

template<typename T1 , size_t PREFIX_LEN>
bool HasPrefix ( const T1 &  obj,
const std::array< uint8_t, PREFIX_LEN > &  prefix 
)
inline

Check whether a container begins with the given prefix.

Definition at line 121 of file string.h.

Here is the caller graph for this function:

◆ Join() [1/2]

template<typename C , typename S >
auto Join ( const C &  container,
const S separator 
)

Definition at line 81 of file string.h.

Here is the call graph for this function:

◆ Join() [2/2]

template<typename C , typename S , typename UnaryOp >
auto Join ( const C &  container,
const S separator,
UnaryOp  unary_op 
)

Join all container items.

Typically used to concatenate strings but accepts containers with elements of any type.

Parameters
containerThe items to join
separatorThe separator
unary_opApply this operator to each item

Definition at line 68 of file string.h.

Here is the caller graph for this function:

◆ MakeUnorderedList()

std::string MakeUnorderedList ( const std::vector< std::string > &  items)
inline

Create an unordered multi-line list of items.

Definition at line 89 of file string.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemovePrefix()

std::string RemovePrefix ( std::string_view  str,
std::string_view  prefix 
)
inline

Definition at line 54 of file string.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemovePrefixView()

std::string_view RemovePrefixView ( std::string_view  str,
std::string_view  prefix 
)
inline

Definition at line 46 of file string.h.

Here is the caller graph for this function:

◆ ReplaceAll()

void ReplaceAll ( std::string &  in_out,
const std::string &  search,
const std::string &  substitute 
)

Definition at line 10 of file string.cpp.

Here is the caller graph for this function:

◆ SplitString() [1/2]

std::vector<std::string> SplitString ( std::string_view  str,
char  sep 
)
inline

Definition at line 21 of file string.h.

Here is the caller graph for this function:

◆ SplitString() [2/2]

std::vector<std::string> SplitString ( std::string_view  str,
std::string_view  separators 
)
inline

Definition at line 26 of file string.h.

◆ ToString()

template<typename T >
std::string ToString ( const T &  t)

Locale-independent version of std::to_string.

Definition at line 109 of file string.h.

Here is the caller graph for this function:

◆ TrimString()

std::string TrimString ( std::string_view  str,
std::string_view  pattern = " \f\n\r\t\v" 
)
inline

Definition at line 41 of file string.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrimStringView()

std::string_view TrimStringView ( std::string_view  str,
std::string_view  pattern = " \f\n\r\t\v" 
)
inline

Definition at line 31 of file string.h.

Here is the caller graph for this function: