WarpX
Functions
WarpXUtilStr Namespace Reference

Functions

bool is_in (const std::vector< std::string > &vect, const std::string &elem)
 
bool is_in (const std::vector< std::string > &vect, const std::vector< std::string > &elems)
 
template<typename Container >
auto split (std::string const &instr, std::string const &separator, bool const trim=false, std::string const &trim_space=" \)
 Splits a string using a string separator. This is somewhat similar to amrex::Tokenize. The main difference is that, if the separator ":" is used, amrex::Tokenize will split ":3::2" into ["3","2"] while this functio will split ":3::2" into ["","3","","2"]. This function can also perform a trimming to remove whitespaces (or any other arbitrary string) from the split string. More...
 

Function Documentation

◆ is_in() [1/2]

bool WarpXUtilStr::is_in ( const std::vector< std::string > &  vect,
const std::string &  elem 
)

Return true if elem is in vect, false otherwise

Parameters
[in]vectvector of strings, typically names
[in]elemsingle string
Returns
true if elem is in vect, false otherwise

◆ is_in() [2/2]

bool WarpXUtilStr::is_in ( const std::vector< std::string > &  vect,
const std::vector< std::string > &  elems 
)

Return true if any element in elems is in vect, false otherwise

Parameters
[in]vectvector of strings, typically names
[in]elemsvector of string
Returns
true if any element in elems is in vect, false otherwise

◆ split()

template<typename Container >
auto WarpXUtilStr::split ( std::string const &  instr,
std::string const &  separator,
bool const  trim = false,
std::string const &  trim_space = " \t" 
)

Splits a string using a string separator. This is somewhat similar to amrex::Tokenize. The main difference is that, if the separator ":" is used, amrex::Tokenize will split ":3::2" into ["3","2"] while this functio will split ":3::2" into ["","3","","2"]. This function can also perform a trimming to remove whitespaces (or any other arbitrary string) from the split string.

Template Parameters
Containerthe type of the split string.
Parameters
[in]instrthe input string
[in]separatorthe separator string
[in]trimtrue to trim the split string, false otherwise.
[in]trim_spacethe string to trim if trim is true.
Returns
cont the split string