49 #if VL_STRING_COPY_ON_WRITE == 0 61 #if VL_STRING_COPY_ON_WRITE == 0 70 #if VL_STRING_COPY_ON_WRITE == 0 79 #if VL_STRING_COPY_ON_WRITE == 0 82 for(
int i=0; i<
count; ++i)
100 std::vector<char> buffer;
101 file->
load( buffer );
106 return loadText( &buffer[0], (
int)buffer.size(), default_encoding );
127 return fromUTF8((
char*)data, bytes);
136 Log::error(
"String::loadText() unknown encoding.\n");
140 Log::error(
"String::loadText() SE_UTF32_BE/SE_UTF32_LE encoding not supported.\n");
149 mString->resize(character_count);
163 int end_idx = start+count-1;
164 if (end_idx >
length()-1 )
169 int sz = end_idx - start + 1;
170 sz = sz < 0 ? 0 : sz;
171 str.mString->resize( sz );
172 for(
int i=0; i<(int)str.mString->length(); ++i)
173 (*str.mString)[i] = (*mString)[start+i];
183 for(
int i=
length(); i--; )
184 if ((*mString)[i] == ch)
200 for(; j<str.
length(); ++j)
202 if ( str[j] != (*mString)[i+j] )
214 return find(ch) != -1;
223 for(
int i=start; i<
length(); ++i)
224 if ((*mString)[i] == ch)
231 return find(substr) != -1;
237 int String_Quick_Search(
const wchar_t*x,
int m,
const wchar_t*y,
int n)
240 for (
int i = 0; i < 0x10000; ++i)
242 for (
int i = 0; i < m; ++i)
244 for(
int j=0; j <= n - m; j += qsBc[y[j + m]] )
245 if (memcmp(x, y + j, m*
sizeof(
wchar_t)) == 0)
260 int pos = String_Quick_Search( &(*substr.mString)[0], substr.
length(), &(*mString)[0]+start,
length()-start );
261 return pos >= 0 ? pos + start : pos;
275 for(
int i=start; i<=
max; ++i)
278 for(; j<substr.
length(); ++j)
280 if (substr[j] != (*mString)[i+j])
302 for(
int i=0; i<
length(); ++i)
314 for(
int i=0; i<chars.
length(); ++i)
329 while( (*mString)[pos] == ch )
334 while( pos >=0 && (*mString)[pos] == ch )
362 fields.push_back(
String() );
363 fields.back().acquireData();
364 fields.back().mString->clear();
365 for(
int i=0; i<
length(); ++i)
367 if ( separator_list.
contains((*mString)[i]) )
369 fields.push_back(
String() );
370 fields.back().acquireData();
371 fields.back().mString->clear();
374 fields.back().mString->push_back( (*mString)[i] );
380 for (
size_t i=fields.size(); i--; )
381 if (fields[i].
empty())
382 fields.erase(fields.begin() + i);
386 void String::split(
wchar_t separator, std::vector<String>& fields,
bool remove_empty)
const 396 fields.push_back(
String() );
397 fields.back().acquireData();
398 fields.back().mString->clear();
399 for(
int i=0; i<
length(); ++i)
401 if ((*mString)[i] == separator)
403 fields.push_back(
String() );
404 fields.back().acquireData();
405 fields.back().mString->clear();
408 fields.back().mString->push_back( (*mString)[i] );
414 for (
size_t i=fields.size(); i--; )
415 if (fields[i].
empty())
416 fields.erase(fields.begin() + i);
430 lines.push_back(
String() );
431 lines.back().acquireData();
432 lines.back().mString->clear();
433 for(
int i=0; i<
length(); ++i)
435 if ((*mString)[i] ==
'\n' || (*mString)[i] ==
'\r')
437 lines.push_back(
String() );
438 lines.back().acquireData();
439 lines.back().mString->clear();
441 if ((*mString)[i] ==
'\n' && (*mString)[i+1] ==
'\r')
444 if ((*mString)[i] ==
'\r' && (*mString)[i+1] ==
'\n')
448 lines.back().mString->push_back( (*mString)[i] );
458 for(; i<
length() && field_count<field_index; ++i)
460 if ( (*
this)[i] == separator )
464 for(; i<
length() && (*this)[i] != separator; ++i)
478 for(
int pos =
find(str, start); pos != -1 && removed<
count; start=pos, pos=
find(str, start), ++removed)
479 remove( pos, str.
length() );
492 tmp.mString->clear();
493 int end = start + count-1;
494 for(
int i=0; i<
length(); i++ )
495 if (i<start || i>end)
496 tmp.mString->push_back((*mString)[i]);
498 mString = tmp.mString;
512 for(
int i=0; i<tmp.
length(); ++i)
513 if ( tmp[i]!=ch || removed==count || i<start)
514 mString->push_back( tmp[i] );
525 for(
int i=0; i<
count; ++i)
527 wchar_t tmp = (*this)[i];
528 (*this)[i] = (*this)[
length() - 1 - i];
529 (*this)[
length() - 1 - i] = tmp;
552 std::vector<String> parts;
553 split(
'/', parts,
true);
554 std::vector<String> new_parts;
555 for(
size_t i=0; i<parts.size(); ++i)
560 if (parts[i] ==
".." && !new_parts.empty())
562 new_parts.pop_back();
566 new_parts.push_back(parts[i]);
575 for(
size_t i=0; i<new_parts.size(); ++i)
577 *
this += new_parts[i];
578 if(i != new_parts.size()-1)
592 for(
int i=0; i<
count; ++i)
593 mString->push_back(ch);
601 for(
int i=0; i<other.
length(); ++i)
602 mString->push_back(other[i]);
613 return insert(0, ch, count);
618 remove(start,
count);
629 std::vector<int> positions;
630 for(
int pos = 0; (pos=supstr.
find(substr,pos)) != -1; pos += substr.
length() )
631 positions.push_back(pos);
634 for(
unsigned i=(
unsigned)positions.size(); i--; )
648 int end = start +
count;
651 for(
int i=start; i<end; ++i)
660 for(
int i=0; i<
length(); ++i)
661 if ((*mString)[i] == old_ch)
662 (*mString)[i] = new_ch;
673 for(
int i=start; i<
length(); ++i)
674 if ((*mString)[i] == ch)
686 for(
int pos =
find(str, start); pos != -1; start=pos+str.
length(), pos=
find(str, start))
696 for(
int i=0; i<
min; ++i)
698 if ( (*mString)[i] != (*other.mString)[i] )
699 return (
int)(*mString)[i] - (int)(*other.mString)[i];
716 return memcmp( &(*mString)[0] + offset, &(*str.mString)[0],
sizeof((*mString)[0])*str.
length() ) == 0;
733 return memcmp( &(*mString)[0], &(*str.mString)[0],
sizeof((*mString)[0])*str.
length() ) == 0;
752 return length() > 0 && (*mString)[0] == ch;
763 for(
int i=0; i<
length(); ++i)
764 (*lower.mString)[i] =
getLowerCase( (*lower.mString)[i] );
776 for(
int i=0; i<
length(); ++i)
777 (*lower.mString)[i] =
getUpperCase( (*lower.mString)[i] );
790 int remaining =
length() - pos;
791 mString->resize( mString->length() + str.
length() );
792 memmove( &(*mString)[0]+pos+str.
length(), &(*mString)[0]+pos,
sizeof(str[0])*remaining );
793 memcpy( &(*mString)[0]+pos, &(*str.mString)[0],
sizeof(str[0])*str.
length() );
806 int remaining =
length() - pos;
807 mString->resize( mString->length() +
count );
808 memmove( &(*mString)[0]+pos+count, &(*mString)[0]+pos,
sizeof((*mString)[0])*remaining );
809 for(
int i=0; i<count && i+pos<
length(); ++i)
810 (*mString)[i+pos] = ch;
853 int slash_pos = a > b ? a : b;
864 if (require_dot && dot_pos == -1)
876 for(
int i=0; i<(int)str.length(); ++i)
877 s.mString->push_back( str[i] );
884 return fromUTF8( str.c_str(), (int)str.length());
895 size = (int)strlen(str);
896 const unsigned char* ascii = (
const unsigned char*)str;
898 for(
int i=0; i<size; ++i)
901 s.mString->push_back( ascii[i] );
904 s.mString->push_back( L
'?' );
916 int character_count = byte_count < 0 ? -1 : byte_count / 2;
919 if (character_count<0)
920 for(character_count=0; str[character_count]; ) ++character_count;
930 for(
int i=0; i<character_count; ++i)
932 const unsigned char* bytes = (
const unsigned char*)(str+i);
933 unsigned int code = bytes[1] + (bytes[0]<<8);
935 if (code>=0xD800 && code <=0xDC00)
937 s.mString->push_back(
'?' );
941 s.mString->push_back( (
wchar_t)code );
952 int character_count = byte_count < 0 ? -1 : byte_count / 2;
955 if (character_count<0)
956 for(character_count=0; str[character_count]; ) ++character_count;
966 for(
int i=0; i<character_count; ++i)
968 unsigned char* bytes = (
unsigned char*)(str+i);
969 unsigned int code = bytes[0] + (bytes[1]<<8);
971 if (code>=0xD800 && code <=0xDC00)
973 s.mString->push_back(
'?' );
977 s.mString->push_back( (
wchar_t)code );
994 Log::error(
"String::fromUTF16(): not UTF16 BE nor LE found.\n");
1005 unsigned char* utf8 = (
unsigned char*)str;
1008 if ( utf8[0] == 0xEF && utf8[1] == 0xBB && utf8[2] == 0xBF )
1012 for(byte_count=0; utf8[byte_count]; ) ++byte_count;
1015 const int UTF8_1BYTE = 128;
1016 const int UTF8_2BYTE = 128+64;
1017 const int UTF8_3BYTE = 128+64+32;
1018 const int UTF8_4BYTE = 128+64+32+16;
1020 for(
int i=start; i<byte_count; ++i )
1028 unsigned int unicode_code_point = 0;
1029 if (utf8[i] < UTF8_1BYTE)
1030 unicode_code_point = utf8[i];
1032 if ( (utf8[i] & UTF8_3BYTE) == UTF8_2BYTE )
1034 unicode_code_point = ((utf8[i]-UTF8_2BYTE)<<6) + (utf8[i+1]&0x3f);
1038 if ( (utf8[i] & UTF8_4BYTE) == UTF8_3BYTE )
1040 unicode_code_point = ((utf8[i]-UTF8_3BYTE)<<12) + ((utf8[i+1]&0x3f)<<6) + (utf8[i+2]&0x3f);
1045 unicode_code_point = ((utf8[i]-UTF8_4BYTE)<<18) + ((utf8[i+1]&0x3f)<<12) + ((utf8[i+2]&0x3f)<<6) + (utf8[i+3]&0x3f);
1049 if (unicode_code_point <= 0xFFFF)
1050 s.mString->push_back((
wchar_t)unicode_code_point);
1052 s.mString->push_back(L
'?');
1062 unsigned char* latin1 = (
unsigned char*)str;
1063 if (character_count<0)
1064 for(character_count=0; latin1[character_count]; ) ++character_count;
1067 for(
int i=0; i<character_count; ++i)
1068 s.mString->push_back( latin1_to_unicode[ latin1[i] ] );
1075 memset(buffer, 0,
sizeof(buffer));
1076 sprintf(buffer,
"%p", value);
1083 memset(buffer, 0,
sizeof(buffer));
1084 sprintf(buffer,
"%d", value);
1091 memset(buffer, 0,
sizeof(buffer));
1092 sprintf(buffer,
"%u", value);
1099 memset(buffer, 0,
sizeof(buffer));
1100 sprintf(buffer,
"%lld", value);
1107 memset(buffer, 0,
sizeof(buffer));
1108 sprintf(buffer,
"%llu", value);
1115 memset(buffer, 0,
sizeof(buffer));
1118 case 0: sprintf(buffer,
"%.0lf", value);
break;
1119 case 1: sprintf(buffer,
"%.1lf", value);
break;
1120 case 2: sprintf(buffer,
"%.2lf", value);
break;
1121 case 3: sprintf(buffer,
"%.3lf", value);
break;
1122 case 4: sprintf(buffer,
"%.4lf", value);
break;
1123 case 5: sprintf(buffer,
"%.5lf", value);
break;
1124 case 6: sprintf(buffer,
"%.6lf", value);
break;
1125 case 7: sprintf(buffer,
"%.7lf", value);
break;
1126 case 8: sprintf(buffer,
"%.8lf", value);
break;
1127 case 9: sprintf(buffer,
"%.9lf", value);
break;
1128 case 10: sprintf(buffer,
"%.10lf", value);
break;
1129 case 11: sprintf(buffer,
"%.11lf", value);
break;
1130 case 12: sprintf(buffer,
"%.12lf", value);
break;
1131 case 13: sprintf(buffer,
"%.13lf", value);
break;
1132 case 14: sprintf(buffer,
"%.14lf", value);
break;
1133 case 15: sprintf(buffer,
"%.15lf", value);
break;
1134 case 16: sprintf(buffer,
"%.16lf", value);
break;
1135 case 17: sprintf(buffer,
"%.17lf", value);
break;
1136 case 18: sprintf(buffer,
"%.18lf", value);
break;
1137 case 19: sprintf(buffer,
"%.19lf", value);
break;
1138 case 20: sprintf(buffer,
"%.20lf", value);
break;
1139 default: sprintf(buffer,
"%.6lf", value);
break;
1148 return std::wstring();
1151 for(
int i=0; i<
length(); ++i)
1152 ws += (*mString)[i];
1160 return std::string();
1161 std::string std_string;
1163 std::vector<unsigned char> utf8;
1167 std_string.resize(utf8.size()-1);
1168 memcpy(&std_string[0], &utf8[0], utf8.size()-1);
1184 if (mString->length())
1186 for(
int i=0; i<(int)mString->length() && (*mString)[i]; ++i)
1188 if ( (*mString)[i] < 128 || !translate_non_ascii_chars )
1189 ascii += (
char)((*mString)[i] & 0xFF);
1192 const char* translation = unicode_to_ascii( (*mString)[i] );
1195 for(
int j=0; translation[j]; ++j)
1196 ascii += translation[j];
1208 std::vector<unsigned char> utf8;
1209 toUTF8(utf8, include_utf8_signature);
1213 for(
int i=0; utf8[i]; ++i)
1214 str.push_back(utf8[i]);
1218 void String::toUTF8(std::vector<unsigned char>& utf8,
bool include_utf8_signature)
const 1221 if(include_utf8_signature)
1223 utf8.push_back(0xEF);
1224 utf8.push_back(0xBB);
1225 utf8.push_back(0xBF);
1240 for(
int i=0; i<
length(); ++i)
1242 if ( (*mString)[i] < 0x80)
1243 utf8.push_back( (
unsigned char)(*mString)[i] );
1245 if ( (*mString)[i] < 0x800)
1247 int a = 0xC0 | ((*mString)[i]>>6);
1248 int b = 0x80 | ((*mString)[i]&0x3F);
1249 utf8.push_back( (
unsigned char)a );
1250 utf8.push_back( (
unsigned char)b );
1254 int a = 0xE0 | ((*mString)[i]>>12);
1255 int b = 0x80 | (((*mString)[i]>>6)&0x3F);
1256 int c = 0x80 | ((*mString)[i]&0x3F);
1257 utf8.push_back( (
unsigned char)a );
1258 utf8.push_back( (
unsigned char)b );
1259 utf8.push_back( (
unsigned char)c );
1269 if (include_utf16be_signature)
1271 utf16.push_back(0xFE);
1272 utf16.push_back(0xFF);
1282 for(
int i=0; i<
length(); ++i)
1284 int x = ((*mString)[i]>>8) & 0xFF;
1285 int y = (*mString)[i] & 0xFF;
1286 utf16.push_back( (
unsigned char)x );
1287 utf16.push_back( (
unsigned char)y );
1295 if (include_utf16le_signature)
1297 utf16.push_back(0xFF);
1298 utf16.push_back(0xFE);
1308 for(
int i=0; i<
length(); ++i)
1310 int x = (*mString)[i] & 0xFF;
1311 int y = ((*mString)[i]>>8) & 0xFF;
1312 utf16.push_back( (
unsigned char)x );
1313 utf16.push_back( (
unsigned char)y );
1325 latin1.push_back(0);
1329 for(
int i=0; i<
length(); ++i)
1331 if ((*mString)[i] < 128)
1332 latin1.push_back((
unsigned char)(*mString)[i]);
1337 for(; latin1_to_unicode[j]; ++j)
1339 if ( latin1_to_unicode[j] == (*mString)[i] )
1341 latin1.push_back((
unsigned char)j);
1346 latin1.push_back(
'?');
1349 latin1.push_back(0);
1380 int filter_type = 0;
1381 bool filter_ok = filter.
empty();
1403 if ( filter_type && filter.
length() > 1 )
1405 for(
int i=(
int)strings.size(); i--; )
1408 case 0:
if( strings[i].
find(match) == -1 ) strings.erase( strings.begin() + i );
break;
1409 case -1:
if( !strings[i].
endsWith(match) ) strings.erase( strings.begin() + i );
break;
1410 case +1:
if( !strings[i].
startsWith(match) ) strings.erase( strings.begin() + i );
break;
1417 const unsigned char* h = (
unsigned char*)str;
1424 if (byte_count>4 && h[0] == 0xFF && h[1] == 0xFE && h[2] == 0 && h[3] == 0 )
return SE_UTF32_LE;
1425 if (byte_count>4 && h[0] == 0 && h[1] == 0 && h[2] == 0xFE && h[3] == 0xFF)
return SE_UTF32_BE;
1426 if (byte_count>3 && h[0] == 0xEF && h[1] == 0xBB && h[2] == 0xBF )
return SE_UTF8;
1427 if (byte_count>2 && h[0] == 0xFE && h[1] == 0xFF )
return SE_UTF16_BE;
1428 if (byte_count>2 && h[0] == 0xFF && h[1] == 0xFE )
return SE_UTF16_LE;
1429 return default_encoding;
1434 for(
int i=0; i<107; ++i)
1436 if (ch >= case_table_start_min_max[i][1] && ch <= case_table_start_min_max[i][2])
1438 int index = ch - case_table_start_min_max[i][1] + case_table_start_min_max[i][0];
1439 return case_table_upper_lower_title[index][0];
1447 for(
int i=0; i<107; ++i)
1449 if (ch >= case_table_start_min_max[i][1] && ch <= case_table_start_min_max[i][2])
1451 int index = ch - case_table_start_min_max[i][1] + case_table_start_min_max[i][0];
1452 return case_table_upper_lower_title[index][1];
1460 for(
int i=0; i<107; ++i)
1462 if (ch >= case_table_start_min_max[i][1] && ch <= case_table_start_min_max[i][2])
1464 int index = ch - case_table_start_min_max[i][1] + case_table_start_min_max[i][0];
1465 return case_table_upper_lower_title[index][2];
1473 std::string trimmed;
1474 for(
unsigned i=0; i<text.length(); ++i)
1476 if(text[i] ==
' ' ||
1487 trimmed = text.c_str() + i;
1491 int i = (int)trimmed.length();
1494 if(trimmed[i] ==
' ' ||
1495 trimmed[i] ==
'\n' ||
1496 trimmed[i] ==
'\t' ||
1497 trimmed[i] ==
'\v' ||
1498 trimmed[i] ==
'\b' ||
1499 trimmed[i] ==
'\a' ||
1500 trimmed[i] ==
'\f' ||
1501 trimmed[i] ==
'\r' )
1506 trimmed.resize( i+1 );
1512 std::vector<char> buffer;
1513 buffer.resize(1024 + strlen(fmt));
1518 vsnprintf(&buffer[0], buffer.size(), fmt, ap);
String toLowerCase() const
Returns the lower-case version of a String.
String & prepend(const String &str)
Prepends the specified String to another String.
void toLatin1(std::vector< unsigned char > &latin1) const
Encodes the String into a Latin1 encoded string.
String extractFileExtension(bool require_dot=true) const
If the String contains a file name or file path the function returns the extension of the file...
VLCORE_EXPORT FileSystem * defFileSystem()
Returns the default FileSystem used by VisualizationLibrary.
int findBackwards(wchar_t ch) const
Searches for the specified character chstarting from the end of the string and returns the index of t...
String & trim()
Equivalent to trim("\n\r\t\v "), that is, removes all the tabs, spaces and new-lines from the beginni...
static String fromUTF16(const unsigned short *str, int byte_count=-1)
str must have UTF16 LE or UTF16 BE signature The size of the buffer pointed by 'str' must be at least...
void squeeze()
Minimizes the memory buffer used to store the String.
static String fromUInt(unsigned int value)
Creates a string representing the given unsigned integer value.
int compare(const String &other) const
Performs a lexicographic comparison.
An abstract class representing a file.
std::wstring toStdWString() const
Returns the std::wstring representation of a String.
A simple String formatting class.
String & resize(int character_count)
Resizes the string to the specified character count.
String & reverse()
Reverses the order of the characters in the string.
static String fromLongLong(long long value)
Creates a string representing the given long long value.
static String fromUTF8(const char *str, int byte_count=-1)
Accepts strings with and without UTF8 signature.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
String substring(int start, int count=-1) const
Returns the count characters long substring starting a character index start. If count == -1 the retu...
String & replace(wchar_t old_ch, wchar_t new_ch)
Replaces the character 'old_ch' with 'new_ch'.
static unsigned short getTitleCase(unsigned short ch)
Returns the title-case version of the specified character.
static String fromUTF16BE(const unsigned short *str, int byte_count=-1)
Accepts strings with and without UTF16 BE signature Supports natively the characters from the BMP...
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
static String fromInt(int value)
Creates a string representing the given integer value.
String extractPath() const
If the String contains a file path the function returns the path with trailing slash, without the file name.
void splitLines(std::vector< String > &lines) const
Splits a String into a set of Strings each of which contains a line.
virtual ref< VirtualFile > locateFile(const String &full_path, const String &alternate_path=String()) const
Looks for a VirtualFile on the disk and in the currently active FileSystem.
int count(wchar_t ch, int start=0) const
Returns the number of occurrences of the given character after position 'start'.
String & operator=(const char *str)
Equivalent to '*this = fromUTF8(str);'.
int findInLargeText(const String &substr, int start=0) const
Searches for the specified string substr starting at position start and returns the index of the firs...
static String fromStdWString(const std::wstring &str)
Initializes the string from a std::string using the fromAscii() function.
String left(int count) const
Returns the count leftmost caracters of a String. If count is negative the function returns all but t...
int toInt(bool hex=false) const
Returns the int number represented by the string. The conversion is done using the standard atoi() fu...
String & normalizeSlashes()
Transform \ slashes in / slashes and removes duplicates.
virtual void close()=0
Closes the file.
static unsigned short getLowerCase(unsigned short ch)
Returns the lower-case version of the specified character.
void toUTF8(std::vector< unsigned char > &utf8, bool include_utf8_signature=true) const
Encodes the String into a UTF8 encoded string.
Visualization Library main namespace.
static String fromStdString(const std::string &str, bool utf8=true)
Initializes the string from a std::string using fromUTF() if utf8 == true (default) otherwise uses fr...
String & remove(wchar_t ch, int start=0, int count=-1)
Removes 'count' occurrences of the character 'ch' after position 'start'.
int length() const
Returns the length of the string.
double toDouble() const
Returns the double number represented by the string. The conversion is done using the standard atof()...
static EStringEncoding detectEncoding(const void *str, int byte_count, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING)
Detects the encoding.
void toUTF16LE(std::vector< unsigned char > &utf16, bool include_utf16le_signature=true) const
Encodes the String into a UTF16 little endian encoded string.
float max(float a, float b)
float min(float a, float b)
static String fromPointer(const void *value)
Creates a string representing the given pointer.
static String fromAscii(const char *str, int size=-1)
Initializes the string from a 7 bit ascii string.
static String fromUTF16LE(const unsigned short *str, int byte_count=-1)
Accepts strings with and without UTF16 LE signature Supports natively the characters from the BMP...
void acquireData() const
Acquires a private copy of the data if the string has been copied from another one.
VL_COMPILE_TIME_CHECK(sizeof(i8) *8==8)
String & append(const String &other)
Appends the specified String to another String.
bool empty() const
Returns true if length() == 0.
static String loadText(const String &path, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING)
Loads a String from the specified path.
void split(wchar_t separator, std::vector< String > &fields, bool remove_empty_fields=false) const
Splits a String into a set of fields. The fields are separated by the specified separator and are ret...
bool startsWith(const String &str) const
Returns true if a String starts with the specified String str.
static String fromLatin1(const char *str, int character_count=-1)
The size of the buffer pointed by 'str' must be at least 'character_count' bytes large or null termin...
bool contains(wchar_t ch) const
Returns true if a String contains the specified character.
int find(wchar_t ch, int start=0) const
Searches for the specified character ch starting at position start and returns the index of the first...
String extractFileName() const
If the String contains a file path the function returns the file name without the path...
void toAscii(std::string &ascii, bool translate_non_ascii_chars=true) const
Provides some basic character translation of code points outside of the ASCII range.
static void filterStrings(std::vector< String > &strings, const String &filter)
Filters the specified Strings using the given filter. The filter must be of the type "*abc"...
static unsigned short getUpperCase(unsigned short ch)
Returns the upper-case version of the specified character.
static String fromULongLong(unsigned long long value)
Creates a string representing the given unsigned long long value.
static std::string trimStdString(const std::string &text)
Remove the spaces before and after an std::string.
static String fromDouble(double value, int decimals=6)
Creates a string representing the given double value The value of 'decimals' can be between 0 and 20...
String toUpperCase() const
Returns the upper-case version of a String.
The ref<> class is used to reference-count an Object.
String right(int count) const
Returns the count rightmost caracters of a String. If count is negative the function returns all but ...
void toUTF16BE(std::vector< unsigned char > &utf16, bool include_utf16be_signature=true) const
Encodes the String into a UTF16 big endian encoded string.
static String printf(const char *fmt,...)
Returns a formatted string using the legacy printf syntax. The resulting string can be maximum 1024 +...
std::string toStdString() const
Returns a UTF8 encoded std::string.
bool endsWith(const String &str) const
Returns true if a String ends with the specified String str.
long long load(std::vector< char > &data)
Loads the entire file in the specified vector.
String & insert(int pos, const String &str)
Inserts str at position pos.
String & clear()
Clears the string.
String field(wchar_t separator, int field_index) const
Splits a String into a set of fields based on the specified separator and returns the filed at positi...
String & fill(wchar_t ch)
Fills the string with the specified character ch.