#ifndef RADIX_RADIXCORE_STRINGFUNCTIONS_HH_ #define RADIX_RADIXCORE_STRINGFUNCTIONS_HH_ /* * @file: stringfunctions.hh * @author: Jordan P. Lefebvre * * Created on October 23, 2017, 16:34 PM */ #include #include #include #include #include #include "radixcore/visibility.hh" namespace radix { /** * @brief ordinal convert character to its ordinal value * @param c char * @return integer */ int ordinal(char c); /** * @brief itoa converts integer into character * @param number integer must be within character bounds * @return char */ template char itoa(type number); /** * @brief utc_to_time UTC time to * @param time UTC formatted date and time * @param zone time zone * @param daylight daylight savings * @return struct tm */ struct std::tm RADIX_PUBLIC utc_to_time(const std::string &time, int &zone, int &daylight); /** * Convert a string to lowercase * @param the string to be converted */ std::string RADIX_PUBLIC string_tolower(const std::string &data); /** * Convert a string to uppercase * @param the string to be converted */ std::string RADIX_PUBLIC string_toupper(const std::string &data); /** * trim a leading and trailing whitespace * @param the string to be converted */ std::string RADIX_PUBLIC trim_string(const std::string &data); /** * @brief Remove double- and single- quotes from the string */ std::string RADIX_PUBLIC strip_quotes(const std::string &src); /** * @brief Convert something to a string. */ template std::string RADIX_PUBLIC to_string(const T &x, int prec = 6); /** * @brief Convert something from a string using stream idioms. */ template T RADIX_PUBLIC from_string(const std::string &val, const T &defVal); /** * @brief Join something like a vector to a single string with delimiter */ template std::string RADIX_PUBLIC join(const std::string &delim, const T &x); /** * @brief Split a string into pieces using a delimiter */ std::vector RADIX_PUBLIC split_string(const std::string &delim, const std::string &word); /** * @brief Find all instances and replace them */ std::string RADIX_PUBLIC find_and_replace(const std::string &str, const std::string &find, const std::string &replace); /** * @brief remove a particular substring (multiple times) from a target string */ std::string RADIX_PUBLIC remove_substring(const char *msg, const char *sub); /** * @brief remove extra whitespace (\t-->' ', \n-->' ', ' '-->' ') */ std::string RADIX_PUBLIC remove_extra_whitespace(const std::string &str); } // namespace radix //! Templated functions #include "stringfunctions.i.hh" #endif /** RADIX_RADIXCORE_STRINGFUNCTIONS_HH_ */