ccuty  1.0
 All Classes Namespaces Files Functions Enumerations Macros Pages
Classes | Namespaces | Constant Groups | Functions
ccstring.hpp File Reference

Useful functions for C++ strings (trim, split, trimsplit, icompare, tolower, etc.) More...

Go to the source code of this file.

Classes

struct  ccuty::strdelim
 Delimiters for strsplit(), regsplit(), strtoken() and strtrim(). More...
 

Namespaces

 ccuty
 C++ Utilities.
 

Constant Groups

 ccuty
 C++ Utilities.
 

Functions

constexpr unsigned long long ccuty::strid (const char *str, int last=32767, unsigned long long id=0)
 Returns a numeric ID from last characters that can be used in switch blocks. More...
 
unsigned long long ccuty::strid (const std::string &str, int last=32767)
 Returns a numeric ID from last characters that can be used in switch blocks. More...
 
size_t ccuty::strsplit (std::vector< std::string > &tokens, const std::string &str, ccuty::strdelim delimiters, int limit=0)
 Splits a string into a vector of tokens. More...
 
size_t ccuty::strsplit (std::string &left, std::string &right, const std::string &str, ccuty::strdelim delimiters)
 Splits a string into two tokens. More...
 
size_t ccuty::regsplit (std::vector< std::string > &tokens, const std::string &str, ccuty::strdelim delimiters, int limit=0)
 Splits a string into a vector of tokens using a regex. More...
 
bool ccuty::strtoken (std::string &token, const std::string &str, ccuty::strdelim &delimiters)
 Retrieves the next token in a string. More...
 
void ccuty::strtrim (std::string &str, ccuty::strdelim toremove)
 Removes beginning and trailing characters. More...
 
void ccuty::strtrim (std::string &str)
 Removes beginning and trailing whitespaces.
 
void ccuty::unquote (std::string &str)
 Removes beginning/trailing quotes and whitespaces.
 
std::string ccuty::trimmed (const std::string &str)
 Returns a copy without beginning and trailing spaces.
 
std::string ccuty::unquoted (const std::string &str)
 Returns a copy without beginning/trailing quotes and whitespaces.
 
int ccuty::icompare (const std::string &a, const std::string &b)
 Compares two ASCII strings ignoring case (relies on tolower(int)).
 
bool ccuty::iequal (const std::string &str1, const std::string &str2)
 Compares two ASCII strings ignoring case (relies on tolower(int)).
 
void ccuty::lowerize (std::string &str)
 Lowercases an ASCII string (relies on tolower(int)).
 
void ccuty::upperize (std::string &str)
 Uppercases an ASCII string (relies on tolower(int)).
 
std::string ccuty::tolower (const std::string &str)
 Returns an lowercased copy of an ASCII string (relies on toupper(int)).
 
std::string ccuty::toupper (const std::string &str)
 Returns an uppercased copy of an ASCII string (relies on tolower(int)).
 
bool ccuty::from_string (bool &var, const std::string &str)
 Converts string to bool (returns true if the value could be successfully converted).
 
bool ccuty::from_string (long &var, const std::string &str)
 Converts string to long (returns true if the value could be successfully converted).
 
bool ccuty::from_string (unsigned long &var, const std::string &str)
 Converts string to unsigned long (returns true if the value could be successfully converted).
 
bool ccuty::from_string (float &var, const std::string &str)
 Converts string to float (returns true if the value could be successfully converted).
 
bool ccuty::from_string (double &var, const std::string &str)
 Converts string to double (returns true if the value could be successfully converted).
 
bool ccuty::from_string (long double &var, const std::string &str)
 Converts string to long double (returns true if the value could be successfully converted).
 
int ccuty::system (const std::string &command)
 Calls the C system() function.
 

Detailed Description

Useful functions for C++ strings (trim, split, trimsplit, icompare, tolower, etc.)

Author
Eric Lecolinet 2017 - https://www.telecom-paristech.fr/~elc