31 outStr.begin(), outStr.end(),
33 (int (*)(int))tolower);
44 outStr.begin(), outStr.end(),
46 (int (*)(int))toupper);
58 #define MASK2BYTES 0xC0 59 #define MASK3BYTES 0xE0 60 #define MASK4BYTES 0xF0 61 #define MASK5BYTES 0xF8 62 #define MASK6BYTES 0xFC 68 output.reserve(
input.size());
69 for (
unsigned short i :
input)
102 output.reserve(
input.size());
103 for (
size_t i = 0; i <
input.size();)
126 output.push_back(ch);
137 const double val,
int nDecimalDigits,
bool middle_space)
141 const double aVal = std::abs(
val);
148 else if (aVal >= 1e9)
153 else if (aVal >= 1e6)
158 else if (aVal >= 1e3)
168 else if (aVal >= 1e-3)
173 else if (aVal >= 1e-6)
178 else if (aVal >= 1e-9)
190 middle_space ?
"%.*f %c" :
"%.*f%c", nDecimalDigits,
val * mult,
198 char* str,
const char* strDelimit,
char** context) noexcept
200 #if defined(_MSC_VER) && (_MSC_VER >= 1400) 202 return ::strtok_s(str, strDelimit, context);
206 return ::strtok_r(str, strDelimit, context);
214 template <
class CONTAINER>
217 CONTAINER& outTokens,
bool skipBlankTokens) noexcept
221 const size_t len = inString.size();
222 bool prev_was_delim =
true;
224 for (
size_t pos = 0; pos <=
len; pos++)
237 cur_is_delim = (inDelimiters.find(
c) != string::npos);
243 if (!skipBlankTokens) outTokens.push_back(
std::string());
247 outTokens.push_back(cur_token);
253 cur_token.push_back(
c);
255 prev_was_delim = cur_is_delim;
260 template void mrpt::system::tokenize<std::deque<std::string>>(
262 std::deque<std::string>& outTokens,
bool skipBlankTokens) noexcept;
263 template void mrpt::system::tokenize<std::vector<std::string>>(
265 std::vector<std::string>& outTokens,
bool skipBlankTokens) noexcept;
278 size_t s = str.find_first_not_of(
" \t");
279 size_t e = str.find_last_not_of(
" \t");
280 if (
s == std::string::npos || e == std::string::npos)
283 return str.substr(
s, e -
s + 1);
291 const std::string& str,
const size_t total_len,
bool truncate_if_larger)
294 if (
r.size() < total_len || truncate_if_larger)
r.resize(total_len,
' ');
315 s1.c_str(), s2.c_str(),
324 s1.c_str(), s2.c_str(),
328 template <
typename STRING_LIST>
332 const size_t lenNL = newline.size();
335 size_t totalLen = lst.size() * lenNL;
336 for (
const auto&
s : lst) totalLen +=
s.size();
338 outText.resize(totalLen);
342 for (
const auto&
s : lst)
345 &outText[curPos], totalLen,
s.c_str(),
s.size());
347 for (
const auto& sNL : newline) outText[curPos++] = sNL;
352 const std::vector<std::string>& lst,
std::string& outText,
359 const std::deque<std::string>& lst,
std::string& outText,
unsigned __int16 uint16_t
int _strncmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strncmp.
bool strStartsI(const std::string &str, const std::string &subStr)
Return true if "str" starts with "subStr" (case insensitive)
int _strnicmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strnicmp.
void decodeUTF8(const std::string &strUTF8, std::vector< uint16_t > &out_uniStr)
Decodes a UTF-8 string into an UNICODE string.
bool strCmp(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case sensitive)
void stringListAsString(const std::vector< std::string > &lst, std::string &out, const std::string &newline="\")
Convert a string list to one single string with new-lines.
void encodeUTF8(const std::vector< uint16_t > &input, std::string &output)
Encodes a 2-bytes UNICODE string into a UTF-8 string.
void tokenize(const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
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.
GLsizei const GLchar ** string
GLdouble GLdouble GLdouble r
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::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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 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.
GLuint GLenum GLenum transform
static void impl_stringListAsString(const STRING_LIST &lst, std::string &outText, const std::string &newline)
bool strCmpI(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case insensitive)
int _strcmp(const char *str1, const char *str2) noexcept
An OS-independent version of strcmp.
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
int _strcmpi(const char *str1, const char *str2) noexcept
An OS-independent version of strcmpi.