Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespaces | Functions
StringUtils.h File Reference

Detailed Description

Various string utility functions.

Include dependency graph for StringUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 ola
 The namespace containing all OLA symbols.
 

Functions

void ola::StringSplit (const std::string &input, std::vector< std::string > *tokens, const std::string &delimiters=" ")
 Split a string into pieces. More...
 
void ola::StringSplit (const std::string &input, std::vector< std::string > &tokens, const std::string &delimiters=" ")
 Split a string into pieces. More...
 
void ola::StringTrim (std::string *input)
 Trim leading and trailing whitespace from a string. More...
 
void ola::ShortenString (std::string *input)
 Truncate the string based on the presence of \0 characters. More...
 
bool ola::StringBeginsWith (const std::string &s, const std::string &prefix)
 Check if one string is a prefix of another. More...
 
bool ola::StringEndsWith (const std::string &s, const std::string &suffix)
 Check if one string is a suffix of another. More...
 
bool ola::StripPrefix (std::string *s, const std::string &prefix)
 Strips a prefix from a string. More...
 
bool ola::StripSuffix (std::string *s, const std::string &suffix)
 Strips a suffix from a string. More...
 
std::string ola::IntToString (int i)
 Convert an int to a string. More...
 
std::string ola::IntToString (unsigned int i)
 
string ola::IntToHexString (unsigned int i, unsigned int width)
 
std::string ola::IntToHexString (uint8_t i)
 
std::string ola::IntToHexString (uint16_t i)
 
std::string ola::IntToHexString (uint32_t i)
 
void ola::Escape (std::string *original)
 Escape a string with \ . More...
 
string ola::EscapeString (const std::string &original)
 Escape a string, returning a copy. More...
 
void ola::ReplaceAll (std::string *original, const std::string &find, const std::string &replace)
 Replace all instances of the find string with the replace string. More...
 
string ola::EncodeString (const std::string &original)
 Encode any unprintable characters in a string as hex, returning a copy. More...
 
bool ola::StringToBool (const std::string &value, bool *output)
 Convert a string to a bool. More...
 
bool ola::StringToBoolTolerant (const std::string &value, bool *output)
 Convert a string to a bool in a tolerant way. More...
 
bool ola::StringToInt (const std::string &value, unsigned int *output, bool strict=false)
 Convert a string to a unsigned int. More...
 
bool ola::StringToInt (const std::string &value, uint16_t *output, bool strict=false)
 Convert a string to a uint16_t. More...
 
bool ola::StringToInt (const std::string &value, uint8_t *output, bool strict=false)
 Convert a string to a uint8_t. More...
 
bool ola::StringToInt (const std::string &value, int *output, bool strict=false)
 Convert a string to a int. More...
 
bool ola::StringToInt (const std::string &value, int16_t *output, bool strict=false)
 Convert a string to a int16_t. More...
 
bool ola::StringToInt (const std::string &value, int8_t *output, bool strict=false)
 Convert a string to a int8_t. More...
 
template<typename int_type >
int_type ola::StringToIntOrDefault (const std::string &value, int_type alternative, bool strict=false)
 Convert a string to an int type or return a default if it failed. More...
 
bool ola::HexStringToInt (const std::string &value, uint8_t *output)
 Convert a hex string to a uint8_t. More...
 
bool ola::HexStringToInt (const std::string &value, uint16_t *output)
 Convert a hex string to a uint16_t. More...
 
bool ola::HexStringToInt (const std::string &value, uint32_t *output)
 Convert a hex string to a uint32_t. More...
 
bool ola::HexStringToInt (const std::string &value, int8_t *output)
 Convert a hex string to a int8_t. More...
 
bool ola::HexStringToInt (const std::string &value, int16_t *output)
 Convert a hex string to a int16_t. More...
 
bool ola::HexStringToInt (const std::string &value, int32_t *output)
 Convert a hex string to a int32_t. More...
 
void ola::ToLower (std::string *s)
 Convert a string to lower case. More...
 
void ola::ToUpper (std::string *s)
 Convert a string to upper case. More...
 
void ola::CapitalizeLabel (std::string *s)
 Transform a string to a pretty-printed form. More...
 
void ola::CustomCapitalizeLabel (std::string *s)
 Similar to CapitalizeLabel() but this also capitalized known acronyms. More...
 
void ola::CapitalizeFirst (std::string *s)
 Transform a string by capitalizing the first character. More...
 
void ola::FormatData (std::ostream *out, const uint8_t *data, unsigned int length, unsigned int indent=0, unsigned int byte_per_line=8)
 Write binary data to an ostream in a human readable form. More...
 
template<typename int_type >
bool ola::PrefixedHexStringToInt (const std::string &input, int_type *output)
 Convert a hex string, prefixed with 0x or 0X to an int type.
 
template<typename T >
std::string ola::StringJoin (const std::string &delim, const T &input)
 Join a vector of a type. More...