18#ifndef __FPSDK_COMMON_STRING_HPP__
19#define __FPSDK_COMMON_STRING_HPP__
46# define PRINTF_ATTR(n) __attribute__((format(printf, n, n + 1)))
67std::
string Vsprintf(const
char* fmt, va_list args);
78std::
string Strftime(const
char* const fmt, const int64_t ts = 0, const
bool utc = false);
90int StrReplace(std::
string& str, const std::
string& search, const std::
string& replace, const
int max = 0);
130std::vector<std::
string>
StrSplit(const std::
string& str, const std::
string& sep, const
int maxNum = 0);
140std::
string StrJoin(const std::vector<std::
string>& strs, const std::
string& sep);
151 const std::vector<std::
string>& strs, std::function<std::
string(const std::
string&)> map);
167std::vector<std::
string>
HexDump(const std::vector<uint8_t> data);
177std::vector<std::
string>
HexDump(const uint8_t* data, const std::
size_t size);
197bool StrEndsWith(const std::
string& str, const std::
string& suffix);
std::string Vsprintf(const char *fmt, va_list args)
Format string.
std::string Strftime(const char *const fmt, const int64_t ts=0, const bool utc=false)
Format time.
void StrTrimLeft(std::string &str)
Trim string left.
std::vector< std::string > StrSplit(const std::string &str, const std::string &sep, const int maxNum=0)
Split string.
std::string StrToUpper(const std::string &str)
Convert string to all upper case.
std::vector< std::string > HexDump(const std::vector< uint8_t > data)
Format hexdump of data.
void StrTrimRight(std::string &str)
Trim string right.
std::vector< std::string > StrMap(const std::vector< std::string > &strs, std::function< std::string(const std::string &)> map)
Map strings.
void StrTrim(std::string &str)
Trim string left and right.
std::string StrToLower(const std::string &str)
Convert string to all lower case.
bool StrToValue(const std::string &str, int8_t &value)
Convert string to value (int8_t)
bool StrEndsWith(const std::string &str, const std::string &suffix)
Check if one string ends with another string.
bool StrContains(const std::string &str, const std::string &sub)
Check if one string is contained within another string string.
std::string Sprintf(const char *const fmt,...) PRINTF_ATTR(1)
Format string.
bool StrStartsWith(const std::string &str, const std::string &prefix)
Check if one string starts with another string.
std::string StrJoin(const std::vector< std::string > &strs, const std::string &sep)
Join strings.
int StrReplace(std::string &str, const std::string &search, const std::string &replace, const int max=0)
Search and replace.
void MakeUnique(std::vector< std::string > &strs)
Remove duplicates.
#define PRINTF_ATTR(n)
Helper macro for marking functions as taking printf() style formatting strings.