ifw-core 7.0.0
 
Loading...
Searching...
No Matches
ifw::core::utils::string Namespace Reference

Functions

std::string Upper (const std::string &str)
 Uppercase string.
 
std::string Lower (const std::string &str)
 Lower case string.
 
std::string Trim (const std::string &str, const std::string &trim_chars)
 Trim input string for leading/trailing characters.
 
std::string Replace (const std::string &str, const std::string &old_sub_str, const std::string &new_sub_str)
 Replace occurences of "old_sub_str" with "new_sub_str" in "str".
 
std::string Truncate (const std::string &text, const int32_t max_len, const std::string &truncation_indicator="...")
 Truncate "str" if longer than "max_len".
 
void Split (const std::string &str, const std::string &separator, std::vector< std::string > &str_els, int32_t exp_nb_elements=-1)
 Split "str" according to the sequence of separator characters given.
 
std::vector< std::string > Split (const std::string &str, const std::string &separator, int32_t exp_nb_elements=-1)
 Split "str" according to the sequence of separator characters given.
 
void SplitBuffer (const std::string buffer, std::vector< std::string > &buffer_lines, const bool strip=true, const bool remove_empty_lines=true, const std::string remove_comments="")
 Split a buffer, typically a file buffer, with newline characters.
 
template<class TYPE>
std::string Concat (const std::vector< TYPE > &list, const std::string &sep="")
 Concatenate elements of the given type, contained in the list.
 
void StringCopy (char *dest_buf, const char *src_buf, const int32_t max_bytes, const bool truncate=false)
 Safe string copy. If the length of “src_buf” exceeds “max_bytes” the string may either be truncated or the function fails.
 
bool Match (const std::string &str, const std::string &reg_exp)
 Carry out a regular expression match on the given string.
 

Function Documentation

◆ Concat()

template<class TYPE>
std::string ifw::core::utils::string::Concat ( const std::vector< TYPE > & list,
const std::string & sep = "" )

Concatenate elements of the given type, contained in the list.

◆ Lower()

std::string ifw::core::utils::string::Lower ( const std::string & str)

Lower case string.

◆ Match()

bool ifw::core::utils::string::Match ( const std::string & str,
const std::string & reg_exp )

Carry out a regular expression match on the given string.

Todo
Use mutex to protect this.

◆ Replace()

std::string ifw::core::utils::string::Replace ( const std::string & str,
const std::string & old_sub_str,
const std::string & new_sub_str )

Replace occurences of "old_sub_str" with "new_sub_str" in "str".

◆ Split() [1/2]

std::vector< std::string > ifw::core::utils::string::Split ( const std::string & str,
const std::string & separator,
int32_t exp_nb_elements = -1 )

Split "str" according to the sequence of separator characters given.

◆ Split() [2/2]

void ifw::core::utils::string::Split ( const std::string & str,
const std::string & separator,
std::vector< std::string > & str_els,
int32_t exp_nb_elements = -1 )

Split "str" according to the sequence of separator characters given.

◆ SplitBuffer()

void ifw::core::utils::string::SplitBuffer ( const std::string buffer,
std::vector< std::string > & buffer_lines,
const bool strip = true,
const bool remove_empty_lines = true,
const std::string remove_comments = "" )

Split a buffer, typically a file buffer, with newline characters.

◆ StringCopy()

void ifw::core::utils::string::StringCopy ( char * dest_buf,
const char * src_buf,
const int32_t max_bytes,
const bool truncate = false )

Safe string copy. If the length of “src_buf” exceeds “max_bytes” the string may either be truncated or the function fails.

◆ Trim()

std::string ifw::core::utils::string::Trim ( const std::string & str,
const std::string & trim_chars )

Trim input string for leading/trailing characters.

◆ Truncate()

std::string ifw::core::utils::string::Truncate ( const std::string & text,
const int32_t max_len,
const std::string & truncation_indicator = "..." )

Truncate "str" if longer than "max_len".

◆ Upper()

std::string ifw::core::utils::string::Upper ( const std::string & str)

Uppercase string.