Bitcoin Core  0.20.99
P2P Digital Currency
Functions
string.h File Reference
#include <attributes.h>
#include <algorithm>
#include <array>
#include <cstring>
#include <locale>
#include <sstream>
#include <string>
#include <vector>
Include dependency graph for string.h:

Go to the source code of this file.

Functions

NODISCARD std::string TrimString (const std::string &str, const std::string &pattern=" \\\)
 
template<typename T , typename BaseType , typename UnaryOp >
auto Join (const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
 Join a list of items. More...
 
template<typename T >
Join (const std::vector< T > &list, const T &separator)
 
std::string Join (const std::vector< std::string > &list, const std::string &separator)
 
NODISCARD bool ValidAsCString (const std::string &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>
NODISCARD 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

◆ HasPrefix()

template<typename T1 , size_t PREFIX_LEN>
NODISCARD 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 83 of file string.h.

Here is the caller graph for this function:

◆ Join() [1/3]

template<typename T , typename BaseType , typename UnaryOp >
auto Join ( const std::vector< T > &  list,
const BaseType &  separator,
UnaryOp  unary_op 
) -> decltype(unary_op(list.at(0)))

Join a list of items.

Parameters
listThe list to join
separatorThe separator
unary_opApply this operator to each item in the list

Definition at line 36 of file string.h.

Here is the caller graph for this function:

◆ Join() [2/3]

template<typename T >
T Join ( const std::vector< T > &  list,
const T &  separator 
)

Definition at line 48 of file string.h.

Here is the call graph for this function:

◆ Join() [3/3]

std::string Join ( const std::vector< std::string > &  list,
const std::string &  separator 
)
inline

Definition at line 54 of file string.h.

◆ ToString()

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

Locale-independent version of std::to_string.

Definition at line 71 of file string.h.

Here is the caller graph for this function:

◆ TrimString()

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

Definition at line 18 of file string.h.

Here is the caller graph for this function:

◆ ValidAsCString()

NODISCARD bool ValidAsCString ( const std::string &  str)
inlinenoexcept

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

Definition at line 62 of file string.h.

Here is the caller graph for this function: