Thrill  0.1
String Algorithms

## Functions

int compare_icase (const char *a, const char *b)
returns +1/0/-1 like strcmp(a, b) but without regard for letter case More...

int compare_icase (const char *a, const std::string &b)
returns +1/0/-1 like strcmp(a, b) but without regard for letter case More...

int compare_icase (const std::string &a, const char *b)
returns +1/0/-1 like strcmp(a, b) but without regard for letter case More...

int compare_icase (const std::string &a, const std::string &b)
returns +1/0/-1 like strcmp(a, b) but without regard for letter case More...

bool contains (const std::string &str, const std::string &pattern)
Tests of string contains pattern. More...

bool contains (const std::string &str, const char *pattern)
Tests of string contains pattern. More...

bool contains (const std::string &str, const char ch)
Tests of string contains character. More...

bool contains_word (const std::string &str, const char *word)
Search the given string for a whitespace-delimited word. More...

bool contains_word (const std::string &str, const std::string &word)
Search the given string for a whitespace-delimited word. More...

bool ends_with (const std::string &str, const std::string &match)
Checks if the given match string is located at the end of this string. More...

bool ends_with (const std::string &str, const char *match)
Checks if the given match string is located at the end of this string. More...

bool ends_with_icase (const std::string &str, const std::string &match)
Checks if the given match string is located at the end of this string. More...

bool ends_with_icase (const std::string &str, const char *match)
Checks if the given match string is located at the end of this string. More...

bool equal_icase (const char *a, const char *b)
returns true if a == b without regard for letter case More...

bool equal_icase (const char *a, const std::string &b)
returns true if a == b without regard for letter case More...

bool equal_icase (const std::string &a, const char *b)
returns true if a == b without regard for letter case More...

bool equal_icase (const std::string &a, const std::string &b)
returns true if a == b without regard for letter case More...

std::string & erase_all (std::string *str, char drop= ' ')
Remove all occurrences of the given character in-place. More...

std::string & erase_all (std::string *str, const char *drop)
Remove all occurrences of the given characters in-place. More...

std::string & erase_all (std::string *str, const std::string &drop)
Remove all occurrences of the given characters in-place. More...

std::string erase_all (const std::string &str, char drop= ' ')
Remove all occurrences of the given character, return copy of string. More...

std::string erase_all (const std::string &str, const char *drop)
Remove all occurrences of the given characters, return copy of string. More...

std::string erase_all (const std::string &str, const std::string &drop)
Remove all occurrences of the given characters, return copy of string. More...

std::string escape_html (const std::string &str)
Escape characters for inclusion in HTML documents: replaces the characters <, >, & and " with HTML entities. More...

std::string escape_uri (const std::string &src)
Escape a string into a URI-encoding. More...

std::string extract_between (const std::string &str, const char *sep1, const char *sep2)
Search the string for given start and end separators and extract all characters between the both, if they are found. More...

std::string extract_between (const std::string &str, const char *sep1, const std::string &sep2)
Search the string for given start and end separators and extract all characters between the both, if they are found. More...

std::string extract_between (const std::string &str, const std::string &sep1, const char *sep2)
Search the string for given start and end separators and extract all characters between the both, if they are found. More...

std::string extract_between (const std::string &str, const std::string &sep1, const std::string &sep2)
Search the string for given start and end separators and extract all characters between the both, if they are found. More...

std::string format_iec_units (uint64_t number, int precision)
Format number as something like 1 TiB. More...

std::string format_si_units (uint64_t number, int precision)
Format number as something like 1 TB. More...

size_t index_of (const std::vector< std::string > &list, const char *str)
Attempts to find str in the list and return the index. More...

size_t index_of (const std::vector< std::string > &list, const std::string &str)
Attempts to find str in the list and return the index. More...

size_t index_of_icase (const std::vector< std::string > &list, const char *str)
Attempts to find str in the list and return the index using case-insensitive comparisons. More...

size_t index_of_icase (const std::vector< std::string > &list, const std::string &str)
Attempts to find str in the list and return the index using case-insensitive comparisons. More...

std::string join (char glue, const std::vector< std::string > &parts)
Join a vector of strings by some glue character between each pair from the sequence. More...

std::string join (const char *glue, const std::vector< std::string > &parts)
Join a vector of strings by some glue string between each pair from the sequence. More...

std::string join (const std::string &glue, const std::vector< std::string > &parts)
Join a vector of strings by some glue string between each pair from the sequence. More...

template<typename Glue , typename Iterator >
static std::string join (Glue glue, Iterator first, Iterator last)
Join a sequence of strings by some glue string between each pair from the sequence. More...

template<typename Container >
static std::string join (char glue, const Container &parts)
Join a Container of strings by some glue character between each pair from the sequence. More...

template<typename Container >
static std::string join (const char *glue, const Container &parts)
Join a Container of strings by some glue string between each pair from the sequence. More...

template<typename Container >
static std::string join (const std::string &glue, const Container &parts)
Join a Container of strings by some glue string between each pair from the sequence. More...

bool less_icase (const char *a, const char *b)
returns true if a < b without regard for letter case More...

bool less_icase (const char *a, const std::string &b)
returns true if a < b without regard for letter case More...

bool less_icase (const std::string &a, const char *b)
returns true if a < b without regard for letter case More...

bool less_icase (const std::string &a, const std::string &b)
returns true if a < b without regard for letter case More...

Truncate or pad string to exactly len characters. More...

bool parse_si_iec_units (const char *str, uint64_t *out_size, char default_unit=0)
Parse a string like "343KB" or "44 GiB" into the corresponding size in bytes. More...

bool parse_si_iec_units (const std::string &str, uint64_t *out_size, char default_unit=0)
Parse a string like "343KB" or "44 GiB" into the corresponding size in bytes. More...

std::string & replace_all (std::string *str, const std::string &needle, const std::string &instead)
Replace all occurrences of needle in str. More...

std::string & replace_all (std::string *str, const std::string &needle, const char *instead)
Replace all occurrences of needle in str. More...

std::string & replace_all (std::string *str, const char *needle, const std::string &instead)
Replace all occurrences of needle in str. More...

std::string & replace_all (std::string *str, const char *needle, const char *instead)
Replace all occurrences of needle in str. More...

std::string replace_all (const std::string &str, const std::string &needle, const std::string &instead)
Replace all occurrences of needle in str. More...

std::string replace_all (const std::string &str, const std::string &needle, const char *instead)
Replace all occurrences of needle in str. More...

std::string replace_all (const std::string &str, const char *needle, const std::string &instead)
Replace all occurrences of needle in str. More...

std::string replace_all (const std::string &str, const char *needle, const char *instead)
Replace all occurrences of needle in str. More...

std::string & replace_first (std::string *str, const std::string &needle, const std::string &instead)
Replace only the first occurrence of needle in str. More...

std::string & replace_first (std::string *str, const std::string &needle, const char *instead)
Replace only the first occurrence of needle in str. More...

std::string & replace_first (std::string *str, const char *needle, const std::string &instead)
Replace only the first occurrence of needle in str. More...

std::string & replace_first (std::string *str, const char *needle, const char *instead)
Replace only the first occurrence of needle in str. More...

std::string replace_first (const std::string &str, const std::string &needle, const std::string &instead)
Replace only the first occurrence of needle in str. More...

std::string replace_first (const std::string &str, const std::string &needle, const char *instead)
Replace only the first occurrence of needle in str. More...

std::string replace_first (const std::string &str, const char *needle, const std::string &instead)
Replace only the first occurrence of needle in str. More...

std::string replace_first (const std::string &str, const char *needle, const char *instead)
Replace only the first occurrence of needle in str. More...

std::vector< std::string > split (char sep, const std::string &str, std::string::size_type limit=std::string::npos)
Split the given string at each separator character into distinct substrings. More...

std::vector< std::string > split (const char *sep, const std::string &str, std::string::size_type limit=std::string::npos)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > split (const std::string &sep, const std::string &str, std::string::size_type limit=std::string::npos)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > split (char sep, const std::string &str, std::string::size_type min_fields, std::string::size_type limit)
Split the given string at each separator character into distinct substrings. More...

std::vector< std::string > split (const char *sep, const std::string &str, std::string::size_type min_fields, std::string::size_type limit)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > split (const std::string &sep, const std::string &str, std::string::size_type min_fields, std::string::size_type limit)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > & split (std::vector< std::string > *into, char sep, const std::string &str, std::string::size_type limit=std::string::npos)
Split the given string at each separator character into distinct substrings. More...

std::vector< std::string > & split (std::vector< std::string > *into, const char *sep, const std::string &str, std::string::size_type limit=std::string::npos)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > & split (std::vector< std::string > *into, const std::string &sep, const std::string &str, std::string::size_type limit=std::string::npos)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > & split (std::vector< std::string > *into, char sep, const std::string &str, std::string::size_type min_fields, std::string::size_type limit)
Split the given string at each separator character into distinct substrings. More...

std::vector< std::string > & split (std::vector< std::string > *into, const char *sep, const std::string &str, std::string::size_type min_fields, std::string::size_type limit)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > & split (std::vector< std::string > *into, const std::string &sep, const std::string &str, std::string::size_type min_fields, std::string::size_type limit)
Split the given string at each separator string into distinct substrings. More...

std::vector< std::string > split_words (const std::string &str, std::string::size_type limit=std::string::npos)
Split the given string by whitespaces into distinct words. More...

bool starts_with (const std::string &str, const std::string &match)
Checks if the given match string is located at the start of this string. More...

bool starts_with (const std::string &str, const char *match)
Checks if the given match string is located at the start of this string. More...

bool starts_with_icase (const std::string &str, const std::string &match)
Checks if the given match string is located at the start of this string. More...

bool starts_with_icase (const std::string &str, const char *match)
Checks if the given match string is located at the start of this string. More...

char to_lower (char ch)
Transform the given character to lower case without any localization. More...

std::string & to_lower (std::string *str)
Transforms the given string to lowercase and returns a reference to it. More...

std::string to_lower (const std::string &str)
Returns a copy of the given string converted to lowercase. More...

char to_upper (char ch)
Transform the given character to upper case without any localization. More...

std::string & to_upper (std::string *str)
Transforms the given string to uppercase and returns a reference to it. More...

std::string to_upper (const std::string &str)
Returns a copy of the given string converted to uppercase. More...

std::string & trim (std::string *str, const char *drop=" \r\n\t")
Trims the given string in-place on the left and right. More...

std::string & trim (std::string *str, const std::string &drop)
Trims the given string in-place on the left and right. More...

std::string trim (const std::string &str, const char *drop=" \r\n\t")
Trims the given string in-place on the left and right. More...

std::string trim (const std::string &str, const std::string &drop)
Trims the given string in-place on the left and right. More...

std::string & trim_left (std::string *str, const char *drop=" \r\n\t")
Trims the given string in-place only on the left. More...

std::string & trim_left (std::string *str, const std::string &drop)
Trims the given string in-place only on the left. More...

std::string trim_left (const std::string &str, const char *drop=" \r\n\t")
Trims the given string only on the left. More...

std::string trim_left (const std::string &str, const std::string &drop)
Trims the given string only on the left. More...

std::string & trim_right (std::string *str, const char *drop=" \r\n\t")
Trims the given string in-place only on the right. More...

std::string & trim_right (std::string *str, const std::string &drop)
Trims the given string in-place only on the right. More...

std::string trim_right (const std::string &str, const char *drop=" \r\n\t")
Trims the given string only on the right. More...

std::string trim_right (const std::string &str, const std::string &drop)
Trims the given string only on the right. More...

std::string union_words (const std::string &wordsA, const std::string &wordsB)
Return union of two keyword sets. More...

std::string word_wrap (const std::string &str, unsigned int wrap=80)
Try to wrap a string to 80 columns without split words. More...

## Base64 Encoding and Decoding

std::string base64_encode (const void *data, size_t size, size_t line_break=0)
Encode the given binary data into base64 representation as described in RFC 2045 or RFC 3548. More...

std::string base64_encode (const std::string &str, size_t line_break=0)
Encode the given binary string into base64 representation as described in RFC 2045 or RFC 3548. More...

std::string base64_decode (const void *data, size_t size, bool strict=true)
Decode a string in base64 representation as described in RFC 2045 or RFC 3548 and return the original data. More...

std::string base64_decode (const std::string &str, bool strict=true)
Decode a string in base64 representation as described in RFC 2045 or RFC 3548 and return the original data. More...

## Hexdump Methods

std::string hexdump (const void *const data, size_t size)
Dump a (binary) string as a sequence of uppercase hexadecimal pairs. More...

std::string hexdump (const std::string &str)
Dump a (binary) string as a sequence of uppercase hexadecimal pairs. More...

template<typename Type >
std::string hexdump_type (const Type &t)
Dump a (binary) item as a sequence of uppercase hexadecimal pairs. More...

std::string hexdump (const std::vector< char > &data)
Dump a char vector as a sequence of uppercase hexadecimal pairs. More...

std::string hexdump (const std::vector< uint8_t > &data)
Dump a uint8_t vector as a sequence of uppercase hexadecimal pairs. More...

std::string hexdump_sourcecode (const std::string &str, const std::string &var_name="name")
Dump a (binary) string into a C source code snippet. More...

std::string hexdump_lc (const void *const data, size_t size)
Dump a (binary) string as a sequence of lowercase hexadecimal pairs. More...

std::string hexdump_lc (const std::string &str)
Dump a (binary) string as a sequence of lowercase hexadecimal pairs. More...

template<typename Type >
std::string hexdump_lc_type (const Type &t)
Dump a (binary) item as a sequence of lowercase hexadecimal pairs. More...

std::string hexdump_lc (const std::vector< char > &data)
Dump a char vector as a sequence of lowercase hexadecimal pairs. More...

std::string hexdump_lc (const std::vector< uint8_t > &data)
Dump a uint8_t vector as a sequence of lowercase hexadecimal pairs. More...

std::string parse_hexdump (const std::string &str)

## Detailed Description

simple string manipulations

## Function Documentation

 std::string base64_decode ( const void * data, size_t size, bool strict = true )

Decode a string in base64 representation as described in RFC 2045 or RFC 3548 and return the original data.

If a non-whitespace invalid base64 character is encountered and the parameter "strict" is true, then this function will throw a std::runtime_error. If "strict" is false, the character is silently ignored.

Parameters
 data input data to decode size size of input data to decode strict throw exception on invalid character
Returns
decoded binary data

Definition at line 108 of file base64.cpp.

Referenced by tlx::base64_decode().

 std::string base64_decode ( const std::string & str, bool strict = true )

Decode a string in base64 representation as described in RFC 2045 or RFC 3548 and return the original data.

If a non-whitespace invalid base64 character is encountered and the parameter "strict" is true, then this function will throw a std::runtime_error. If "strict" is false, the character is silently ignored.

Parameters
 str input string to encode strict throw exception on invalid character
Returns
decoded binary data

Definition at line 203 of file base64.cpp.

References tlx::base64_decode().

 std::string base64_encode ( const void * data, size_t size, size_t line_break = 0 )

Encode the given binary data into base64 representation as described in RFC 2045 or RFC 3548.

The output string contains only characters [A-Za-z0-9+/] and is roughly 33% longer than the input. The output string can be broken into lines after n characters, where n must be a multiple of 4.

Parameters
 data input data to encode size size of input data to encode line_break break the output string every n characters
Returns
base64 encoded string

Definition at line 25 of file base64.cpp.

Referenced by tlx::base64_encode().

 std::string base64_encode ( const std::string & str, size_t line_break = 0 )

Encode the given binary string into base64 representation as described in RFC 2045 or RFC 3548.

The output string contains only characters [A-Za-z0-9+/] and is roughly 33% longer than the input. The output string can be broken into lines after n characters, where n must be a multiple of 4.

Parameters
 str input string to encode line_break break the output string every n characters
Returns
base64 encoded string

Definition at line 102 of file base64.cpp.

References tlx::base64_encode().

 int compare_icase ( const char * a, const char * b )

returns +1/0/-1 like strcmp(a, b) but without regard for letter case

Definition at line 18 of file compare_icase.cpp.

References tlx::to_lower().

 int compare_icase ( const char * a, const std::string & b )

returns +1/0/-1 like strcmp(a, b) but without regard for letter case

Definition at line 35 of file compare_icase.cpp.

References tlx::to_lower().

 int compare_icase ( const std::string & a, const char * b )

returns +1/0/-1 like strcmp(a, b) but without regard for letter case

Definition at line 54 of file compare_icase.cpp.

References tlx::to_lower().

 int compare_icase ( const std::string & a, const std::string & b )

returns +1/0/-1 like strcmp(a, b) but without regard for letter case

Definition at line 72 of file compare_icase.cpp.

References tlx::to_lower().

 bool contains ( const std::string & str, const std::string & pattern )

Tests of string contains pattern.

Definition at line 15 of file contains.cpp.

 bool contains ( const std::string & str, const char * pattern )

Tests of string contains pattern.

Definition at line 19 of file contains.cpp.

 bool contains ( const std::string & str, const char ch )

Tests of string contains character.

Definition at line 23 of file contains.cpp.

 bool contains_word ( const std::string & str, const char * word )

Search the given string for a whitespace-delimited word.

It works as if the str was split_words() and the resulting vector checked for a given word. However this function does not create a vector, it scans the string directly. Whitespace is space, tab, newline or carriage-return.

Parameters
 str whitespace-delimited string to check word word to find
Returns
true if the word was found

Definition at line 19 of file contains_word.cpp.

References tlx::is_white().

Referenced by tlx::union_words().

 bool contains_word ( const std::string & str, const std::string & word )

Search the given string for a whitespace-delimited word.

It works as if the str was split_words() and the resulting vector checked for a given word. However this function does not create a vector, it scans the string directly. Whitespace is space, tab, newline or carriage-return.

Parameters
 str whitespace-delimited string to check word word to find
Returns
true if the word was found

Definition at line 55 of file contains_word.cpp.

References tlx::is_white().

 bool ends_with ( const std::string & str, const std::string & match )

Checks if the given match string is located at the end of this string.

Definition at line 20 of file ends_with.cpp.

 bool ends_with ( const std::string & str, const char * match )

Checks if the given match string is located at the end of this string.

Definition at line 27 of file ends_with.cpp.

 bool ends_with_icase ( const std::string & str, const std::string & match )

Checks if the given match string is located at the end of this string.

Compares the characters case-insensitively.

Definition at line 44 of file ends_with.cpp.

References tlx::to_lower().

 bool ends_with_icase ( const std::string & str, const char * match )

Checks if the given match string is located at the end of this string.

Compares the characters case-insensitively.

Definition at line 54 of file ends_with.cpp.

References tlx::to_lower().

 bool equal_icase ( const char * a, const char * b )

returns true if a == b without regard for letter case

Definition at line 18 of file equal_icase.cpp.

References tlx::to_lower().

Referenced by tlx::index_of_icase().

 bool equal_icase ( const char * a, const std::string & b )

returns true if a == b without regard for letter case

Definition at line 26 of file equal_icase.cpp.

References tlx::to_lower().

 bool equal_icase ( const std::string & a, const char * b )

returns true if a == b without regard for letter case

Definition at line 35 of file equal_icase.cpp.

References tlx::to_lower().

 bool equal_icase ( const std::string & a, const std::string & b )

returns true if a == b without regard for letter case

Definition at line 44 of file equal_icase.cpp.

References tlx::to_lower().

 std::string & erase_all ( std::string * str, char drop = ' ' )

Remove all occurrences of the given character in-place.

Parameters
 str string to process drop remove this character
Returns
reference to the modified string

Definition at line 18 of file erase_all.cpp.

Referenced by tlx::erase_all().

 std::string & erase_all ( std::string * str, const char * drop )

Remove all occurrences of the given characters in-place.

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 34 of file erase_all.cpp.

 std::string & erase_all ( std::string * str, const std::string & drop )

Remove all occurrences of the given characters in-place.

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 50 of file erase_all.cpp.

References tlx::erase_all().

 std::string erase_all ( const std::string & str, char drop = ' ' )

Remove all occurrences of the given character, return copy of string.

Parameters
 str string to process drop remove this character
Returns
copy of string possibly with less characters

Definition at line 57 of file erase_all.cpp.

 std::string erase_all ( const std::string & str, const char * drop )

Remove all occurrences of the given characters, return copy of string.

Parameters
 str string to process drop remove these characters
Returns
copy of string possibly with less characters

Definition at line 71 of file erase_all.cpp.

 std::string erase_all ( const std::string & str, const std::string & drop )

Remove all occurrences of the given characters, return copy of string.

Parameters
 str string to process drop remove these characters
Returns
copy of string possibly with less characters

Definition at line 92 of file erase_all.cpp.

References tlx::erase_all().

 std::string escape_html ( const std::string & str )

Escape characters for inclusion in HTML documents: replaces the characters <, >, & and " with HTML entities.

Definition at line 15 of file escape_html.cpp.

 std::string escape_uri ( const std::string & src )

Escape a string into a URI-encoding.

This maps all non A-Z0-9 characters to HH hex representation.

Definition at line 15 of file escape_uri.cpp.

 std::string extract_between ( const std::string & str, const char * sep1, const char * sep2 )

Search the string for given start and end separators and extract all characters between the both, if they are found.

Otherwise return an empty string.

Parameters
 str string to search in sep1 start boundary sep2 end boundary

Definition at line 37 of file extract_between.cpp.

References tlx::extract_between_template().

 std::string extract_between ( const std::string & str, const char * sep1, const std::string & sep2 )

Search the string for given start and end separators and extract all characters between the both, if they are found.

Otherwise return an empty string.

Parameters
 str string to search in sep1 start boundary sep2 end boundary

Definition at line 42 of file extract_between.cpp.

References tlx::extract_between_template().

 std::string extract_between ( const std::string & str, const std::string & sep1, const char * sep2 )

Search the string for given start and end separators and extract all characters between the both, if they are found.

Otherwise return an empty string.

Parameters
 str string to search in sep1 start boundary sep2 end boundary

Definition at line 47 of file extract_between.cpp.

References tlx::extract_between_template().

 std::string extract_between ( const std::string & str, const std::string & sep1, const std::string & sep2 )

Search the string for given start and end separators and extract all characters between the both, if they are found.

Otherwise return an empty string.

Parameters
 str string to search in sep1 start boundary sep2 end boundary

Definition at line 52 of file extract_between.cpp.

References tlx::extract_between_template().

 std::string format_iec_units ( uint64_t number, int precision = 3 )

Format number as something like 1 TiB.

Format a byte size using IEC (Ki, Mi, Gi, Ti) suffixes (powers of two). Returns "123 Ki" or similar.

Definition at line 38 of file format_si_iec_units.cpp.

Referenced by Context::Launch(), main(), and MemoryConfig::print().

 std::string format_si_units ( uint64_t number, int precision = 3 )

Format number as something like 1 TB.

Format a byte size using SI (K, M, G, T) suffixes (powers of ten). Returns "123 M" or similar.

Definition at line 19 of file format_si_iec_units.cpp.

 std::string hexdump ( const void *const data, size_t size )

Dump a (binary) string as a sequence of uppercase hexadecimal pairs.

Parameters
 data binary data to output in hex size length of binary data
Returns

Definition at line 21 of file hexdump.cpp.

 std::string hexdump ( const std::string & str )

Dump a (binary) string as a sequence of uppercase hexadecimal pairs.

Parameters
 str binary data to output in hex
Returns

Definition at line 42 of file hexdump.cpp.

References tlx::hexdump().

 std::string hexdump ( const std::vector< char > & data )

Dump a char vector as a sequence of uppercase hexadecimal pairs.

Parameters
 data binary data to output in hex
Returns

Definition at line 46 of file hexdump.cpp.

References tlx::hexdump().

 std::string hexdump ( const std::vector< uint8_t > & data )

Dump a uint8_t vector as a sequence of uppercase hexadecimal pairs.

Parameters
 data binary data to output in hex
Returns

Definition at line 50 of file hexdump.cpp.

References tlx::hexdump().

 std::string hexdump_lc ( const void *const data, size_t size )

Dump a (binary) string as a sequence of lowercase hexadecimal pairs.

Parameters
 data binary data to output in hex size length of binary data
Returns

Definition at line 95 of file hexdump.cpp.

Referenced by tlx::hexdump_lc(), and tlx::hexdump_lc_type().

 std::string hexdump_lc ( const std::string & str )

Dump a (binary) string as a sequence of lowercase hexadecimal pairs.

Parameters
 str binary data to output in hex
Returns

Definition at line 116 of file hexdump.cpp.

References tlx::hexdump_lc().

 std::string hexdump_lc ( const std::vector< char > & data )

Dump a char vector as a sequence of lowercase hexadecimal pairs.

Parameters
 data binary data to output in hex
Returns

Definition at line 120 of file hexdump.cpp.

References tlx::hexdump_lc().

 std::string hexdump_lc ( const std::vector< uint8_t > & data )

Dump a uint8_t vector as a sequence of lowercase hexadecimal pairs.

Parameters
 data binary data to output in hex
Returns

Definition at line 124 of file hexdump.cpp.

References tlx::hexdump_lc().

 std::string tlx::hexdump_lc_type ( const Type & t )

Dump a (binary) item as a sequence of lowercase hexadecimal pairs.

Parameters
 t binary data to output in hex
Returns

Definition at line 110 of file hexdump.hpp.

References tlx::hexdump_lc().

 std::string hexdump_sourcecode ( const std::string & str, const std::string & var_name = "name" )

Dump a (binary) string into a C source code snippet.

The snippet defines an array of const uint8_t* holding the data of the string.

Parameters
 str string to output as C source array var_name name of the array variable in the outputted code snippet
Returns
string holding C source snippet

Definition at line 54 of file hexdump.cpp.

 std::string tlx::hexdump_type ( const Type & t )

Dump a (binary) item as a sequence of uppercase hexadecimal pairs.

Parameters
 t binary data to output in hex
Returns

Definition at line 52 of file hexdump.hpp.

References tlx::hexdump().

 size_t index_of ( const std::vector< std::string > & list, const char * str )

Attempts to find str in the list and return the index.

Definition at line 19 of file index_of.cpp.

 size_t index_of ( const std::vector< std::string > & list, const std::string & str )

Attempts to find str in the list and return the index.

Definition at line 29 of file index_of.cpp.

 size_t index_of_icase ( const std::vector< std::string > & list, const char * str )

Attempts to find str in the list and return the index using case-insensitive comparisons.

Definition at line 39 of file index_of.cpp.

References tlx::equal_icase().

 size_t index_of_icase ( const std::vector< std::string > & list, const std::string & str )

Attempts to find str in the list and return the index using case-insensitive comparisons.

Definition at line 50 of file index_of.cpp.

References tlx::equal_icase().

 std::string join ( char glue, const std::vector< std::string > & parts )

Join a vector of strings by some glue character between each pair from the sequence.

Parameters
 glue character for glue parts the vector of strings to join
Returns
string constructed from the vector with the glue between two strings

Definition at line 16 of file join.cpp.

 std::string join ( const char * glue, const std::vector< std::string > & parts )

Join a vector of strings by some glue string between each pair from the sequence.

Parameters
 glue string to glue parts the vector of strings to join
Returns
string constructed from the vector with the glue between two strings

Definition at line 20 of file join.cpp.

References tlx::join().

 std::string join ( const std::string & glue, const std::vector< std::string > & parts )

Join a vector of strings by some glue string between each pair from the sequence.

Parameters
 glue string to glue parts the vector of strings to join
Returns
string constructed from the vector with the glue between two strings

Definition at line 24 of file join.cpp.

References tlx::join().

 static std::string tlx::join ( Glue glue, Iterator first, Iterator last )
inlinestatic

Join a sequence of strings by some glue string between each pair from the sequence.

The sequence in given as a range between two iterators.

Parameters
 glue string to glue first the beginning iterator of the range to join last the ending iterator of the range to join
Returns
string constructed from the range with the glue between two strings.

Definition at line 33 of file join_generic.hpp.

 static std::string tlx::join ( char glue, const Container & parts )
inlinestatic

Join a Container of strings by some glue character between each pair from the sequence.

Parameters
 glue character for glue parts the vector of strings to join
Returns
string constructed from the vector with the glue between two strings

Definition at line 60 of file join_generic.hpp.

References tlx::join().

 static std::string tlx::join ( const char * glue, const Container & parts )
inlinestatic

Join a Container of strings by some glue string between each pair from the sequence.

Parameters
 glue string to glue parts the vector of strings to join
Returns
string constructed from the vector with the glue between two strings

Definition at line 74 of file join_generic.hpp.

References tlx::join().

 static std::string tlx::join ( const std::string & glue, const Container & parts )
inlinestatic

Join a Container of strings by some glue string between each pair from the sequence.

Parameters
 glue string to glue parts the vector of strings to join
Returns
string constructed from the vector with the glue between two strings

Definition at line 88 of file join_generic.hpp.

References tlx::join().

 bool less_icase ( const char * a, const char * b )

returns true if a < b without regard for letter case

Definition at line 18 of file less_icase.cpp.

References tlx::to_lower().

 bool less_icase ( const char * a, const std::string & b )

returns true if a < b without regard for letter case

Definition at line 33 of file less_icase.cpp.

References tlx::to_lower().

 bool less_icase ( const std::string & a, const char * b )

returns true if a < b without regard for letter case

Definition at line 49 of file less_icase.cpp.

References tlx::to_lower().

 bool less_icase ( const std::string & a, const std::string & b )

returns true if a < b without regard for letter case

Definition at line 65 of file less_icase.cpp.

References tlx::to_lower().

 std::string pad ( const std::string & s, size_t len, char pad_char )

Truncate or pad string to exactly len characters.

Definition at line 15 of file pad.cpp.

 std::string parse_hexdump ( const std::string & str )

Converts each pair of hexadecimal digits into a byte of the output string. Throws std::runtime_error() if an unknown letter is encountered.

Parameters
 str string to parse as hex digits
Returns

Definition at line 131 of file hexdump.cpp.

 bool parse_si_iec_units ( const char * str, uint64_t * out_size, char default_unit = 0 )

Parse a string like "343KB" or "44 GiB" into the corresponding size in bytes.

Returns the number of bytes and sets ok = true if the string could be parsed correctly. If no units indicator is given, use def_unit in k/m/g/t/p (powers of ten) or in K/M/G/T/P (power of two).

Definition at line 17 of file parse_si_iec_units.cpp.

Referenced by main(), DiskConfig::parse_line(), tlx::parse_si_iec_units(), and MemoryConfig::setup_detect().

 bool parse_si_iec_units ( const std::string & str, uint64_t * out_size, char default_unit = 0 )

Parse a string like "343KB" or "44 GiB" into the corresponding size in bytes.

Returns the number of bytes and sets ok = true if the string could be parsed correctly. If no units indicator is given, use def_unit in k/m/g/t/p (powers of ten) or in K/M/G/T/P (power of two).

Definition at line 88 of file parse_si_iec_units.cpp.

References tlx::parse_si_iec_units().

 std::string & replace_all ( std::string * str, const std::string & needle, const std::string & instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 120 of file replace.cpp.

Referenced by thrill::common::LogCmdlineParams().

 std::string & replace_all ( std::string * str, const std::string & needle, const char * instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 133 of file replace.cpp.

 std::string & replace_all ( std::string * str, const char * needle, const std::string & instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 147 of file replace.cpp.

 std::string & replace_all ( std::string * str, const char * needle, const char * instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 161 of file replace.cpp.

 std::string replace_all ( const std::string & str, const std::string & needle, const std::string & instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. Returns a copy of the string with possible replacements.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacements

Definition at line 179 of file replace.cpp.

 std::string replace_all ( const std::string & str, const std::string & needle, const char * instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. Returns a copy of the string with possible replacements.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacements

Definition at line 194 of file replace.cpp.

 std::string replace_all ( const std::string & str, const char * needle, const std::string & instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. Returns a copy of the string with possible replacements.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacements

Definition at line 209 of file replace.cpp.

 std::string replace_all ( const std::string & str, const char * needle, const char * instead )

Replace all occurrences of needle in str.

Each needle will be replaced with instead, if found. Returns a copy of the string with possible replacements.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacements

Definition at line 224 of file replace.cpp.

 std::string & replace_first ( std::string * str, const std::string & needle, const std::string & instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 21 of file replace.cpp.

 std::string & replace_first ( std::string * str, const std::string & needle, const char * instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 32 of file replace.cpp.

 std::string & replace_first ( std::string * str, const char * needle, const std::string & instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 43 of file replace.cpp.

 std::string & replace_first ( std::string * str, const char * needle, const char * instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. The replacement is done in the given string and a reference to the same is returned.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
reference to str

Definition at line 54 of file replace.cpp.

 std::string replace_first ( const std::string & str, const std::string & needle, const std::string & instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. Returns a copy of the string with the possible replacement.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacement

Definition at line 68 of file replace.cpp.

 std::string replace_first ( const std::string & str, const std::string & needle, const char * instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. Returns a copy of the string with the possible replacement.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacement

Definition at line 81 of file replace.cpp.

 std::string replace_first ( const std::string & str, const char * needle, const std::string & instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. Returns a copy of the string with the possible replacement.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacement

Definition at line 93 of file replace.cpp.

 std::string replace_first ( const std::string & str, const char * needle, const char * instead )

Replace only the first occurrence of needle in str.

The needle will be replaced with instead, if found. Returns a copy of the string with the possible replacement.

Parameters
 str the string to process needle string to search for in str instead replace needle with instead
Returns
copy of string possibly with replacement

Definition at line 105 of file replace.cpp.

 std::vector< std::string > split ( char sep, const std::string & str, std::string::size_type limit = std::string::npos )

Split the given string at each separator character into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings.

Parameters
 sep separator character str string to split limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 20 of file split.cpp.

Referenced by JoinTPCH4(), DiskConfig::parse_fileio(), DiskConfig::parse_line(), Percentiles(), and tlx::split().

 std::vector< std::string > split ( const char * sep, const std::string & str, std::string::size_type limit = std::string::npos )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings.

Parameters
 sep separator string str string to split limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 28 of file split.cpp.

References tlx::split().

 std::vector< std::string > split ( const std::string & sep, const std::string & str, std::string::size_type limit = std::string::npos )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings.

Parameters
 sep separator string str string to split limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 36 of file split.cpp.

References tlx::split().

 std::vector< std::string > split ( char sep, const std::string & str, std::string::size_type min_fields, std::string::size_type limit )

Split the given string at each separator character into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings. Returns a vector of strings with at least min_fields and at most limit_fields, empty fields are added if needed.

Parameters
 sep separator string str string to split min_fields minimum number of parts returned limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 47 of file split.cpp.

References tlx::split().

 std::vector< std::string > split ( const char * sep, const std::string & str, std::string::size_type min_fields, std::string::size_type limit )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings. Returns a vector of strings with at least min_fields and at most limit_fields, empty fields are added if needed.

Parameters
 sep separator string str string to split min_fields minimum number of parts returned limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 56 of file split.cpp.

References tlx::split().

 std::vector< std::string > split ( const std::string & sep, const std::string & str, std::string::size_type min_fields, std::string::size_type limit )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings. Returns a vector of strings with at least min_fields and at most limit_fields, empty fields are added if needed.

Parameters
 sep separator string str string to split min_fields minimum number of parts returned limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 65 of file split.cpp.

References tlx::split().

 std::vector< std::string > & split ( std::vector< std::string > * into, char sep, const std::string & str, std::string::size_type limit = std::string::npos )

Split the given string at each separator character into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings.

Parameters
 into destination std::vector sep separator character str string to split limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 77 of file split.cpp.

 std::vector< std::string > & split ( std::vector< std::string > * into, const char * sep, const std::string & str, std::string::size_type limit = std::string::npos )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings.

Parameters
 into destination std::vector sep separator string str string to split limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 147 of file split.cpp.

References tlx::split().

 std::vector< std::string > & split ( std::vector< std::string > * into, const std::string & sep, const std::string & str, std::string::size_type limit = std::string::npos )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings.

Parameters
 into destination std::vector sep separator string str string to split limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 155 of file split.cpp.

References tlx::split().

 std::vector< std::string > & split ( std::vector< std::string > * into, char sep, const std::string & str, std::string::size_type min_fields, std::string::size_type limit )

Split the given string at each separator character into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings. Returns a vector of strings with at least min_fields and at most limit_fields, empty fields are added if needed.

Parameters
 into destination std::vector sep separator character str string to split min_fields minimum number of parts returned limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 166 of file split.cpp.

References tlx::split().

 std::vector< std::string > & split ( std::vector< std::string > * into, const char * sep, const std::string & str, std::string::size_type min_fields, std::string::size_type limit )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings. Returns a vector of strings with at least min_fields and at most limit_fields, empty fields are added if needed.

Parameters
 into destination std::vector sep separator string str string to split min_fields minimum number of parts returned limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 179 of file split.cpp.

References tlx::split().

 std::vector< std::string > & split ( std::vector< std::string > * into, const std::string & sep, const std::string & str, std::string::size_type min_fields, std::string::size_type limit )

Split the given string at each separator string into distinct substrings.

Multiple consecutive separators are considered individually and will result in empty split substrings. Returns a vector of strings with at least min_fields and at most limit_fields, empty fields are added if needed.

Parameters
 into destination std::vector sep separator string str string to split min_fields minimum number of parts returned limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 192 of file split.cpp.

References tlx::split().

 std::vector< std::string > split_words ( const std::string & str, std::string::size_type limit = std::string::npos )

Split the given string by whitespaces into distinct words.

Multiple consecutive whitespaces are considered as one split point. Whitespaces are space, tab, newline and carriage-return.

Parameters
 str string to split limit maximum number of parts returned
Returns
vector containing each split substring

Definition at line 15 of file split_words.cpp.

 bool starts_with ( const std::string & str, const std::string & match )

Checks if the given match string is located at the start of this string.

Definition at line 19 of file starts_with.cpp.

 bool starts_with ( const std::string & str, const char * match )

Checks if the given match string is located at the start of this string.

Definition at line 26 of file starts_with.cpp.

 bool starts_with_icase ( const std::string & str, const std::string & match )

Checks if the given match string is located at the start of this string.

Compares the characters case-insensitively.

Definition at line 39 of file starts_with.cpp.

References tlx::to_lower().

 bool starts_with_icase ( const std::string & str, const char * match )

Checks if the given match string is located at the start of this string.

Compares the characters case-insensitively.

Definition at line 49 of file starts_with.cpp.

References tlx::to_lower().

 char to_lower ( char ch )

Transform the given character to lower case without any localization.

Definition at line 17 of file to_lower.cpp.

 std::string & to_lower ( std::string * str )

Transforms the given string to lowercase and returns a reference to it.

Parameters
 str string to process
Returns
reference to the modified string

Definition at line 23 of file to_lower.cpp.

References tlx::to_lower().

 std::string to_lower ( const std::string & str )

Returns a copy of the given string converted to lowercase.

Parameters
 str string to process
Returns
new string lowercased

Definition at line 29 of file to_lower.cpp.

References tlx::to_lower().

 char to_upper ( char ch )

Transform the given character to upper case without any localization.

Definition at line 17 of file to_upper.cpp.

Referenced by tlx::to_upper().

 std::string & to_upper ( std::string * str )

Transforms the given string to uppercase and returns a reference to it.

Parameters
 str string to process
Returns
reference to the modified string

Definition at line 23 of file to_upper.cpp.

References tlx::to_upper().

 std::string to_upper ( const std::string & str )

Returns a copy of the given string converted to uppercase.

Parameters
 str string to process
Returns
new string uppercased

Definition at line 29 of file to_upper.cpp.

References tlx::to_upper().

 std::string & trim ( std::string * str, const char * drop = " \r\n\t" )

Trims the given string in-place on the left and right.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 20 of file trim.cpp.

 std::string & trim ( std::string * str, const std::string & drop )

Trims the given string in-place on the left and right.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 33 of file trim.cpp.

 std::string trim ( const std::string & str, const char * drop = " \r\n\t" )

Trims the given string in-place on the left and right.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 46 of file trim.cpp.

 std::string trim ( const std::string & str, const std::string & drop )

Trims the given string in-place on the left and right.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 62 of file trim.cpp.

 std::string & trim_left ( std::string * str, const char * drop = " \r\n\t" )

Trims the given string in-place only on the left.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 112 of file trim.cpp.

 std::string & trim_left ( std::string * str, const std::string & drop )

Trims the given string in-place only on the left.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 117 of file trim.cpp.

 std::string trim_left ( const std::string & str, const char * drop = " \r\n\t" )

Trims the given string only on the left.

Removes all characters in the given drop array, which defaults to " ". Returns a copy of the string.

Parameters
 str string to process drop remove these characters
Returns
new trimmed string

Definition at line 122 of file trim.cpp.

 std::string trim_left ( const std::string & str, const std::string & drop )

Trims the given string only on the left.

Removes all characters in the given drop array, which defaults to " ". Returns a copy of the string.

Parameters
 str string to process drop remove these characters
Returns
new trimmed string

Definition at line 129 of file trim.cpp.

 std::string & trim_right ( std::string * str, const char * drop = " \r\n\t" )

Trims the given string in-place only on the right.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 86 of file trim.cpp.

 std::string & trim_right ( std::string * str, const std::string & drop )

Trims the given string in-place only on the right.

Removes all characters in the given drop array, which defaults to " ".

Parameters
 str string to process drop remove these characters
Returns
reference to the modified string

Definition at line 91 of file trim.cpp.

 std::string trim_right ( const std::string & str, const char * drop = " \r\n\t" )

Trims the given string only on the right.

Removes all characters in the given drop array, which defaults to " ". Returns a copy of the string.

Parameters
 str string to process drop remove these characters
Returns
new trimmed string

Definition at line 96 of file trim.cpp.

 std::string trim_right ( const std::string & str, const std::string & drop )

Trims the given string only on the right.

Removes all characters in the given drop array, which defaults to " ". Returns a copy of the string.

Parameters
 str string to process drop remove these characters
Returns
new trimmed string

Definition at line 103 of file trim.cpp.

 std::string union_words ( const std::string & wordsA, const std::string & wordsB )

Return union of two keyword sets.

Definition at line 16 of file union_words.cpp.

References tlx::contains_word().

 std::string word_wrap ( const std::string & str, unsigned int wrap = 80 )

Try to wrap a string to 80 columns without split words.

All newlines are kept, new newline characters are inserted only at spaces, hence, words are never split. If words longer than 80 columns occur they are NOT broken.

Definition at line 22 of file word_wrap.cpp.

References tlx::is_space().