C++ Utilities. More...
Classes | |
class | Socket |
TCP/IP or UDP/Datagram socket. More... | |
class | ServerSocket |
TCP/IP server socket. More... | |
class | SocketBuffer |
Preserves record boundaries when exchanging messages between connected TCP/IP sockets. More... | |
struct | strdelim |
Delimiters for strsplit(), regsplit(), strtoken() and strtrim(). More... | |
class | stringset |
Set of strings, allows converting strings to numbers. More... | |
class | istringset |
Indexed set of strings, allows converting strings to numbers and vice-versa. More... | |
class | MacDesktop |
Class for managing the MacOSX desktop. More... | |
Functions | |
std::string | basename (const std::string &path, bool with_extension=true) |
Returns filename component of path. More... | |
std::string | dirname (const std::string &path) |
Returns directory component of path. | |
std::string | dirslashed (const std::string &path) |
Adds a final / to a path if not already the case. | |
std::string | extname (const std::string &path, bool with_dot=true) |
Returns extension of path. More... | |
std::string | change_extname (const std::string &path, const std::string &ext) |
Changes the extension of the pathname (ext must start with a dot or be empty). | |
std::string | join_paths (const std::string &left, const std::string &right) |
Creates a new path from 2 paths. | |
constexpr unsigned long long | 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 | 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 | 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 | strsplit (std::string &left, std::string &right, const std::string &str, ccuty::strdelim delimiters) |
Splits a string into two tokens. More... | |
size_t | 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 | strtoken (std::string &token, const std::string &str, ccuty::strdelim &delimiters) |
Retrieves the next token in a string. More... | |
void | strtrim (std::string &str, ccuty::strdelim toremove) |
Removes beginning and trailing characters. More... | |
void | strtrim (std::string &str) |
Removes beginning and trailing whitespaces. | |
void | unquote (std::string &str) |
Removes beginning/trailing quotes and whitespaces. | |
std::string | trimmed (const std::string &str) |
Returns a copy without beginning and trailing spaces. | |
std::string | unquoted (const std::string &str) |
Returns a copy without beginning/trailing quotes and whitespaces. | |
int | icompare (const std::string &a, const std::string &b) |
Compares two ASCII strings ignoring case (relies on tolower(int)). | |
bool | iequal (const std::string &str1, const std::string &str2) |
Compares two ASCII strings ignoring case (relies on tolower(int)). | |
void | lowerize (std::string &str) |
Lowercases an ASCII string (relies on tolower(int)). | |
void | upperize (std::string &str) |
Uppercases an ASCII string (relies on tolower(int)). | |
std::string | tolower (const std::string &str) |
Returns an lowercased copy of an ASCII string (relies on toupper(int)). | |
std::string | toupper (const std::string &str) |
Returns an uppercased copy of an ASCII string (relies on tolower(int)). | |
bool | from_string (bool &var, const std::string &str) |
Converts string to bool (returns true if the value could be successfully converted). | |
bool | from_string (long &var, const std::string &str) |
Converts string to long (returns true if the value could be successfully converted). | |
bool | from_string (unsigned long &var, const std::string &str) |
Converts string to unsigned long (returns true if the value could be successfully converted). | |
bool | from_string (float &var, const std::string &str) |
Converts string to float (returns true if the value could be successfully converted). | |
bool | from_string (double &var, const std::string &str) |
Converts string to double (returns true if the value could be successfully converted). | |
bool | from_string (long double &var, const std::string &str) |
Converts string to long double (returns true if the value could be successfully converted). | |
int | system (const std::string &command) |
Calls the C system() function. | |
C++ Utilities.
|
inline |
Returns filename component of path.
Keeps filename extension if with_extension is true.
|
inline |
Returns extension of path.
Keeps dot between extension if with_dot is true.
|
inline |
Returns a numeric ID from last characters that can be used in switch
blocks.
The returned ID relies on the last 8 characters of the string (or on the last 8 characters up to the last position if last is provided). Because this function is a constexpr
, it is computed at compile time and can be used in switch
blocks.
Example:
|
inline |
Returns a numeric ID from last characters that can be used in switch
blocks.
|
inline |
Splits a string into a vector of tokens.
Splits str into tokens that are stored in tokens. If greater than 0, limit is the maximum number of tokens and the last token contains the remaining text. delimiters specifies the delimiters. All whitespaces match if delimiters is the empty string. By default, the tokens are trimmed. See ccuty::strdelim for more options.
|
inline |
Splits a string into two tokens.
Works as ccuty::strsplit() except that this function splits str into two tokens that are stored in left and right.
|
inline |
Splits a string into a vector of tokens using a regex
.
Works as ccuty::strsplit() except that the delimiter is a regex
.
|
inline |
Retrieves the next token in a string.
Retrieves the next token token in string str. delimiters specifies the delimiters. All whitespaces match if delimiters is the empty string.
|
inline |
Removes beginning and trailing characters.
Removes beginning and trailing characters that belongs to toremove. Removes all whitespaces if toremove is the empty string.