MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
Functions
util::string Namespace Reference

String conversions and helper functions. More...

Functions

void clip_newlines (std::string *str)
 Clips newlines from the end of the string, in-place.
 
void clip_whitespaces (std::string *str)
 Clips whitespaces from the front and end of the string, in-place.
 
std::string clipped_newlines (std::string const &str)
 Clips newlines from the end of the string.
 
std::string clipped_whitespaces (std::string const &str)
 Clips whitespaces from the front and end of the string.
 
template<typename T >
convert (std::string const &str, bool strict_conversion=true)
 From string to other types conversions.
 
std::string ellipsize (std::string const &in, std::size_t chars, int type=0)
 Reduces string size by inserting "..." at the end (type = 0), in the middle (type = 1) or at the beginning (type = 2).
 
template<typename T >
char const * for_type (void)
 String representation for types.
 
template<>
char const * for_type< double > (void)
 
template<>
char const * for_type< float > (void)
 
template<>
char const * for_type< int16_t > (void)
 
template<>
char const * for_type< int32_t > (void)
 
template<>
char const * for_type< int64_t > (void)
 
template<>
char const * for_type< int8_t > (void)
 
template<>
char const * for_type< uint16_t > (void)
 
template<>
char const * for_type< uint32_t > (void)
 
template<>
char const * for_type< uint64_t > (void)
 
template<>
char const * for_type< uint8_t > (void)
 
template<>
std::string get (std::string const &value)
 
template<typename T >
std::string get (T const &value)
 From arbitrary types to string conversion.
 
template<typename T >
std::string get_digits (T const &value, int digits)
 Returns string with 'digits' of precision.
 
template<typename T >
std::string get_filled (T const &value, int width, char fill='0')
 Returns a string filled to the left to a length of 'width' chars.
 
template<typename T >
std::string get_fixed (T const &value, int digits)
 Returns string with 'digits' of fixed precision (fills with zeros).
 
std::string get_size_string (std::size_t size)
 Returns a string with a human readable byte size, e.g.
 
std::string left (std::string const &str, std::size_t chars)
 Returns the leftmost 'chars' characters of 'str'.
 
std::string lowercase (std::string const &str)
 Returns a lower-case version of the string.
 
void normalize (std::string *str)
 Replaces several whitespaces with a single blank, in-place.
 
std::string normalized (std::string const &str)
 Replaces several whitespaces with a single blank.
 
void punctate (std::string *input, char delim=',', std::size_t spacing=3)
 Inserts 'delim' every 'spacing' characters from the right, in-place.
 
std::string punctated (std::string const &input, char delim=',', std::size_t spacing=3)
 Inserts 'delim' every 'spacing' characters from the right.
 
std::string right (std::string const &str, std::size_t chars)
 Returns the rightmost 'chars' characters of 'str'.
 
int size_for_type_string (std::string const &typestring)
 Returns the byte size of given type string (e.g.
 
std::string uppercase (std::string const &str)
 Returns an upper-case version of the string.
 
std::string wordwrap (char const *str, int width)
 Inserts line breaks on word boundaries to limit lines to 'width' chars.
 

Detailed Description

String conversions and helper functions.

Function Documentation

◆ clip_newlines()

void util::string::clip_newlines ( std::string *  str)
inline

Clips newlines from the end of the string, in-place.

Definition at line 317 of file strings.h.

◆ clip_whitespaces()

void util::string::clip_whitespaces ( std::string *  str)
inline

Clips whitespaces from the front and end of the string, in-place.

Definition at line 299 of file strings.h.

◆ clipped_newlines()

std::string util::string::clipped_newlines ( std::string const &  str)
inline

Clips newlines from the end of the string.

Definition at line 325 of file strings.h.

◆ clipped_whitespaces()

std::string util::string::clipped_whitespaces ( std::string const &  str)
inline

Clips whitespaces from the front and end of the string.

Definition at line 309 of file strings.h.

◆ convert()

template<typename T >
T util::string::convert ( std::string const &  str,
bool  strict_conversion = true 
)
inline

From string to other types conversions.

Definition at line 151 of file strings.h.

◆ ellipsize()

std::string util::string::ellipsize ( std::string const &  in,
std::size_t  chars,
int  type = 0 
)
inline

Reduces string size by inserting "..." at the end (type = 0), in the middle (type = 1) or at the beginning (type = 2).

Definition at line 388 of file strings.h.

◆ for_type()

template<typename T >
char const * util::string::for_type ( void  )

String representation for types.

Definition at line 163 of file strings.h.

◆ for_type< double >()

template<>
char const * util::string::for_type< double > ( void  )
inline

Definition at line 245 of file strings.h.

◆ for_type< float >()

template<>
char const * util::string::for_type< float > ( void  )
inline

Definition at line 238 of file strings.h.

◆ for_type< int16_t >()

template<>
char const * util::string::for_type< int16_t > ( void  )
inline

Definition at line 189 of file strings.h.

◆ for_type< int32_t >()

template<>
char const * util::string::for_type< int32_t > ( void  )
inline

Definition at line 196 of file strings.h.

◆ for_type< int64_t >()

template<>
char const * util::string::for_type< int64_t > ( void  )
inline

Definition at line 203 of file strings.h.

◆ for_type< int8_t >()

template<>
char const * util::string::for_type< int8_t > ( void  )
inline

Definition at line 169 of file strings.h.

◆ for_type< uint16_t >()

template<>
char const * util::string::for_type< uint16_t > ( void  )
inline

Definition at line 217 of file strings.h.

◆ for_type< uint32_t >()

template<>
char const * util::string::for_type< uint32_t > ( void  )
inline

Definition at line 224 of file strings.h.

◆ for_type< uint64_t >()

template<>
char const * util::string::for_type< uint64_t > ( void  )
inline

Definition at line 231 of file strings.h.

◆ for_type< uint8_t >()

template<>
char const * util::string::for_type< uint8_t > ( void  )
inline

Definition at line 210 of file strings.h.

◆ get() [1/2]

template<>
std::string util::string::get ( std::string const &  value)
inline

Definition at line 117 of file strings.h.

◆ get() [2/2]

template<typename T >
std::string util::string::get ( T const &  value)
inline

From arbitrary types to string conversion.

Definition at line 108 of file strings.h.

◆ get_digits()

template<typename T >
std::string util::string::get_digits ( T const &  value,
int  digits 
)
inline

Returns string with 'digits' of precision.

Definition at line 133 of file strings.h.

◆ get_filled()

template<typename T >
std::string util::string::get_filled ( T const &  value,
int  width,
char  fill = '0' 
)
inline

Returns a string filled to the left to a length of 'width' chars.

Definition at line 142 of file strings.h.

◆ get_fixed()

template<typename T >
std::string util::string::get_fixed ( T const &  value,
int  digits 
)
inline

Returns string with 'digits' of fixed precision (fills with zeros).

Definition at line 124 of file strings.h.

◆ get_size_string()

std::string util::string::get_size_string ( std::size_t  size)
inline

Returns a string with a human readable byte size, e.g.

9.3 MB.

Definition at line 478 of file strings.h.

◆ left()

std::string util::string::left ( std::string const &  str,
std::size_t  chars 
)
inline

Returns the leftmost 'chars' characters of 'str'.

Definition at line 446 of file strings.h.

◆ lowercase()

std::string util::string::lowercase ( std::string const &  str)
inline

Returns a lower-case version of the string.

Definition at line 458 of file strings.h.

◆ normalize()

void util::string::normalize ( std::string *  str)
inline

Replaces several whitespaces with a single blank, in-place.

Definition at line 409 of file strings.h.

◆ normalized()

std::string util::string::normalized ( std::string const &  str)
inline

Replaces several whitespaces with a single blank.

Definition at line 438 of file strings.h.

◆ punctate()

void util::string::punctate ( std::string *  input,
char  delim = ',',
std::size_t  spacing = 3 
)
inline

Inserts 'delim' every 'spacing' characters from the right, in-place.

Definition at line 271 of file strings.h.

◆ punctated()

std::string util::string::punctated ( std::string const &  input,
char  delim = ',',
std::size_t  spacing = 3 
)
inline

Inserts 'delim' every 'spacing' characters from the right.

Definition at line 291 of file strings.h.

◆ right()

std::string util::string::right ( std::string const &  str,
std::size_t  chars 
)
inline

Returns the rightmost 'chars' characters of 'str'.

Definition at line 452 of file strings.h.

◆ size_for_type_string()

int util::string::size_for_type_string ( std::string const &  typestring)
inline

Returns the byte size of given type string (e.g.

1 for "uint8"). If the type is unknown, the function returns 0.

Definition at line 252 of file strings.h.

◆ uppercase()

std::string util::string::uppercase ( std::string const &  str)
inline

Returns an upper-case version of the string.

Definition at line 468 of file strings.h.

◆ wordwrap()

std::string util::string::wordwrap ( char const *  str,
int  width 
)
inline

Inserts line breaks on word boundaries to limit lines to 'width' chars.

Definition at line 333 of file strings.h.