#include <string>#include <vector>#include <sstream>#include <stdexcept>

Go to the source code of this file.
Functions | |
| std::string | erase_to_last_of (std::string const &str, char ch) |
| std::string | split (std::string &s, char c) |
| bool | is_prefix (std::string const &s, std::string const &prefix) |
| std::vector< std::string > | separate_token (std::string const &str, char sep) |
| std::string | ltrim (std::string const &str, std::string const &totrim="\t ") |
| remove trim chars from start of input string return the new string | |
| std::string | rtrim (std::string const &str, std::string const &totrim="\t ") |
| remove trim chars from end of input string return the new string | |
| std::string | trim (std::string const &str, std::string const &totrim="\t ") |
| ltrim(rtrim(str)) | |
| std::string const | format_percent (double value, size_t int_width, size_t frac_width, bool showpos=false) |
| template<typename To , typename From > | |
| To | op_lexical_cast (From const &src) |
| template<> | |
| unsigned int | op_lexical_cast< unsigned int > (std::string const &str) |
Variables | |
| static unsigned int const | percent_int_width = 2 |
| prefered width to format percentage | |
| static unsigned int const | percent_fract_width = 4 |
| static unsigned int const | percent_width = percent_int_width + percent_fract_width + 1 |
std::string helpers
Definition in file string_manip.h.
| std::string erase_to_last_of | ( | std::string const & | str, | |
| char | ch | |||
| ) |
| str | string | |
| ch | the characterto search |
erase char from the begin of str to the last occurence of ch from and return the string
| std::string const format_percent | ( | double | value, | |
| size_t | int_width, | |||
| size_t | frac_width, | |||
| bool | showpos = false | |||
| ) |
format_percent - smart format of double percentage value
| value | - the value | |
| int_width | - the maximum integer integer width default to 2 | |
| frac_width | - the fractionnary width default to 4 | |
| showpos | - show + sign for positive values |
This formats a percentage into exactly the given width and returns it. If the integer part is larger than the given int_width, the returned string will be wider. The returned string is never shorter than (fract_with + int_width + 1)
Definition at line 107 of file string_manip.cpp.
References is_prefix().
Referenced by format_percent_tests().


| bool is_prefix | ( | std::string const & | s, | |
| std::string const & | prefix | |||
| ) |
return true if "prefix" is a prefix of "s", behavior is undefined if prefix is an empty string
| std::string ltrim | ( | std::string const & | str, | |
| std::string const & | totrim = "\t " | |||
| ) |
remove trim chars from start of input string return the new string
| To op_lexical_cast | ( | From const & | src | ) | [inline] |
| src | input parameter convert From src to a T through an istringstream. |
Throws invalid_argument if conversion fail.
Note that this is not as foolproof as boost's lexical_cast
Definition at line 87 of file string_manip.h.
Referenced by oprof_start::read_set_events(), oprof_start::save_config(), generic_spec< T >::set(), tobool_tests(), tostr_tests(), and touint_tests().

| unsigned int op_lexical_cast< unsigned int > | ( | std::string const & | str | ) | [inline] |
| std::string rtrim | ( | std::string const & | str, | |
| std::string const & | totrim = "\t " | |||
| ) |
remove trim chars from end of input string return the new string
| std::vector<std::string> separate_token | ( | std::string const & | str, | |
| char | sep | |||
| ) |
| str | the string to tokenize | |
| sep | the separator_char |
separate fields in a string in a list of token; field are separated by the sep character, sep char can be escaped by '\' to specify a sep char in a token, '\' not followed by a sep is taken as it e.g. "\,\a" --> ",\a"
| std::string split | ( | std::string & | s, | |
| char | c | |||
| ) |
split string s by first occurence of char c, returning the second part. s is set to the first part. Neither include the split character
| std::string trim | ( | std::string const & | str, | |
| std::string const & | totrim = "\t " | |||
| ) |
ltrim(rtrim(str))
unsigned int const percent_fract_width = 4 [static] |
Definition at line 74 of file string_manip.h.
Referenced by format_output::formatter::format_diff(), and format_percent_tests().
unsigned int const percent_int_width = 2 [static] |
prefered width to format percentage
Definition at line 73 of file string_manip.h.
Referenced by format_output::formatter::format_diff(), and format_percent_tests().
unsigned int const percent_width = percent_int_width + percent_fract_width + 1 [static] |
Definition at line 75 of file string_manip.h.
1.6.1