Sierra Toolkit Version of the Day
StringUtilDetail

Classes

class  sierra::object_phrase
 Class object_phrase makes a pretty string for those annoying plural or singular noun/verb phrases. More...
struct  sierra::less_nocase< T >
 Class less_nocase implements a case insensitive compare functor. More...
struct  sierra::less_nocase< String >
 Class specialization less_nocase for String. More...
struct  sierra::less_nocase< std::string >
 Class specialization less_nocase for std::string. More...
struct  sierra::less_nocase< const char * >
 Class specialization less_nocase for char const pointer. More...
struct  sierra::equal_nocase< T >
 Class equal_nocase implements a case insensitive compare functor. More...
struct  sierra::equal_nocase< String >
 Class specialization equal_nocase for String. More...
struct  sierra::equal_nocase< std::string >
 Class specialization equal_nocase for std::string. More...
struct  sierra::equal_nocase< const char * >
 Class specialization equal_nocase for char const pointer. More...
struct  sierra::hash_nocase< _Key >
 Class hash_nocase is a traits class for hash functions. More...
struct  sierra::hash_nocase< std::string >
 Class specialization hash_nocase for std::string. More...
struct  sierra::hash_nocase< String >
 Class specialization hash_nocase for String. More...

Functions

int sierra::case_strcmp (const char *c1, const char *c2)
 Function case_strcmp compares two null terminated strings case insenstively. It returns zero if they are case insensitively equal, a negative value if c1 is case insensitively less than c2, or a positive value if c1 is case insensitively greater than c2
int sierra::case_strncmp (const char *c1, const char *c2, size_t n)
int sierra::case_strcmp (const std::string &s1, const std::string &s2)
 Function case_strcmp compares two null terminated strings case insenstively. It returns zero if they are case insensitively equal, a negative value if s1 is case insensitively less than s2, or a positive value if s1 is case insensitively greater than s2
int sierra::case_strcmp (const String &s1, const String &s2)
 Function case_strcmp compares two null terminated strings case insenstively. It returns zero if they are case insensitively equal, a negative value if s1 is case insensitively less than s2, or a positive value if s1 is case insensitively greater than s2
const char * sierra::case_strstr (const char *s, const char *find)
const char * sierra::case_strstr (const std::string &s1, const std::string &s2)
const char * sierra::case_strstr (const String &s1, const String &s2)
String sierra::undef_if_empty (const String &s)
int sierra::to_upper (int c)
 Function to_upper returns the value converted to upper case.
int sierra::to_lower (int c)
 Function to_lower returns the value converted to lower case.
int sierra::to_identifier_upper (int c)
 Function to_identifier_upper returns the value converted to underscore if it is a space or to upper case.
int sierra::to_identifier_lower (int c)
 Function to_identifier_lower returns the value converted to underscore if it is a space or to lower case.
template<class T >
T & sierra::make_upper (T &name)
 Function make_upper converts strgin name to upper case. The conversion happens in place.
template<class T >
T & sierra::make_lower (T &name)
 Function make_lower converts string name to lower case. The convertion happens in place.
template<class T >
T & sierra::make_identifier (T &name)
 Function make_identifier converts string name to an identifier case. The convertion happens in place.
template<class T >
T & sierra::make_lower_identifier (T &name)
 Function make_lower_identifier converts string name to a lower case identifier case. The convertion happens in place.
char * sierra::make_identifier (char *name)
 Function make_identifier converts string name to an identifier case. The convertion happens in place.
char * sierra::make_lower_identifier (char *name)
 Function make_lower_identifier converts string name to a lower case identifier case. The convertion happens in place.
template<class T >
T & sierra::trim (T &name)
 Function trim trims preceeding and trailing spaces from name. The convertion happens in place.
std::string sierra::title (const std::string &s)
 Function title returns a first letter of each word capitalized of the string.
std::string sierra::title (const String &s)
String sierra::lower (const String &s)
 Function lower returns a lower case version of the string.
std::string sierra::to_string (const double &r, int precision=4)
 Function to_string returns a string representation of r.
std::string sierra::to_string (const float &r, int precision=4)
 Function to_string returns a string representation of r.
template<typename T >
std::string sierra::to_string (const T &t)
const char * sierra::demangle (const char *symbol)
 Function demangle returns the demangled C++ symbol from the mangled C++ symbol. The mangled named is obtained from the type_info name() function. From some compilers, the name is already demangled.
std::string sierra::format_time (double t, const char *format="%b %e %Y %H:%M:%S")
 Function format_time encodes the time using the format specified. The format is described in stdftime.
std::string sierra::word_wrap (const std::string &s, unsigned int line_length, const std::string &prefix, const std::string &prefix_first_line)
 Function word_wrap reformats a string into multiple lines, none longer that line_length, the first line prefixed with prefix_first_line and the remaining lines prefixed with prefix.
std::string sierra::word_wrap (const std::string &s, unsigned int line_length=72, const std::string &prefix="")
 Function word_wrap reformats a string into multiple lines, none longer that line_length and each line prefixed with prefix.
std::ostream & sierra::operator<< (std::ostream &os, const object_phrase &phrase)
 Function operator<< writes an object phrase to the output stream.
std::istream & sierra::getline (std::istream &is, sierra::String &s, char eol= '\n')
 Function getline returns a string from the input stream which has been terminated by the newline character.
size_t sierra::hash_string_nocase (const char *p)
 Function hash_string_nocase hash a character string case insensitively.

Function Documentation

int sierra::case_strcmp ( const char *  c1,
const char *  c2 
)

Function case_strcmp compares two null terminated strings case insenstively. It returns zero if they are case insensitively equal, a negative value if c1 is case insensitively less than c2, or a positive value if c1 is case insensitively greater than c2

Parameters:
c1a char const pointer to the first string.
c2a char const pointer to the second string.
Returns:
an int value of zero if they are equal, negative if c1 is less than c2, or positive if c1 is greater than c2, without regard to case.

Definition at line 47 of file StringUtil.cpp.

int sierra::case_strcmp ( const std::string &  s1,
const std::string &  s2 
) [inline]

Function case_strcmp compares two null terminated strings case insenstively. It returns zero if they are case insensitively equal, a negative value if s1 is case insensitively less than s2, or a positive value if s1 is case insensitively greater than s2

Parameters:
s1a std::string reference to the first string.
s2a std::string reference to the second string.
Returns:
an int value of zero if they are equal, negative if s1 is less than s2, or positive if s1 is greater than s2, without regard to case.

Definition at line 52 of file StringUtil.hpp.

int sierra::case_strcmp ( const String s1,
const String s2 
) [inline]

Function case_strcmp compares two null terminated strings case insenstively. It returns zero if they are case insensitively equal, a negative value if s1 is case insensitively less than s2, or a positive value if s1 is case insensitively greater than s2

Parameters:
s1a String reference to the first string.
s2a String reference to the second string.
Returns:
an int value of zero if they are equal, negative if s1 is less than s2, or positive if s1 is greater than s2, without regard to case.

Definition at line 70 of file StringUtil.hpp.

int sierra::to_upper ( int  c) [inline]

Function to_upper returns the value converted to upper case.

Parameters:
can int value to be converted.
Returns:
an int value converted to upper case.

Definition at line 105 of file StringUtil.hpp.

int sierra::to_lower ( int  c) [inline]

Function to_lower returns the value converted to lower case.

Parameters:
can int value to be converted
Returns:
an int value converted to lower case.

Definition at line 116 of file StringUtil.hpp.

int sierra::to_identifier_upper ( int  c) [inline]

Function to_identifier_upper returns the value converted to underscore if it is a space or to upper case.

Parameters:
can int value to be converted
Returns:
an int value converted to an underscore or upper case.

Definition at line 128 of file StringUtil.hpp.

int sierra::to_identifier_lower ( int  c) [inline]

Function to_identifier_lower returns the value converted to underscore if it is a space or to lower case.

Parameters:
can int value to be converted
Returns:
an int value converted to an underscore or lower case.

Definition at line 140 of file StringUtil.hpp.

template<class T >
T& sierra::make_upper ( T &  name) [inline]

Function make_upper converts strgin name to upper case. The conversion happens in place.

Parameters:
namea T reference to convert to a upper case.
Returns:
an T reference to the converted upper case string.

Definition at line 153 of file StringUtil.hpp.

template<class T >
T& sierra::make_lower ( T &  name) [inline]

Function make_lower converts string name to lower case. The convertion happens in place.

Parameters:
namea T reference to convert to an lower.
Returns:
an T reference to the converted lower case string.

Definition at line 168 of file StringUtil.hpp.

template<class T >
T& sierra::make_identifier ( T &  name) [inline]

Function make_identifier converts string name to an identifier case. The convertion happens in place.

Parameters:
namea T reference to convert to an identifier.
Returns:
an T reference to the converted identifier string.

Definition at line 183 of file StringUtil.hpp.

template<class T >
T& sierra::make_lower_identifier ( T &  name) [inline]

Function make_lower_identifier converts string name to a lower case identifier case. The convertion happens in place.

Parameters:
namea T reference to convert to a lower case identifier.
Returns:
an T reference to the converted lower case identifier string.

Definition at line 199 of file StringUtil.hpp.

char* sierra::make_identifier ( char *  name) [inline]

Function make_identifier converts string name to an identifier case. The convertion happens in place.

Parameters:
namea char pointer to convert to an identifier.
Returns:
an char pointer to the converted identifier string.

Definition at line 213 of file StringUtil.hpp.

char* sierra::make_lower_identifier ( char *  name) [inline]

Function make_lower_identifier converts string name to a lower case identifier case. The convertion happens in place.

Parameters:
namea char pointer to convert to a lower case identifier.
Returns:
an char pointer to the converted lower case identifier string.

Definition at line 229 of file StringUtil.hpp.

template<class T >
T& sierra::trim ( T &  name) [inline]

Function trim trims preceeding and trailing spaces from name. The convertion happens in place.

Parameters:
namea T reference to trim.
Returns:
an T reference to the trimmed string.

Definition at line 246 of file StringUtil.hpp.

std::string sierra::title ( const std::string &  s)

Function title returns a first letter of each word capitalized of the string.

Parameters:
sa std::string const reference to be word capitalized.
Returns:
a std::string value of the word capitalized string.

Definition at line 107 of file StringUtil.cpp.

String sierra::lower ( const String s) [inline]

Function lower returns a lower case version of the string.

Parameters:
sa String const reference to be lower cased.
Returns:
a String value of the lower cased string.

Definition at line 281 of file StringUtil.hpp.

std::string sierra::to_string ( const double &  r,
int  precision = 4 
)

Function to_string returns a string representation of r.

Parameters:
ra double value to be stringized.
precisionan int value of the precision.
Returns:
a std::string value of the string representation of r.

Definition at line 151 of file StringUtil.cpp.

std::string sierra::to_string ( const float &  r,
int  precision = 4 
)

Function to_string returns a string representation of r.

Parameters:
ra float value to be stringized.
precisionan int value of the precision.
Returns:
a std::string value of the string representation of r.

Definition at line 162 of file StringUtil.cpp.

template<typename T >
std::string sierra::to_string ( const T &  t)

Template function to_string returns a string representation of r.

Parameters:
ta T value to be stringized.
Returns:
a std::string value of the string representation of r.

Definition at line 135 of file StringUtil.cpp.

const char * sierra::demangle ( const char *  symbol)

Function demangle returns the demangled C++ symbol from the mangled C++ symbol. The mangled named is obtained from the type_info name() function. From some compilers, the name is already demangled.

Parameters:
symbola char const pointer to the symbol.
Returns:
a std::string value of the demangled name.

Definition at line 210 of file Platform.cpp.

std::string sierra::format_time ( double  t,
const char *  format = "%b %e %Y %H:%M:%S" 
)

Function format_time encodes the time using the format specified. The format is described in stdftime.

Parameters:
ta time_t value of the time to format.
formata char const pointer to the format.
Returns:
a String value of the encoded time.

Definition at line 173 of file StringUtil.cpp.

std::string sierra::word_wrap ( const std::string &  s,
unsigned int  line_length,
const std::string &  prefix,
const std::string &  prefix_first_line 
)

Function word_wrap reformats a string into multiple lines, none longer that line_length, the first line prefixed with prefix_first_line and the remaining lines prefixed with prefix.

Parameters:
sa std::string const reference to the string to word wrap.
line_lengthan unsigned int value of the line length.
prefixa std::string const reference to a line prefix string.
prefix_first_linea std::string const reference to a line prefix string for the first line.
Returns:
a std::string value of the word wrapped string.

Definition at line 249 of file StringUtil.cpp.

std::string sierra::word_wrap ( const std::string &  s,
unsigned int  line_length = 72,
const std::string &  prefix = "" 
) [inline]

Function word_wrap reformats a string into multiple lines, none longer that line_length and each line prefixed with prefix.

Parameters:
sa std::string const reference to the string to word wrap.
line_lengthan unsigned int value of the line length.
prefixa std::string const reference to a line prefix string.
Returns:
a std::string value of the word wrapped string.

Definition at line 386 of file StringUtil.hpp.

std::ostream& sierra::operator<< ( std::ostream &  os,
const object_phrase &  phrase 
) [inline]

Function operator<< writes an object phrase to the output stream.

Parameters:
osa std::ostream reference to the output stream to write to.
phrasean object_phrase const reference to the object phrase to be written.
Returns:
a std::ostream reference to the output stream.

Definition at line 456 of file StringUtil.hpp.

std::istream & sierra::getline ( std::istream &  is,
sierra::String s,
char  eol = '\n' 
)

Function getline returns a string from the input stream which has been terminated by the newline character.

Parameters:
isa std::istream reference to the input stream.
sa sierra::String reference to received the line.
eola char value to use of the newline character.
Returns:
a std::istream reference to the input stream.

Definition at line 33 of file StringUtil.cpp.

size_t sierra::hash_string_nocase ( const char *  p) [inline]

Function hash_string_nocase hash a character string case insensitively.

Parameters:
pa char const pointer to a character string.
Returns:
a size_t value of the hashed string.

Definition at line 761 of file StringUtil.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines