9 #ifndef MRPT_STRING_UTILS_H 10 #define MRPT_STRING_UTILS_H 30 char*
strtok(
char* str,
const char* strDelimit,
char** context) noexcept;
49 std::deque<std::string>& outTokens,
bool skipBlankTokens =
true) noexcept;
52 const
std::
string& inString, const
std::
string& inDelimiters,
53 std::vector<
std::
string>& outTokens,
bool skipBlankTokens = true) noexcept;
92 const
double val,
int nDecimalDigits = 2,
bool middle_space = true);
96 const
std::
string& str, const
size_t total_len,
97 bool truncate_if_larger = false);
100 bool strCmp(const
std::
string& s1, const
std::
string& s2);
116 template <typename T>
121 for (; it != V.end();)
125 if (it != V.end()) ret +=
",";
135 template <
typename T>
138 std::stringstream sin;
146 template <
typename T>
149 std::stringstream sin;
std::vector< uint8_t > vector_byte
bool strStartsI(const std::string &str, const std::string &subStr)
Return true if "str" starts with "subStr" (case insensitive)
void encodeBase64(const vector_byte &inputData, std::string &outString)
Encode a sequence of bytes as a string in base-64.
bool strCmp(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case sensitive)
const Scalar * const_iterator
void encodeUTF8(const vector_word &input, std::string &output)
Encodes a 2-bytes UNICODE string into a UTF-8 string.
void decodeUTF8(const std::string &strUTF8, vector_word &out_uniStr)
Decodes a UTF-8 string into an UNICODE string.
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
char * strtok(char *str, const char *strDelimit, char **context) noexcept
An OS-independent method for tokenizing a string.
bool decodeBase64(const std::string &inString, vector_byte &outData)
Decode a base-64 string into the original sequence of bytes.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
void tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string unitsFormat(const double val, int nDecimalDigits=2, bool middle_space=true)
This function implements formatting with the appropriate SI metric unit prefix: 1e-12->'p', 1e-9->'n', 1e-6->'u', 1e-3->'m', 1->'', 1e3->'K', 1e6->'M', 1e9->'G', 1e12->'T'.
std::vector< uint16_t > vector_word
T str2num(std::string const &value)
Original code snippet found in http://stackoverflow.com/a/30357710.
std::string upperCase(const std::string &str)
Returns a upper-case version of a string.
GLenum GLenum GLenum input
bool strStarts(const std::string &str, const std::string &subStr)
Return true if "str" starts with "subStr" (case sensitive)
std::string num2str(T const &value)
Convert number instance to string.
std::string trim(const std::string &str)
Removes leading and trailing spaces.
std::string rightPad(const std::string &str, const size_t total_len, bool truncate_if_larger=false)
Enlarge the string with spaces up to the given length.
GLsizei const GLfloat * value
bool strCmpI(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case insensitive)
std::string sprintf_container(const char *fmt, const T &V)
Generates a string for a container in the format [A,B,C,...], and the fmt string for each vector elem...