33 outStr.begin(), outStr.end(),
35 (int(*)(int)) tolower );
46 outStr.begin(), outStr.end(),
48 (int(*)(int)) toupper );
60 #define MASK2BYTES 0xC0 61 #define MASK3BYTES 0xE0 62 #define MASK4BYTES 0xF0 63 #define MASK5BYTES 0xF8 64 #define MASK6BYTES 0xFC 69 output.reserve(
input.size() );
70 for(
size_t i=0; i <
input.size(); i++)
75 output += (char)
input[i];
78 else if(
input[i] < 0x800)
102 output.reserve(
input.size() );
103 for(
size_t i=0; i <
input.size();)
110 ch = ((
input[i] & 0x0F) << 12) | (
127 output.push_back(ch);
141 const double aVal = std::abs(
val);
144 {mult=1e-12; prefix=
'T';}
146 {mult=1e-9; prefix=
'G';}
148 {mult=1e-6; prefix=
'M';}
150 {mult=1e-3; prefix=
'K';}
152 {mult=1; prefix=
' ';}
153 else if (aVal >=1e-3)
154 {mult=1e+3; prefix=
'm';}
155 else if (aVal >=1e-6)
156 {mult=1e+6; prefix=
'u';}
157 else if (aVal >=1e-9)
158 {mult=1e+9; prefix=
'n';}
160 {mult=1e+12; prefix=
'p';}
163 middle_space ?
"%.*f %c" :
"%.*f%c",
174 #if defined(_MSC_VER) && (_MSC_VER>=1400) 176 return ::strtok_s(str,strDelimit,context);
180 return ::strtok_r(str,strDelimit,context);
188 template <
class CONTAINER>
192 CONTAINER &outTokens,
197 const size_t len = inString.size();
198 bool prev_was_delim =
true;
200 for (
size_t pos=0; pos<=
len ; pos++)
212 cur_is_delim = (inDelimiters.find(
c)!=string::npos);
216 if (prev_was_delim) {
217 if (!skipBlankTokens)
221 outTokens.push_back( cur_token );
225 cur_token.push_back(
c);
227 prev_was_delim = cur_is_delim;
234 std::deque<std::string> &outTokens,
237 my_tokenize(inString,inDelimiters,outTokens,skipBlankTokens);
243 std::vector<std::string> &outTokens,
246 my_tokenize(inString,inDelimiters,outTokens,skipBlankTokens);
260 size_t s = str.find_first_not_of(
" \t");
261 size_t e = str.find_last_not_of(
" \t");
262 if (
s==std::string::npos || e==std::string::npos)
264 else return str.substr(
s, e-
s+1);
274 if (
r.size()<total_len || truncate_if_larger)
275 r.resize(total_len,
' ');
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
unsigned __int16 uint16_t
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
bool BASE_IMPEXP strStartsI(const std::string &str, const std::string &subStr)
Return true if "str" starts with "subStr" (case insensitive)
#define MRPT_NO_THROWS
C++11 noexcept: Used after member declarations.
bool BASE_IMPEXP strCmp(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case sensitive)
void BASE_IMPEXP encodeUTF8(const vector_word &input, std::string &output)
Encodes a 2-bytes UNICODE string into a UTF-8 string.
void BASE_IMPEXP decodeUTF8(const std::string &strUTF8, vector_word &out_uniStr)
Decodes a UTF-8 string into an UNICODE string.
std::string BASE_IMPEXP lowerCase(const std::string &str)
Returns an lower-case version of a string.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
std::string BASE_IMPEXP 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
int BASE_IMPEXP _strcmpi(const char *str1, const char *str2) MRPT_NO_THROWS
An OS-independent version of strcmpi.
void my_tokenize(const std::string &inString, const std::string &inDelimiters, CONTAINER &outTokens, bool skipBlankTokens) MRPT_NO_THROWS
std::string BASE_IMPEXP upperCase(const std::string &str)
Returns a upper-case version of a string.
GLenum GLenum GLenum input
bool BASE_IMPEXP strStarts(const std::string &str, const std::string &subStr)
Return true if "str" starts with "subStr" (case sensitive)
std::string BASE_IMPEXP trim(const std::string &str)
Removes leading and trailing spaces.
std::string BASE_IMPEXP 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
int BASE_IMPEXP _strcmp(const char *str1, const char *str2) MRPT_NO_THROWS
An OS-independent version of strcmp.
bool BASE_IMPEXP strCmpI(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case insensitive)
void BASE_IMPEXP tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
Tokenizes a string according to a set of delimiting characters.
int BASE_IMPEXP _strnicmp(const char *str, const char *subStr, size_t count) MRPT_NO_THROWS
An OS-independent version of strnicmp.
char BASE_IMPEXP * strtok(char *str, const char *strDelimit, char **context) MRPT_NO_THROWS
An OS-independent method for tokenizing a string.
int BASE_IMPEXP _strncmp(const char *str, const char *subStr, size_t count) MRPT_NO_THROWS
An OS-independent version of strncmp.