30#if defined (JUCE_STRINGS_ARE_UNICODE) && ! JUCE_STRINGS_ARE_UNICODE
31 #error "JUCE_STRINGS_ARE_UNICODE is deprecated! All strings are now unicode by default."
34#if JUCE_NATIVE_WCHAR_IS_UTF8
36#elif JUCE_NATIVE_WCHAR_IS_UTF16
51 using CharType = String::CharPointerType::CharType;
69 numBytes = (numBytes + 3) & ~(
size_t) 3;
73 s->allocatedNumBytes = numBytes;
77 template <
class CharPo
inter>
80 if (
text.getAddress() ==
nullptr ||
text.isEmpty())
83 auto bytesNeeded =
sizeof (
CharType) + CharPointerType::getBytesRequiredFor (
text);
89 template <
class CharPo
inter>
92 if (
text.getAddress() ==
nullptr ||
text.isEmpty() || maxChars == 0)
97 size_t bytesNeeded =
sizeof (
CharType);
99 while (numChars < maxChars && !
end.isEmpty())
101 bytesNeeded += CharPointerType::getBytesRequiredFor (
end.getAndAdvance());
110 template <
class CharPo
inter>
113 if (
start.getAddress() ==
nullptr ||
start.isEmpty())
118 auto bytesNeeded =
sizeof (
CharType);
120 while (
e <
end && !
e.isEmpty())
122 bytesNeeded += CharPointerType::getBytesRequiredFor (
e.getAndAdvance());
133 if (
start.getAddress() ==
nullptr ||
start.isEmpty())
136 auto numBytes = (size_t) (
reinterpret_cast<const char*
> (
end.getAddress())
137 -
reinterpret_cast<const char*
> (
start.getAddress()));
140 dest.getAddress()[numBytes /
sizeof (
CharType)] = 0;
163 if (--(
b->refCount) == -1)
164 delete[]
reinterpret_cast<char*
> (
b);
189 if (
b->allocatedNumBytes >= numBytes &&
b->refCount <= 0)
193 memcpy (newText.getAddress(),
text.getAddress(),
b->allocatedNumBytes);
221 #if JUCE_NATIVE_WCHAR_IS_UTF8
222 static_assert (
sizeof (wchar_t) == 1,
"JUCE_NATIVE_WCHAR_IS_* macro has incorrect value");
223 #elif JUCE_NATIVE_WCHAR_IS_UTF16
224 static_assert (
sizeof (wchar_t) == 2,
"JUCE_NATIVE_WCHAR_IS_* macro has incorrect value");
225 #elif JUCE_NATIVE_WCHAR_IS_UTF32
226 static_assert (
sizeof (wchar_t) == 4,
"JUCE_NATIVE_WCHAR_IS_* macro has incorrect value");
228 #error "native wchar_t size is unknown"
250 std::swap (
text, other.text);
273 std::swap (
text, other.text);
280 :
text (
StringHolderUtils::createUninitialisedBytes (preallocationSize.numBytes + sizeof (CharPointerType::CharType)))
362 CharPointerType
t (
result.text);
377 template <
typename Type>
384 *--
t =
static_cast<char> (
'0' + (char) (
v % 10));
446 static const std::locale classicLocale (std::locale::classic());
447 imbue (classicLocale);
451 size_t writeDouble (
double n,
int numDecPlaces,
bool useScientificNotation)
454 std::ostream o (
this);
456 if (numDecPlaces > 0)
458 o.setf (useScientificNotation ? std::ios_base::scientific : std::ios_base::fixed);
459 o.precision ((std::streamsize) numDecPlaces);
465 return (
size_t) (pptr() - pbase());
469 static char*
doubleToString (
char* buffer,
double n,
int numDecPlaces,
bool useScientificNotation,
size_t& len)
noexcept
472 len = strm.
writeDouble (
n, numDecPlaces, useScientificNotation);
477 template <
typename IntegerType>
486 static String::CharPointerType
createFromDouble (
double number,
int numberOfDecimalPlaces,
bool useScientificNotation)
490 auto start =
doubleToString (buffer, number, numberOfDecimalPlaces, useScientificNotation, len);
513 return (
int)
text.length();
518 return (
size_t) (((
char*)
text.findTerminatingNull().getAddress()) - (
char*)
text.getAddress());
528 jassert (index == 0 || (index > 0 && index <= (
int)
text.lengthUpTo ((
size_t) index + 1)));
532template <
typename Type>
535 template <
typename CharPo
inter>
540 while (!
t.isEmpty())
541 result = ((Type) multiplier) *
result + (Type)
t.getAndAdvance();
546 enum { multiplier =
sizeof (Type) > 4 ? 101 : 31 };
587 return text.compareIgnoreCase (
t.text) == 0;
592 return text == other.text
593 ||
text.compareIgnoreCase (other.text) == 0;
605 auto c1 = s1.getAndAdvance();
608 auto c2 = s2.getAndAdvance();
611 if (! (isDigit1 || isDigit2))
return bias;
612 if (! isDigit1)
return -1;
613 if (! isDigit2)
return 1;
615 if (c1 !=
c2 && bias == 0)
616 bias = c1 <
c2 ? -1 : 1;
626 auto c1 = s1.getAndAdvance();
629 auto c2 = s2.getAndAdvance();
632 if (! (isDigit1 || isDigit2))
return 0;
633 if (! isDigit1)
return -1;
634 if (! isDigit2)
return 1;
635 if (c1 <
c2)
return -1;
636 if (c1 >
c2)
return 1;
640static int naturalStringCompare (String::CharPointerType s1, String::CharPointerType s2,
bool isCaseSensitive)
noexcept
642 bool firstLoop =
true;
646 const bool hasSpace1 = s1.isWhitespace();
647 const bool hasSpace2 = s2.isWhitespace();
649 if ((! firstLoop) && (hasSpace1 ^ hasSpace2))
651 if (s1.isEmpty())
return -1;
652 if (s2.isEmpty())
return 1;
654 return hasSpace2 ? 1 : -1;
659 if (hasSpace1) s1 = s1.findEndOfWhitespace();
660 if (hasSpace2) s2 = s2.findEndOfWhitespace();
662 if (s1.isDigit() && s2.isDigit())
671 auto c1 = s1.getAndAdvance();
672 auto c2 = s2.getAndAdvance();
674 if (c1 !=
c2 && ! isCaseSensitive)
690 if (isAlphaNum2 && ! isAlphaNum1)
return -1;
691 if (isAlphaNum1 && ! isAlphaNum2)
return 1;
693 return c1 <
c2 ? -1 : 1;
709 : textToAppend.
text, maxCharsToTake);
718 const CharPointerType endOfTextToAppend)
720 jassert (startOfTextToAppend.getAddress() !=
nullptr && endOfTextToAppend.getAddress() !=
nullptr);
723 startOfTextToAppend.getAddress());
724 jassert (extraBytesNeeded >= 0);
726 if (extraBytesNeeded > 0)
732 memcpy (newStringStart, startOfTextToAppend.getAddress(), (
size_t) extraBytesNeeded);
733 CharPointerType (
addBytesToPointer (newStringStart, extraBytesNeeded)).writeNull();
752 return operator= (other);
755 return operator+= (
String (*
this));
763 return operator+= (
String (other));
768 const char asString[] = { ch, 0 };
769 return operator+= (asString);
774 const wchar_t asString[] = { ch, 0 };
775 return operator+= (asString);
778#if ! JUCE_NATIVE_WCHAR_IS_UTF32
782 appendCharPointer (CharPointer_UTF32 (asString));
789 template <
typename T>
792 char buffer [(
sizeof(T) * 8) / 2];
796 #if JUCE_STRING_UTF_TYPE == 8
826#if ! JUCE_NATIVE_WCHAR_IS_UTF32
860 #if (JUCE_STRING_UTF_TYPE == 8)
861 stream.
write (
text.text.getAddress(), numBytes);
867 stream.
write (temp, numBytes);
876 return text.indexOf (character);
883 for (
int i = 0; !
t.isEmpty(); ++
i)
887 if (
t.getAndAdvance() == character)
904 for (
int i = 0; !
t.isEmpty(); ++
i)
905 if (
t.getAndAdvance() == character)
915 for (
int i = 0; !
t.isEmpty(); ++
i)
919 if (charactersToLookFor.text.indexOf (
t.getAndAdvance(), ignoreCase) >= 0)
933 return other.isEmpty() ? 0 :
text.indexOf (other.text);
948 for (
int i = startIndex; --
i >= 0;)
956 auto found =
t.indexOf (other.text);
957 return found >= 0 ? found + startIndex : found;
967 for (
int i = startIndex; --
i >= 0;)
976 return found >= 0 ? found + startIndex : found;
981 if (other.isNotEmpty())
983 auto len = other.length();
988 for (
auto n =
text +
i;
i >= 0; --
i)
990 if (
n.compareUpTo (other.text, len) == 0)
1003 if (other.isNotEmpty())
1005 auto len = other.length();
1010 for (
auto n =
text +
i;
i >= 0; --
i)
1012 if (
n.compareIgnoreCaseUpTo (other.text, len) == 0)
1028 for (
int i = 0; !
t.isEmpty(); ++
i)
1029 if (charactersToLookFor.text.indexOf (
t.getAndAdvance(), ignoreCase) >= 0)
1042 return text.indexOf (character) >= 0;
1052 if (
word.isNotEmpty())
1055 auto wordLen =
word.length();
1056 auto end = (
int)
t.length() - wordLen;
1058 for (
int i = 0;
i <=
end; ++
i)
1060 if (
t.compareUpTo (
word.text, wordLen) == 0
1061 && (
i == 0 || ! (
t - 1).isLetterOrDigit())
1062 && ! (
t + wordLen).isLetterOrDigit())
1074 if (
word.isNotEmpty())
1077 auto wordLen =
word.length();
1078 auto end = (
int)
t.length() - wordLen;
1080 for (
int i = 0;
i <=
end; ++
i)
1082 if (
t.compareIgnoreCaseUpTo (
word.text, wordLen) == 0
1083 && (
i == 0 || ! (
t - 1).isLetterOrDigit())
1084 && ! (
t + wordLen).isLetterOrDigit())
1105template <
typename CharPo
inter>
1108 static bool matches (CharPointer wildcard, CharPointer
test,
const bool ignoreCase)
noexcept
1112 auto wc = wildcard.getAndAdvance();
1127 return (wc == tc) || (wc ==
'?' && tc != 0)
1149 if (numberOfTimesToRepeat <= 0)
1155 while (--numberOfTimesToRepeat >= 0)
1156 n.writeAll (stringToRepeat.
text);
1165 auto extraChars = minimumLength;
1168 while (!
end.isEmpty())
1174 if (extraChars <= 0 || padCharacter == 0)
1177 auto currentByteSize = (size_t) (((
char*)
end.getAddress()) - (
char*)
text.getAddress());
1181 while (--extraChars >= 0)
1182 n.write (padCharacter);
1192 auto extraChars = minimumLength;
1195 while (!
end.isEmpty())
1201 if (extraChars <= 0 || padCharacter == 0)
1204 auto currentByteSize = (size_t) (((
char*)
end.getAddress()) - (
char*)
text.getAddress());
1210 while (--extraChars >= 0)
1211 n.write (padCharacter);
1227 if (numCharsToReplace < 0)
1230 numCharsToReplace = 0;
1234 auto insertPoint =
text;
1236 for (
int i = 0;
i < index; ++
i)
1238 if (insertPoint.isEmpty())
1242 return *
this + stringToInsert;
1248 auto startOfRemainder = insertPoint;
1250 for (
int i = 0;
i < numCharsToReplace && ! startOfRemainder.isEmpty(); ++
i)
1253 if (insertPoint ==
text && startOfRemainder.isEmpty())
1254 return stringToInsert.
text;
1256 auto initialBytes = (size_t) (((
char*) insertPoint.getAddress()) - (
char*)
text.getAddress());
1258 auto remainderBytes = (size_t) (((
char*) startOfRemainder.findTerminatingNull().getAddress()) - (
char*) startOfRemainder.getAddress());
1260 auto newTotalBytes = initialBytes + newStringBytes + remainderBytes;
1262 if (newTotalBytes <= 0)
1267 auto* dest = (
char*)
result.text.getAddress();
1268 memcpy (dest,
text.getAddress(), initialBytes);
1269 dest += initialBytes;
1270 memcpy (dest, stringToInsert.
text.getAddress(), newStringBytes);
1271 dest += newStringBytes;
1272 memcpy (dest, startOfRemainder.getAddress(), remainderBytes);
1273 dest += remainderBytes;
1281 auto stringToReplaceLen = stringToReplace.
length();
1282 auto stringToInsertLen = stringToInsert.
length();
1287 while ((
i = (ignoreCase ?
result.indexOfIgnoreCase (
i, stringToReplace)
1288 :
result.indexOf (
i, stringToReplace))) >= 0)
1290 result =
result.replaceSection (
i, stringToReplaceLen, stringToInsert);
1291 i += stringToInsertLen;
1299 auto stringToReplaceLen = stringToReplace.
length();
1304 return replaceSection (index, stringToReplaceLen, stringToInsert);
1326 bytesWritten += String::CharPointerType::getBytesRequiredFor (
c);
1331 auto destOffset = (size_t) (((
char*)
dest.getAddress()) - (
char*)
result.getCharPointer().getAddress());
1340 String::CharPointerType
source {
nullptr }, dest {
nullptr };
1353 auto c = builder.
source.getAndAdvance();
1355 if (
c == charToReplace)
1364 return std::move (builder.
result);
1377 auto c = builder.
source.getAndAdvance();
1378 auto index = charactersToReplace.
text.indexOf (
c);
1381 c = charactersToInsertInstead [index];
1389 return std::move (builder.
result);
1395 return text.compareUpTo (other.text, other.length()) == 0;
1400 return text.compareIgnoreCaseUpTo (other.text, other.length()) == 0;
1407 return *
text == character;
1417 auto t =
text.findTerminatingNull();
1418 return *--
t == character;
1423 auto end =
text.findTerminatingNull();
1424 auto otherEnd = other.text.findTerminatingNull();
1426 while (
end >
text && otherEnd > other.text)
1431 if (*
end != *otherEnd)
1435 return otherEnd == other.text;
1440 auto end =
text.findTerminatingNull();
1441 auto otherEnd = other.text.findTerminatingNull();
1443 while (
end >
text && otherEnd > other.text)
1448 if (
end.toLowerCase() != otherEnd.toLowerCase())
1452 return otherEnd == other.text;
1462 auto c = builder.
source.toUpperCase();
1471 return std::move (builder.
result);
1480 auto c = builder.
source.toLowerCase();
1489 return std::move (builder.
result);
1544 while (--
start >= 0)
1607 return c ==
'"' ||
c ==
'\'';
1631 if (!
t.startsWithChar (quoteCharacter))
1634 if (!
t.endsWithChar (quoteCharacter))
1635 t += quoteCharacter;
1642 String::CharPointerType
end)
1646 if (! (--
end).isWhitespace())
1660 auto start =
text.findEndOfWhitespace();
1661 auto end =
start.findTerminatingNull();
1664 if (trimmedEnd <=
start)
1678 auto t =
text.findEndOfWhitespace();
1691 auto end =
text.findTerminatingNull();
1694 if (trimmedEnd <
end)
1705 while (charactersToTrim.
text.indexOf (*
t) >= 0)
1715 auto end =
text.findTerminatingNull();
1716 auto trimmedEnd =
end;
1718 while (trimmedEnd >
text)
1720 if (charactersToTrim.
text.indexOf (*--trimmedEnd) < 0)
1727 if (trimmedEnd <
end)
1744 auto c = builder.
source.getAndAdvance();
1746 if (charactersToRetain.
text.indexOf (
c) >= 0)
1754 return std::move (builder.
result);
1766 auto c = builder.
source.getAndAdvance();
1768 if (charactersToRemove.
text.indexOf (
c) < 0)
1775 return std::move (builder.
result);
1780 for (
auto t =
text; !
t.isEmpty(); ++
t)
1781 if (permittedCharacters.
text.indexOf (*
t) < 0)
1789 for (
auto t =
text; !
t.isEmpty(); ++
t)
1790 if (charactersToStopAt.
text.indexOf (*
t) >= 0)
1798 for (
auto t =
text; !
t.isEmpty();)
1799 if (chars.text.indexOf (
t.getAndAdvance()) < 0)
1807 for (
auto t =
text; !
t.isEmpty();)
1808 if (chars.text.indexOf (
t.getAndAdvance()) >= 0)
1816 for (
auto t =
text; !
t.isEmpty(); ++
t)
1817 if (!
t.isWhitespace())
1825 size_t bufferSize = 256;
1830 va_start (args, pf);
1838 int num = (
int) vsnprintf (temp.get(), bufferSize - 1, pf, args);
1839 if (num >=
static_cast<int> (bufferSize))
1842 String wideCharVersion (pf);
1844 const int num = (
int)
1859 return String (temp.get());
1863 if (num == 0 || bufferSize > 65536)
1880 auto t =
text.findTerminatingNull();
1901template <
typename Type>
1904 String::CharPointerType::CharType buffer[32];
1912 v =
static_cast<Type
> (
v >> 4);
1916 return String (String::CharPointerType (
t),
1917 String::CharPointerType (
end));
1930 int numChars = (
size * 2) + 2;
1932 numChars +=
size / groupSize;
1936 auto*
data =
static_cast<const unsigned char*
> (
d);
1939 for (
int i = 0;
i <
size; ++
i)
1941 const unsigned char nextByte = *
data++;
1945 if (groupSize > 0 && (
i % groupSize) == (groupSize - 1) &&
i < (
size - 1))
1961 for (
size_t i = 0;
i < num; ++
i)
1970 auto*
data =
static_cast<const uint8*
> (unknownData);
1981 const int numChars =
size / 2 - 1;
1989 for (
int i = 0;
i < numChars; ++
i)
1994 for (
int i = 0;
i < numChars; ++
i)
1999 return std::move (builder.
result);
2020template <
class CharPo
interType_Src,
class CharPo
interType_Dest>
2025 auto& source =
const_cast<String&
> (
s);
2027 using DestChar =
typename CharPointerType_Dest::CharType;
2029 if (source.isEmpty())
2030 return CharPointerType_Dest (
reinterpret_cast<const DestChar*
> (&
emptyChar));
2032 CharPointerType_Src
text (source.getCharPointer());
2033 auto extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (
text) +
sizeof (
typename CharPointerType_Dest::CharType);
2034 auto endOffset = (
text.sizeInBytes() + 3) & ~3u;
2036 source.preallocateBytes (endOffset + extraBytesNeeded);
2037 text = source.getCharPointer();
2040 const CharPointerType_Dest extraSpace (
static_cast<DestChar*
> (newSpace));
2043 auto bytesToClear = (size_t)
jmin ((
int) extraBytesNeeded, 4);
2047 CharPointerType_Dest (extraSpace).writeAll (
text);
2076 return toUTF8().getAddress();
2090template <
class CharPo
interType_Src,
class CharPo
interType_Dest>
2093 static size_t copyToBuffer (
const CharPointerType_Src source,
typename CharPointerType_Dest::CharType*
const buffer,
const size_t maxBufferSizeBytes)
2095 jassert (((ssize_t) maxBufferSizeBytes) >= 0);
2097 if (buffer ==
nullptr)
2098 return CharPointerType_Dest::getBytesRequiredFor (source) +
sizeof (
typename CharPointerType_Dest::CharType);
2100 return CharPointerType_Dest (buffer).writeWithDestByteLimit (source, maxBufferSizeBytes);
2127 if (buffer !=
nullptr)
2129 if (bufferSizeBytes < 0)
2132 if (bufferSizeBytes > 0)
2150 #if JUCE_STRING_UTF_TYPE != 8
2153 :
text (stringLiteral)
2156 #if JUCE_STRING_UTF_TYPE != 8
2160 jassert (stringLiteral !=
nullptr);
2162 #if JUCE_NATIVE_WCHAR_IS_UTF8
2182 jassert (stringLiteral.getAddress() !=
nullptr);
2193 auto trimStart =
end;
2194 auto trimEnd = trimStart;
2195 auto exponentTrimStart =
end;
2196 auto exponentTrimEnd = exponentTrimStart;
2198 decltype (*start) currentChar =
'\0';
2204 if (currentChar ==
'0' &&
c + 1 == trimStart)
2208 else if (currentChar ==
'.')
2210 if (trimStart ==
c + 1 && trimStart !=
end && *trimStart ==
'0')
2215 else if (currentChar ==
'e' || currentChar ==
'E')
2224 exponentTrimStart = cNext;
2226 if (cNext !=
end && *cNext ==
'+')
2229 exponentTrimEnd = cNext;
2232 while (cNext !=
end && *cNext++ ==
'0')
2233 exponentTrimEnd = cNext;
2235 if (exponentTrimEnd ==
end)
2236 exponentTrimStart =
c;
2239 trimEnd = trimStart;
2243 if ((trimStart != trimEnd && currentChar ==
'.') || exponentTrimStart != exponentTrimEnd)
2245 if (trimStart == trimEnd)
2248 if (exponentTrimStart == exponentTrimEnd)
2251 if (trimEnd == exponentTrimStart)
2262 auto absInput = std::abs (input);
2264 if (absInput >= 1.0e6 || absInput <= 1.0e-5)
2267 int intInput = (
int) input;
2269 if ((
double) intInput == input)
2270 return { input, 1 };
2272 auto numberOfDecimalPlaces = [absInput]
2276 if (absInput >= 1.0e-3)
2278 if (absInput >= 1.0e-1)
return 16;
2279 if (absInput >= 1.0e-2)
return 17;
2283 if (absInput >= 1.0e-4)
return 19;
2287 if (absInput < 1.0e3)
2289 if (absInput < 1.0e1)
return 15;
2290 if (absInput < 1.0e2)
return 14;
2294 if (absInput < 1.0e4)
return 12;
2295 if (absInput < 1.0e5)
return 11;
2303#if JUCE_ALLOW_STATIC_NULL_VARIABLES
2319#define STRINGIFY2(X) #X
2320#define STRINGIFY(X) STRINGIFY2(X)
2322class StringTests :
public UnitTest
2326 : UnitTest (
"String class", UnitTestCategories::
text)
2329 template <
class CharPo
interType>
2330 struct TestUTFConversion
2332 static void test (UnitTest&
test, Random&
r)
2334 String
s (createRandomWideCharString (
r));
2336 typename CharPointerType::CharType
buffer [300];
2338 memset (buffer, 0xff,
sizeof (buffer));
2339 CharPointerType (buffer).writeAll (
s.toUTF32());
2340 test.expectEquals (String (CharPointerType (buffer)),
s);
2342 memset (buffer, 0xff,
sizeof (buffer));
2343 CharPointerType (buffer).writeAll (
s.toUTF16());
2344 test.expectEquals (String (CharPointerType (buffer)),
s);
2346 memset (buffer, 0xff,
sizeof (buffer));
2347 CharPointerType (buffer).writeAll (
s.toUTF8());
2348 test.expectEquals (String (CharPointerType (buffer)),
s);
2350 test.expect (CharPointerType::isValidString (buffer, (
int) strlen ((
const char*) buffer)));
2354 static String createRandomWideCharString (Random&
r)
2366 while (! CharPointer_UTF16::canRepresent (buffer[
i]));
2372 return CharPointer_UTF32 (buffer);
2375 void runTest()
override
2377 Random
r = getRandom();
2380 beginTest (
"Basics");
2382 expect (String().
length() == 0);
2383 expect (String() == String());
2384 String s1, s2 (
"abcd");
2386 expect (s2.isNotEmpty() && ! s2.isEmpty());
2387 expect (s2.length() == 4);
2389 expect (s2 == s1 && s1 == s2);
2390 expect (s1 ==
"abcd" && s1 == L
"abcd");
2391 expect (String (
"abcd") == String (L
"abcd"));
2392 expect (String (
"abcdefg", 4) == L
"abcd");
2393 expect (String (
"abcdefg", 4) == String (L
"abcdefg", 4));
2396 expect (s2 +
"e" ==
"abcde" && s2 +
'e' ==
"abcde");
2397 expect (s2 + L
'e' ==
"abcde" && s2 + L
"e" ==
"abcde");
2402 expectEquals (s1.
indexOf (String()), 0);
2409 expect (String (
"abc foo bar").containsWholeWord (
"abc") && String (
"abc foo bar").containsWholeWord (
"abc"));
2413 beginTest (
"Operations");
2415 String
s (
"012345678");
2416 expect (
s.hashCode() != 0);
2417 expect (
s.hashCode64() != 0);
2418 expect (
s.hashCode() != (
s +
s).hashCode());
2419 expect (
s.hashCode64() != (
s +
s).hashCode64());
2420 expect (
s.compare (String (
"012345678")) == 0);
2421 expect (
s.compare (String (
"012345679")) < 0);
2422 expect (
s.compare (String (
"012345676")) > 0);
2423 expect (String(
"a").compareNatural (
"A") == 0);
2424 expect (String(
"A").compareNatural (
"B") < 0);
2425 expect (String(
"a").compareNatural (
"B") < 0);
2426 expect (String(
"10").compareNatural (
"2") > 0);
2427 expect (String(
"Abc 10").compareNatural (
"aBC 2") > 0);
2428 expect (String(
"Abc 1").compareNatural (
"aBC 2") < 0);
2431 expect (
s.getLastCharacter() ==
s [
s.length() - 1]);
2433 expect (
s.substring (0, 3) == L
"012");
2434 expect (
s.substring (0, 100) ==
s);
2435 expect (
s.substring (-1, 100) ==
s);
2436 expect (
s.substring (3) ==
"345678");
2437 expect (
s.indexOf (String (L
"45")) == 4);
2438 expect (String (
"444445").indexOf (
"45") == 4);
2439 expect (String (
"444445").lastIndexOfChar (
'4') == 4);
2440 expect (String (
"45454545x").lastIndexOf (String (L
"45")) == 6);
2441 expect (String (
"45454545x").lastIndexOfAnyOf (
"456") == 7);
2442 expect (String (
"45454545x").lastIndexOfAnyOf (String (L
"456x")) == 8);
2443 expect (String (
"abABaBaBa").lastIndexOfIgnoreCase (
"aB") == 6);
2444 expect (
s.indexOfChar (L
'4') == 4);
2445 expect (
s +
s ==
"012345678012345678");
2446 expect (
s.startsWith (
s));
2447 expect (
s.startsWith (
s.substring (0, 4)));
2448 expect (
s.startsWith (
s.dropLastCharacters (4)));
2449 expect (
s.endsWith (
s.substring (5)));
2450 expect (
s.endsWith (
s));
2451 expect (
s.contains (
s.substring (3, 6)));
2452 expect (
s.contains (
s.substring (3)));
2453 expect (
s.startsWithChar (
s[0]));
2454 expect (
s.endsWithChar (
s.getLastCharacter()));
2455 expect (
s [
s.length()] == 0);
2456 expect (String (
"abcdEFGH").toLowerCase() == String (
"abcdefgh"));
2457 expect (String (
"abcdEFGH").toUpperCase() == String (
"ABCDEFGH"));
2459 expect (String (StringRef (
"abc")) ==
"abc");
2460 expect (String (StringRef (
"abc")) == StringRef (
"abc"));
2461 expect (String (
"abc") + StringRef (
"def") ==
"abcdef");
2463 expect (String (
"0x00").getHexValue32() == 0);
2464 expect (String (
"0x100").getHexValue32() == 256);
2467 s2 << ((
int) 4) << ((
short) 5) <<
"678" << L
"9" <<
'0';
2469 expect (s2 ==
"1234567890xyz");
2471 expect (s2 ==
"1234567890xyz123");
2473 expect (s2 ==
"1234567890xyz123123");
2474 s2 << StringRef (
"def");
2475 expect (s2 ==
"1234567890xyz123123def");
2479 String numStr (std::numeric_limits<int16>::max());
2480 expect (numStr ==
"32767");
2483 String numStr (std::numeric_limits<int16>::min());
2484 expect (numStr ==
"-32768");
2488 numStr << std::numeric_limits<int16>::max();
2489 expect (numStr ==
"32767");
2493 numStr << std::numeric_limits<int16>::min();
2494 expect (numStr ==
"-32768");
2498 String numStr (std::numeric_limits<int32>::max());
2499 expect (numStr ==
"2147483647");
2502 String numStr (std::numeric_limits<int32>::min());
2503 expect (numStr ==
"-2147483648");
2507 numStr << std::numeric_limits<int32>::max();
2508 expect (numStr ==
"2147483647");
2512 numStr << std::numeric_limits<int32>::min();
2513 expect (numStr ==
"-2147483648");
2517 String numStr (std::numeric_limits<uint32>::max());
2518 expect (numStr ==
"4294967295");
2521 String numStr (std::numeric_limits<uint32>::min());
2522 expect (numStr ==
"0");
2526 String numStr (std::numeric_limits<int64>::max());
2527 expect (numStr ==
"9223372036854775807");
2530 String numStr (std::numeric_limits<int64>::min());
2531 expect (numStr ==
"-9223372036854775808");
2535 numStr << std::numeric_limits<int64>::max();
2536 expect (numStr ==
"9223372036854775807");
2540 numStr << std::numeric_limits<int64>::min();
2541 expect (numStr ==
"-9223372036854775808");
2545 String numStr (std::numeric_limits<uint64>::max());
2546 expect (numStr ==
"18446744073709551615");
2549 String numStr (std::numeric_limits<uint64>::min());
2550 expect (numStr ==
"0");
2554 numStr << std::numeric_limits<uint64>::max();
2555 expect (numStr ==
"18446744073709551615");
2559 numStr << std::numeric_limits<uint64>::min();
2560 expect (numStr ==
"0");
2564 String numStr (std::numeric_limits<size_t>::min());
2565 expect (numStr ==
"0");
2568 beginTest (
"Numeric conversions");
2569 expect (String().getIntValue() == 0);
2570 expect (String().getDoubleValue() == 0.0);
2571 expect (String().getFloatValue() == 0.0f);
2572 expect (
s.getIntValue() == 12345678);
2573 expect (
s.getLargeIntValue() == (
int64) 12345678);
2574 expect (
s.getDoubleValue() == 12345678.0);
2575 expect (
s.getFloatValue() == 12345678.0f);
2576 expect (String (-1234).getIntValue() == -1234);
2577 expect (String ((
int64) -1234).getLargeIntValue() == -1234);
2578 expect (String (-1234.56).getDoubleValue() == -1234.56);
2579 expect (String (-1234.56f).getFloatValue() == -1234.56f);
2580 expect (String (std::numeric_limits<int>::max()).getIntValue() == std::numeric_limits<int>::max());
2581 expect (String (std::numeric_limits<int>::min()).getIntValue() == std::numeric_limits<int>::min());
2582 expect (String (std::numeric_limits<int64>::max()).getLargeIntValue() == std::numeric_limits<int64>::max());
2583 expect (String (std::numeric_limits<int64>::min()).getLargeIntValue() == std::numeric_limits<int64>::min());
2584 expect ((
"xyz" +
s).getTrailingIntValue() ==
s.getIntValue());
2585 expect (String (
"xyz-5").getTrailingIntValue() == -5);
2586 expect (String (
"-12345").getTrailingIntValue() == -12345);
2587 expect (
s.getHexValue32() == 0x12345678);
2588 expect (
s.getHexValue64() == (
int64) 0x12345678);
2599 unsigned char data[] = { 1, 2, 3, 4, 0xa, 0xb, 0xc, 0xd };
2604 expectEquals (String (12345.67, 4), String (
"12345.6700"));
2605 expectEquals (String (12345.67, 6), String (
"12345.670000"));
2606 expectEquals (String (2589410.5894, 7), String (
"2589410.5894000"));
2607 expectEquals (String (12345.67, 8), String (
"12345.67000000"));
2608 expectEquals (String (1e19, 4), String (
"10000000000000000000.0000"));
2609 expectEquals (String (1
e-34, 36), String (
"0.000000000000000000000000000000000100"));
2610 expectEquals (String (1.39, 1), String (
"1.4"));
2612 expectEquals (String (12345.67, 4,
true), String (
"1.2346e+04"));
2613 expectEquals (String (12345.67, 6,
true), String (
"1.234567e+04"));
2614 expectEquals (String (2589410.5894, 7,
true), String (
"2.5894106e+06"));
2615 expectEquals (String (12345.67, 8,
true), String (
"1.23456700e+04"));
2616 expectEquals (String (1e19, 4,
true), String (
"1.0000e+19"));
2617 expectEquals (String (1
e-34, 5,
true), String (
"1.00000e-34"));
2618 expectEquals (String (1.39, 1,
true), String (
"1.4e+00"));
2620 beginTest (
"Subsections");
2627 expect (s3.
indexOfAnyOf (String (L
"xyzf"), 2,
false) == -1);
2634 expect (s3.
endsWith (String (
"HIJ")));
2638 expect (s3.
indexOf (
"HIJ") == 7);
2639 expect (s3.
indexOf (String (L
"HIJK")) == -1);
2645 s4.append (String (
"xyz123"), 3);
2646 expect (s4 == s3 +
"xyz");
2648 expect (String (1234) < String (1235));
2649 expect (String (1235) > String (1234));
2650 expect (String (1234) >= String (1234));
2651 expect (String (1234) <= String (1234));
2652 expect (String (1235) >= String (1234));
2653 expect (String (1234) <= String (1235));
2655 String s5 (
"word word2 word3");
2656 expect (s5.containsWholeWord (String (
"word2")));
2657 expect (s5.indexOfWholeWord (
"word2") == 5);
2658 expect (s5.containsWholeWord (String (L
"word")));
2659 expect (s5.containsWholeWord (
"word3"));
2660 expect (s5.containsWholeWord (s5));
2661 expect (s5.containsWholeWordIgnoreCase (String (L
"Word2")));
2662 expect (s5.indexOfWholeWordIgnoreCase (
"Word2") == 5);
2663 expect (s5.containsWholeWordIgnoreCase (String (L
"Word")));
2664 expect (s5.containsWholeWordIgnoreCase (
"Word3"));
2665 expect (! s5.containsWholeWordIgnoreCase (String (L
"Wordx")));
2666 expect (! s5.containsWholeWordIgnoreCase (
"xWord2"));
2667 expect (s5.containsNonWhitespaceChars());
2668 expect (s5.containsOnly (
"ordw23 "));
2669 expect (! String (
" \n\r\t").containsNonWhitespaceChars());
2671 expect (s5.matchesWildcard (String (L
"wor*"),
false));
2672 expect (s5.matchesWildcard (
"wOr*",
true));
2673 expect (s5.matchesWildcard (String (L
"*word3"),
true));
2674 expect (s5.matchesWildcard (
"*word?",
true));
2675 expect (s5.matchesWildcard (String (L
"Word*3"),
true));
2676 expect (! s5.matchesWildcard (String (L
"*34"),
true));
2677 expect (String (
"xx**y").matchesWildcard (
"*y",
true));
2678 expect (String (
"xx**y").matchesWildcard (
"x*y",
true));
2679 expect (String (
"xx**y").matchesWildcard (
"xx*y",
true));
2680 expect (String (
"xx**y").matchesWildcard (
"xx*",
true));
2681 expect (String (
"xx?y").matchesWildcard (
"x??y",
true));
2682 expect (String (
"xx?y").matchesWildcard (
"xx?y",
true));
2683 expect (! String (
"xx?y").matchesWildcard (
"xx?y?",
true));
2684 expect (String (
"xx?y").matchesWildcard (
"xx??",
true));
2686 expectEquals (s5.fromFirstOccurrenceOf (String(),
true,
false), s5);
2687 expectEquals (s5.fromFirstOccurrenceOf (
"xword2",
true,
false), s5.substring (100));
2688 expectEquals (s5.fromFirstOccurrenceOf (String (L
"word2"),
true,
false), s5.substring (5));
2689 expectEquals (s5.fromFirstOccurrenceOf (
"Word2",
true,
true), s5.substring (5));
2690 expectEquals (s5.fromFirstOccurrenceOf (
"word2",
false,
false), s5.getLastCharacters (6));
2691 expectEquals (s5.fromFirstOccurrenceOf (
"Word2",
false,
true), s5.getLastCharacters (6));
2693 expectEquals (s5.fromLastOccurrenceOf (String(),
true,
false), s5);
2694 expectEquals (s5.fromLastOccurrenceOf (
"wordx",
true,
false), s5);
2695 expectEquals (s5.fromLastOccurrenceOf (
"word",
true,
false), s5.getLastCharacters (5));
2696 expectEquals (s5.fromLastOccurrenceOf (
"worD",
true,
true), s5.getLastCharacters (5));
2697 expectEquals (s5.fromLastOccurrenceOf (
"word",
false,
false), s5.getLastCharacters (1));
2698 expectEquals (s5.fromLastOccurrenceOf (
"worD",
false,
true), s5.getLastCharacters (1));
2700 expect (s5.upToFirstOccurrenceOf (String(),
true,
false).isEmpty());
2701 expectEquals (s5.upToFirstOccurrenceOf (
"word4",
true,
false), s5);
2702 expectEquals (s5.upToFirstOccurrenceOf (
"word2",
true,
false), s5.substring (0, 10));
2703 expectEquals (s5.upToFirstOccurrenceOf (
"Word2",
true,
true), s5.substring (0, 10));
2704 expectEquals (s5.upToFirstOccurrenceOf (
"word2",
false,
false), s5.substring (0, 5));
2705 expectEquals (s5.upToFirstOccurrenceOf (
"Word2",
false,
true), s5.substring (0, 5));
2707 expectEquals (s5.upToLastOccurrenceOf (String(),
true,
false), s5);
2708 expectEquals (s5.upToLastOccurrenceOf (
"zword",
true,
false), s5);
2709 expectEquals (s5.upToLastOccurrenceOf (
"word",
true,
false), s5.dropLastCharacters (1));
2710 expectEquals (s5.dropLastCharacters(1).upToLastOccurrenceOf (
"word",
true,
false), s5.dropLastCharacters (1));
2711 expectEquals (s5.upToLastOccurrenceOf (
"Word",
true,
true), s5.dropLastCharacters (1));
2712 expectEquals (s5.upToLastOccurrenceOf (
"word",
false,
false), s5.dropLastCharacters (5));
2713 expectEquals (s5.upToLastOccurrenceOf (
"Word",
false,
true), s5.dropLastCharacters (5));
2715 expectEquals (s5.replace (
"word",
"xyz",
false), String (
"xyz xyz2 xyz3"));
2716 expect (s5.replace (
"Word",
"xyz",
true) ==
"xyz xyz2 xyz3");
2717 expect (s5.dropLastCharacters (1).replace (
"Word", String (
"xyz"),
true) == L
"xyz xyz2 xyz");
2718 expect (s5.replace (
"Word",
"",
true) ==
" 2 3");
2719 expectEquals (s5.replace (
"Word2",
"xyz",
true), String (
"word xyz word3"));
2720 expect (s5.replaceCharacter (L
'w',
'x') != s5);
2721 expectEquals (s5.replaceCharacter (
'w', L
'x').replaceCharacter (
'x',
'w'), s5);
2722 expect (s5.replaceCharacters (
"wo",
"xy") != s5);
2723 expectEquals (s5.replaceCharacters (
"wo",
"xy").replaceCharacters (
"xy",
"wo"), s5);
2724 expectEquals (s5.retainCharacters (
"1wordxya"), String (
"wordwordword"));
2725 expect (s5.retainCharacters (String()).isEmpty());
2726 expect (s5.removeCharacters (
"1wordxya") ==
" 2 3");
2727 expectEquals (s5.removeCharacters (String()), s5);
2728 expect (s5.initialSectionContainingOnly (
"word") == L
"word");
2729 expect (String (
"word").initialSectionContainingOnly (
"word") == L
"word");
2730 expectEquals (s5.initialSectionNotContaining (String (
"xyz ")), String (
"word"));
2731 expectEquals (s5.initialSectionNotContaining (String (
";[:'/")), s5);
2732 expect (! s5.isQuotedString());
2733 expect (s5.quoted().isQuotedString());
2734 expect (! s5.quoted().unquoted().isQuotedString());
2735 expect (! String (
"x'").isQuotedString());
2736 expect (String (
"'x").isQuotedString());
2738 String s6 (
" \t xyz \t\r\n");
2739 expectEquals (s6.trim(), String (
"xyz"));
2740 expect (s6.trim().trim() ==
"xyz");
2741 expectEquals (s5.trim(), s5);
2742 expectEquals (s6.trimStart().trimEnd(), s6.trim());
2743 expectEquals (s6.trimStart().trimEnd(), s6.trimEnd().trimStart());
2744 expectEquals (s6.trimStart().trimStart().trimEnd().trimEnd(), s6.trimEnd().trimStart());
2745 expect (s6.trimStart() != s6.trimEnd());
2746 expectEquals ((
"\t\r\n " + s6 +
"\t\n \r").
trim(), s6.trim());
2751 beginTest (
"UTF conversions");
2753 TestUTFConversion <CharPointer_UTF32>::test (*
this,
r);
2754 TestUTFConversion <CharPointer_UTF8>::test (*
this,
r);
2755 TestUTFConversion <CharPointer_UTF16>::test (*
this,
r);
2759 beginTest (
"StringArray");
2762 s.addTokens (
"4,3,2,1,0",
";,",
"x");
2763 expectEquals (
s.size(), 5);
2765 expectEquals (
s.joinIntoString (
"-"), String (
"4-3-2-1-0"));
2767 expectEquals (
s.joinIntoString (
"--"), String (
"4--3--1--0"));
2768 expectEquals (
s.joinIntoString (StringRef()), String (
"4310"));
2770 expectEquals (
s.joinIntoString (
"x"), String());
2774 expectEquals (toks.
size(), 3);
2779 expectEquals (toks.
size(), 3);
2784 expectEquals (toks.
size(), 3);
2796 expect (!
v2.equals (v1));
2797 expect (! v1.equals (
v2));
2798 expect (
v2.equals (v3));
2799 expect (! v3.equals (v1));
2800 expect (! v1.equals (v3));
2801 expect (v1.equals (v4));
2802 expect (v4.equals (v1));
2803 expect (v5.equals (v4));
2804 expect (v4.equals (v5));
2805 expect (!
v2.equals (v4));
2806 expect (! v4.equals (
v2));
2810 beginTest (
"Significant figures");
2814 expectEquals (String::toDecimalStringWithSignificantFigures (13, 1), String (
"10"));
2815 expectEquals (String::toDecimalStringWithSignificantFigures (13, 2), String (
"13"));
2816 expectEquals (String::toDecimalStringWithSignificantFigures (13, 3), String (
"13.0"));
2817 expectEquals (String::toDecimalStringWithSignificantFigures (13, 4), String (
"13.00"));
2819 expectEquals (String::toDecimalStringWithSignificantFigures (19368, 1), String (
"20000"));
2820 expectEquals (String::toDecimalStringWithSignificantFigures (19348, 3), String (
"19300"));
2822 expectEquals (String::toDecimalStringWithSignificantFigures (-5, 1), String (
"-5"));
2823 expectEquals (String::toDecimalStringWithSignificantFigures (-5, 3), String (
"-5.00"));
2827 expectEquals (String::toDecimalStringWithSignificantFigures (0, 1), String (
"0"));
2828 expectEquals (String::toDecimalStringWithSignificantFigures (0, 2), String (
"0.0"));
2829 expectEquals (String::toDecimalStringWithSignificantFigures (0, 3), String (
"0.00"));
2833 expectEquals (String::toDecimalStringWithSignificantFigures (19.0, 1), String (
"20"));
2834 expectEquals (String::toDecimalStringWithSignificantFigures (19.0, 2), String (
"19"));
2835 expectEquals (String::toDecimalStringWithSignificantFigures (19.0, 3), String (
"19.0"));
2836 expectEquals (String::toDecimalStringWithSignificantFigures (19.0, 4), String (
"19.00"));
2838 expectEquals (String::toDecimalStringWithSignificantFigures (-5.45, 1), String (
"-5"));
2839 expectEquals (String::toDecimalStringWithSignificantFigures (-5.45, 3), String (
"-5.45"));
2841 expectEquals (String::toDecimalStringWithSignificantFigures (12345.6789, 9), String (
"12345.6789"));
2842 expectEquals (String::toDecimalStringWithSignificantFigures (12345.6789, 8), String (
"12345.679"));
2843 expectEquals (String::toDecimalStringWithSignificantFigures (12345.6789, 5), String (
"12346"));
2845 expectEquals (String::toDecimalStringWithSignificantFigures (0.00028647, 6), String (
"0.000286470"));
2846 expectEquals (String::toDecimalStringWithSignificantFigures (0.0028647, 6), String (
"0.00286470"));
2847 expectEquals (String::toDecimalStringWithSignificantFigures (2.8647, 6), String (
"2.86470"));
2849 expectEquals (String::toDecimalStringWithSignificantFigures (-0.0000000000019, 1), String (
"-0.000000000002"));
2853 beginTest (
"Float trimming");
2856 StringPairArray
tests;
2857 tests.set (
"1",
"1");
2858 tests.set (
"1.0",
"1.0");
2859 tests.set (
"-1",
"-1");
2860 tests.set (
"-100",
"-100");
2861 tests.set (
"110",
"110");
2862 tests.set (
"9090",
"9090");
2863 tests.set (
"1000.0",
"1000.0");
2864 tests.set (
"1.0",
"1.0");
2865 tests.set (
"-1.00",
"-1.0");
2866 tests.set (
"1.20",
"1.2");
2867 tests.set (
"1.300",
"1.3");
2868 tests.set (
"1.301",
"1.301");
2869 tests.set (
"1e",
"1");
2870 tests.set (
"-1e+",
"-1");
2871 tests.set (
"1e-",
"1");
2872 tests.set (
"1e0",
"1");
2873 tests.set (
"1e+0",
"1");
2874 tests.set (
"1e-0",
"1");
2875 tests.set (
"1e000",
"1");
2876 tests.set (
"1e+000",
"1");
2877 tests.set (
"-1e-000",
"-1");
2878 tests.set (
"1e100",
"1e100");
2879 tests.set (
"100e100",
"100e100");
2880 tests.set (
"100.0e0100",
"100.0e100");
2881 tests.set (
"-1e1",
"-1e1");
2882 tests.set (
"1e10",
"1e10");
2883 tests.set (
"-1e+10",
"-1e10");
2884 tests.set (
"1e-10",
"1e-10");
2885 tests.set (
"1e0010",
"1e10");
2886 tests.set (
"1e-0010",
"1e-10");
2887 tests.set (
"1e-1",
"1e-1");
2888 tests.set (
"-1.0e1",
"-1.0e1");
2889 tests.set (
"1.0e-1",
"1.0e-1");
2890 tests.set (
"1.00e-1",
"1.0e-1");
2891 tests.set (
"1.001e1",
"1.001e1");
2892 tests.set (
"1.010e+1",
"1.01e1");
2893 tests.set (
"-1.1000e1",
"-1.1e1");
2895 for (
auto& input :
tests.getAllKeys())
2896 expectEquals (reduceLengthOfFloatString (input),
tests[input]);
2900 std::map<double, String>
tests;
2903 tests[1.01] =
"1.01";
2904 tests[0.76378] =
"7.6378e-1";
2905 tests[-10] =
"-1.0e1";
2906 tests[10.01] =
"1.001e1";
2907 tests[10691.01] =
"1.069101e4";
2908 tests[0.0123] =
"1.23e-2";
2909 tests[-3.7e-27] =
"-3.7e-27";
2913 expectEquals (reduceLengthOfFloatString (String (
test.first, 15,
true)),
test.second);
2918 beginTest (
"Serialisation");
2920 std::map <double, String>
tests;
2922 tests[364] =
"364.0";
2923 tests[1e7] =
"1.0e7";
2924 tests[12345678901] =
"1.2345678901e10";
2926 tests[1234567890123456.7] =
"1.234567890123457e15";
2927 tests[12345678.901234567] =
"1.234567890123457e7";
2928 tests[1234567.8901234567] =
"1.234567890123457e6";
2929 tests[123456.78901234567] =
"123456.7890123457";
2930 tests[12345.678901234567] =
"12345.67890123457";
2931 tests[1234.5678901234567] =
"1234.567890123457";
2932 tests[123.45678901234567] =
"123.4567890123457";
2933 tests[12.345678901234567] =
"12.34567890123457";
2934 tests[1.2345678901234567] =
"1.234567890123457";
2935 tests[0.12345678901234567] =
"0.1234567890123457";
2936 tests[0.012345678901234567] =
"0.01234567890123457";
2937 tests[0.0012345678901234567] =
"0.001234567890123457";
2938 tests[0.00012345678901234567] =
"0.0001234567890123457";
2939 tests[0.000012345678901234567] =
"0.00001234567890123457";
2940 tests[0.0000012345678901234567] =
"1.234567890123457e-6";
2941 tests[0.00000012345678901234567] =
"1.234567890123457e-7";
2945 expectEquals (serialiseDouble (
test.first),
test.second);
2946 expectEquals (serialiseDouble (-
test.first),
"-" +
test.second);
2951 beginTest (
"Loops");
2953 String str (CharPointer_UTF8 (
"\xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf"));
2954 std::vector<juce_wchar> parts { 175, 92, 95, 40, 12484, 41, 95, 47, 175 };
2958 expectEquals (
c, parts[index++]);
2963static StringTests stringUnitTests;
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
ostream & operator<<(ostream &out, const MidiEvent &ev)
Definition InMgr.cpp:9
int64_t int64
Definition basics.h:91
int16_t int16
Definition basics.h:87
int8_t int8
Definition basics.h:85
int32_t int32
Definition basics.h:89
static size_t getBytesRequiredFor(const water_uchar charToWrite) noexcept
Definition CharPointer_UTF8.h:294
void clear()
Definition StringArray.cpp:84
int size() const noexcept
Definition StringArray.h:97
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
Definition StringArray.cpp:270
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Definition StringArray.cpp:311
String replaceSection(int startIndex, int numCharactersToReplace, StringRef stringToInsert) const
Definition String.cpp:1099
~String() noexcept
Definition String.cpp:221
String fromFirstOccurrenceOf(StringRef substringToStartFrom, bool includeSubStringInResult, bool ignoreCase) const
Definition String.cpp:1439
bool isQuotedString() const
Definition String.cpp:1487
static String charToString(water_uchar character)
Definition String.cpp:311
bool startsWithChar(water_uchar character) const noexcept
Definition String.cpp:1276
int indexOfAnyOf(StringRef charactersToLookFor, int startIndex=0, bool ignoreCase=false) const noexcept
Definition String.cpp:788
String trimEnd() const
Definition String.cpp:1572
String trimCharactersAtStart(StringRef charactersToTrim) const
Definition String.cpp:1586
int indexOfWholeWord(StringRef wordToLookFor) const noexcept
Definition String.cpp:931
String trimCharactersAtEnd(StringRef charactersToTrim) const
Definition String.cpp:1596
void append(const String &textToAppend, size_t maxCharsToTake)
Definition String.cpp:628
bool containsChar(water_uchar character) const noexcept
Definition String.cpp:921
static String toHexString(int number)
Definition String.cpp:1830
String upToFirstOccurrenceOf(StringRef substringToEndWith, bool includeSubStringInResult, bool ignoreCase) const
Definition String.cpp:1463
CharPointer_UTF8 toUTF8() const
Definition String.cpp:1906
size_t getByteOffsetOfEnd() const noexcept
Definition String.cpp:461
bool equalsIgnoreCase(const String &other) const noexcept
Definition String.cpp:518
bool isNotEmpty() const noexcept
Definition String.h:244
size_t getNumBytesAsUTF8() const noexcept
Definition String.cpp:1956
bool containsWholeWord(StringRef wordToLookFor) const noexcept
Definition String.cpp:975
float getFloatValue() const noexcept
Definition String.cpp:1783
String retainCharacters(StringRef charactersToRetain) const
Definition String.cpp:1620
bool endsWithIgnoreCase(StringRef text) const noexcept
Definition String.cpp:1313
double getDoubleValue() const noexcept
Definition String.cpp:1784
int length() const noexcept
Definition String.cpp:451
String toUpperCase() const
Definition String.cpp:1331
int64 getLargeIntValue() const noexcept
Definition String.cpp:1782
String substring(int startIndex, int endIndex) const
Definition String.cpp:1373
bool endsWithChar(water_uchar character) const noexcept
Definition String.cpp:1284
String paddedLeft(water_uchar padCharacter, int minimumLength) const
Definition String.cpp:1042
static String createStringFromData(const void *data, int size)
Definition String.cpp:1721
String trimStart() const
Definition String.cpp:1559
bool containsWholeWordIgnoreCase(StringRef wordToLookFor) const noexcept
Definition String.cpp:980
int lastIndexOfAnyOf(StringRef charactersToLookFor, bool ignoreCase=false) const noexcept
Definition String.cpp:904
String & operator+=(const String &stringToAppend)
Definition String.cpp:665
String trim() const
Definition String.cpp:1540
static String repeatedString(StringRef stringToRepeat, int numberOfTimesToRepeat)
Definition String.cpp:1028
String quoted(water_uchar quoteCharacter='"') const
Definition String.cpp:1509
String upToLastOccurrenceOf(StringRef substringToFind, bool includeSubStringInResult, bool ignoreCase) const
Definition String.cpp:1475
String unquoted() const
Definition String.cpp:1495
int getHexValue32() const noexcept
Definition String.cpp:1862
void appendCharPointer(const CharPointer_UTF8 startOfTextToAppend, const CharPointer_UTF8 endOfTextToAppend)
Definition String.cpp:639
String dropLastCharacters(int numberToDrop) const
Definition String.cpp:1429
bool endsWith(StringRef text) const noexcept
Definition String.cpp:1296
const char * toRawUTF8() const
Definition String.cpp:1925
String fromLastOccurrenceOf(StringRef substringToFind, bool includeSubStringInResult, bool ignoreCase) const
Definition String.cpp:1451
int indexOfIgnoreCase(StringRef textToLookFor) const noexcept
Definition String.cpp:813
int hashCode() const noexcept
Definition String.cpp:489
bool matchesWildcard(StringRef wildcard, bool ignoreCase) const noexcept
Definition String.cpp:1022
bool startsWithIgnoreCase(StringRef text) const noexcept
Definition String.cpp:1271
int getIntValue() const noexcept
Definition String.cpp:1781
bool startsWith(StringRef text) const noexcept
Definition String.cpp:1266
int compareNatural(StringRef other, bool isCaseSensitive=false) const noexcept
Definition String.cpp:622
String() noexcept
Definition String.cpp:217
void swapWith(String &other) noexcept
Definition String.cpp:231
String replace(StringRef stringToReplace, StringRef stringToInsertInstead, bool ignoreCase=false) const
Definition String.cpp:1159
bool containsNonWhitespaceChars() const noexcept
Definition String.cpp:1699
int lastIndexOfChar(water_uchar character) const noexcept
Definition String.cpp:776
int compare(const String &other) const noexcept
Definition String.cpp:524
void preallocateBytes(size_t numBytesNeeded)
Definition String.cpp:255
bool containsAnyOf(StringRef charactersItMightContain) const noexcept
Definition String.cpp:1690
String getLastCharacters(int numCharacters) const
Definition String.cpp:1434
int getTrailingIntValue() const noexcept
Definition String.cpp:1786
int64 hashCode64() const noexcept
Definition String.cpp:490
water_uchar getLastCharacter() const noexcept
Definition String.cpp:1368
String & operator=(const String &other) noexcept
Definition String.cpp:242
size_t copyToUTF8(CharPointer_UTF8::CharType *destBuffer, size_t maxBufferSizeBytes) const noexcept
Definition String.cpp:1950
bool containsOnly(StringRef charactersItMightContain) const noexcept
Definition String.cpp:1681
static String fromUTF8(const char *utf8buffer, int bufferSizeBytes=-1)
Definition String.cpp:1961
int compareIgnoreCase(const String &other) const noexcept
Definition String.cpp:526
int64 getHexValue64() const noexcept
Definition String.cpp:1863
int lastIndexOf(StringRef textToLookFor) const noexcept
Definition String.cpp:860
int lastIndexOfIgnoreCase(StringRef textToLookFor) const noexcept
Definition String.cpp:882
String toLowerCase() const
Definition String.cpp:1349
void clear() noexcept
Definition String.cpp:236
String replaceCharacters(StringRef charactersToReplace, StringRef charactersToInsertInstead) const
Definition String.cpp:1240
bool containsIgnoreCase(StringRef text) const noexcept
Definition String.cpp:926
int indexOf(StringRef textToLookFor) const noexcept
Definition String.cpp:808
int getReferenceCount() const noexcept
Definition String.cpp:260
String replaceCharacter(water_uchar characterToReplace, water_uchar characterToInsertInstead) const
Definition String.cpp:1217
bool isEmpty() const noexcept
Definition String.h:238
size_t hash() const noexcept
Definition String.cpp:491
bool contains(StringRef text) const noexcept
Definition String.cpp:916
int indexOfChar(water_uchar characterToLookFor) const noexcept
Definition String.cpp:751
String initialSectionContainingOnly(StringRef permittedCharacters) const
Definition String.cpp:1663
String removeCharacters(StringRef charactersToRemove) const
Definition String.cpp:1642
String initialSectionNotContaining(StringRef charactersToStopAt) const
Definition String.cpp:1672
String paddedRight(water_uchar padCharacter, int minimumLength) const
Definition String.cpp:1069
int indexOfWholeWordIgnoreCase(StringRef wordToLookFor) const noexcept
Definition String.cpp:953
water_uchar operator[](int index) const noexcept
Definition String.cpp:466
std::string toStdString() const
Definition String.cpp:1930
static Type swapIfLittleEndian(Type value) noexcept
Definition juce_ByteOrder.h:78
static Type swapIfBigEndian(Type value) noexcept
Definition juce_ByteOrder.h:67
Definition juce_CharPointer_ASCII.h:38
static bool isValidString(const CharType *dataToTest, int maxBytesToRead)
Definition juce_CharPointer_ASCII.h:363
Definition juce_CharPointer_UTF16.h:35
static bool isByteOrderMarkBigEndian(const void *possibleByteOrder) noexcept
Definition juce_CharPointer_UTF16.h:487
static bool isByteOrderMarkLittleEndian(const void *possibleByteOrder) noexcept
Definition juce_CharPointer_UTF16.h:501
int16 CharType
Definition juce_CharPointer_UTF16.h:40
Definition juce_CharPointer_UTF32.h:35
juce_wchar CharType
Definition juce_CharPointer_UTF32.h:37
Definition juce_CharPointer_UTF8.h:35
void writeAll(const CharPointer src) noexcept
Definition juce_CharPointer_UTF8.h:360
char CharType
Definition juce_CharPointer_UTF8.h:37
static bool isByteOrderMark(const void *possibleByteOrder) noexcept
Definition juce_CharPointer_UTF8.h:555
static bool isValidString(const CharType *dataToTest, int maxBytesToRead)
Definition juce_CharPointer_UTF8.h:498
static int indexOfIgnoreCase(CharPointerType1 haystack, const CharPointerType2 needle) noexcept
Definition juce_CharacterFunctions.h:742
static juce_wchar toLowerCase(juce_wchar character) noexcept
Definition juce_CharacterFunctions.cpp:33
static bool isDigit(char character) noexcept
Definition juce_CharacterFunctions.cpp:69
static bool isLetterOrDigit(char character) noexcept
Definition juce_CharacterFunctions.cpp:90
static juce_wchar toUpperCase(juce_wchar character) noexcept
Definition juce_CharacterFunctions.cpp:28
static juce_wchar getUnicodeCharFromWindows1252Codepage(uint8 windows1252Char) noexcept
Definition juce_CharacterFunctions.cpp:164
Definition juce_HeapBlock.h:87
Definition juce_NewLine.h:40
Definition juce_OutputStream.h:38
virtual bool write(const void *dataToWrite, size_t numberOfBytes)=0
Definition juce_String.cpp:62
static StringHolder * bufferFromText(const CharPointerType charPtr) noexcept
Definition juce_String.cpp:208
void compileTimeChecks()
Definition juce_String.cpp:218
StringHolderUtils()=delete
static CharPointerType createFromCharPointer(const CharPointer start, const CharPointer end)
Definition juce_String.cpp:111
static void release(StringHolder *const b) noexcept
Definition juce_String.cpp:160
static bool isEmptyString(StringHolder *other)
Definition juce_String.cpp:213
~StringHolderUtils()=delete
static int getReferenceCount(const CharPointerType text) noexcept
Definition juce_String.cpp:172
static void release(const CharPointerType text) noexcept
Definition juce_String.cpp:167
StringHolder::CharType CharType
Definition juce_String.cpp:65
static CharPointerType createUninitialisedBytes(size_t numBytes)
Definition juce_String.cpp:67
static CharPointerType createFromCharPointer(const CharPointerType start, const CharPointerType end)
Definition juce_String.cpp:131
static CharPointerType makeUniqueWithByteSize(const CharPointerType text, size_t numBytes)
Definition juce_String.cpp:178
static CharPointerType createFromFixedLength(const char *const src, const size_t numChars)
Definition juce_String.cpp:144
static void retain(const CharPointerType text) noexcept
Definition juce_String.cpp:152
static CharPointerType createFromCharPointer(const CharPointer text)
Definition juce_String.cpp:78
static size_t getAllocatedNumBytes(const CharPointerType text) noexcept
Definition juce_String.cpp:199
StringHolder::CharPointerType CharPointerType
Definition juce_String.cpp:64
static CharPointerType createFromCharPointer(const CharPointer text, size_t maxChars)
Definition juce_String.cpp:90
Definition juce_String.h:53
CharPointerType getCharPointer() const noexcept
Definition juce_String.h:1153
int length() const noexcept
Definition juce_String.cpp:511
bool isEmpty() const noexcept
Definition juce_String.h:310
String() noexcept
Definition juce_String.cpp:234
CharPointer_UTF16 toUTF16() const
Definition juce_String.cpp:2071
const char * toRawUTF8() const
Definition juce_String.cpp:2074
bool containsChar(juce_wchar character) const noexcept
Definition juce_String.cpp:1040
void appendCharPointer(CharPointerType startOfTextToAppend, CharPointerType endOfTextToAppend)
Definition juce_String.cpp:717
int indexOf(StringRef textToLookFor) const noexcept
Definition juce_String.cpp:931
int lastIndexOf(StringRef textToLookFor) const noexcept
Definition juce_String.cpp:979
size_t copyToUTF16(CharPointer_UTF16::CharType *destBuffer, size_t maxBufferSizeBytes) const noexcept
Definition juce_String.cpp:2109
size_t getByteOffsetOfEnd() const noexcept
Definition juce_String.cpp:521
void preallocateBytes(size_t numBytesNeeded)
Definition juce_String.cpp:284
String replaceFirstOccurrenceOf(StringRef stringToReplace, StringRef stringToInsertInstead, bool ignoreCase=false) const
Definition juce_String.cpp:1297
CharPointerType end() const
Definition juce_String.h:949
double getDoubleValue() const noexcept
Definition juce_String.cpp:1874
int indexOfWholeWord(StringRef wordToLookFor) const noexcept
Definition juce_String.cpp:1050
static String createHex(uint8)
Definition juce_String.cpp:1920
size_t copyToUTF32(CharPointer_UTF32::CharType *destBuffer, size_t maxBufferSizeBytes) const noexcept
Definition juce_String.cpp:2114
const wchar_t * toWideCharPointer() const
Definition juce_String.cpp:2079
static String formattedRaw(const char *,...)
Definition juce_String.cpp:1823
int lastIndexOfIgnoreCase(StringRef textToLookFor) const noexcept
Definition juce_String.cpp:1001
static String charToString(juce_wchar character)
Definition juce_String.cpp:359
String substring(int startIndex, int endIndex) const
Definition juce_String.cpp:1498
String replaceSection(int startIndex, int numCharactersToReplace, StringRef stringToInsert) const
Definition juce_String.cpp:1218
CharPointerType text
Definition juce_String.h:1339
int indexOfIgnoreCase(StringRef textToLookFor) const noexcept
Definition juce_String.cpp:936
CharPointer_UTF8 toUTF8() const
Definition juce_String.cpp:2070
int indexOfWholeWordIgnoreCase(StringRef wordToLookFor) const noexcept
Definition juce_String.cpp:1072
bool isNotEmpty() const noexcept
Definition juce_String.h:316
CharPointer_UTF32 toUTF32() const
Definition juce_String.cpp:2072
Definition juce_StringRef.h:62
String stringCopy
Definition juce_StringRef.h:135
operator String::CharPointerType() const noexcept
Definition juce_StringRef.h:98
StringRef(const char *stringLiteral) noexcept
Definition juce_String.cpp:2149
int length() const noexcept
Definition juce_StringRef.h:105
String::CharPointerType text
Definition juce_StringRef.h:130
String getLastCharacters(int numCharacters) const
Definition String.cpp:1434
* e
Definition inflate.c:1404
struct huft * t
Definition inflate.c:943
unsigned v[N_MAX]
Definition inflate.c:1584
unsigned d
Definition inflate.c:940
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
static void v2(register WDL_FFT_REAL *a)
Definition fft.c:1099
static void c2(register WDL_FFT_COMPLEX *a)
Definition fft.c:270
virtual ASIOError start()=0
JSAMPIMAGE data
Definition jpeglib.h:945
#define JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE(...)
Definition juce_CompilerWarnings.h:181
#define JUCE_END_IGNORE_WARNINGS_GCC_LIKE
Definition juce_CompilerWarnings.h:182
#define JUCE_BEGIN_IGNORE_WARNINGS_MSVC(warnings)
Definition juce_CompilerWarnings.h:198
#define JUCE_END_IGNORE_WARNINGS_MSVC
Definition juce_CompilerWarnings.h:199
#define JUCE_API
Definition juce_StandardHeader.h:152
static struct TestCase tests[]
Definition lilv_test.c:2218
#define offsetof(TYPE, MEMBER)
Definition list.h:42
Definition juce_String.cpp:370
static char * numberToString(char *t, int64 n) noexcept
Definition juce_String.cpp:393
static char * printDigits(char *t, Type v) noexcept
Definition juce_String.cpp:378
static String::CharPointerType createFromDouble(double number, int numberOfDecimalPlaces, bool useScientificNotation)
Definition juce_String.cpp:486
@ charsNeededForDouble
Definition juce_String.cpp:374
@ charsNeededForInt
Definition juce_String.cpp:373
static char * doubleToString(char *buffer, double n, int numDecPlaces, bool useScientificNotation, size_t &len) noexcept
Definition juce_String.cpp:469
static String::CharPointerType createFromInteger(IntegerType number)
Definition juce_String.cpp:478
Definition juce_String.cpp:788
String & operationAddAssign(String &str, const T number)
Definition juce_String.cpp:790
JOCTET * buffer
Definition juce_JPEGLoader.cpp:302
Definition carla_juce.cpp:31
static int stringCompareRight(String::CharPointerType s1, String::CharPointerType s2) noexcept
Definition juce_String.cpp:601
constexpr StringHolder emptyString
Definition juce_String.cpp:58
NewLine newLine
Definition juce_String.cpp:28
static size_t findByteOffsetOfEnd(String::CharPointerType text) noexcept
Definition juce_String.cpp:516
unsigned short uint16
Definition juce_MathsFunctions.h:41
unsigned long long uint64
Definition juce_MathsFunctions.h:56
constexpr Type jmin(Type a, Type b)
Definition juce_MathsFunctions.h:106
Type unalignedPointerCast(void *ptr) noexcept
Definition juce_Memory.h:88
static String reduceLengthOfFloatString(const String &input)
Definition juce_String.cpp:2189
unsigned int uint32
Definition juce_MathsFunctions.h:45
constexpr Type jmax(Type a, Type b)
Definition juce_MathsFunctions.h:94
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Definition juce_RangedDirectoryIterator.h:184
static String getStringFromWindows1252Codepage(const char *data, size_t num)
Definition juce_String.cpp:1957
static bool isQuoteCharacter(juce_wchar c) noexcept
Definition juce_String.cpp:1605
static int stringCompareLeft(String::CharPointerType s1, String::CharPointerType s2) noexcept
Definition juce_String.cpp:622
static const juce_wchar emptyChar
Definition juce_String.cpp:2018
int getAddressDifference(Type1 *pointer1, Type2 *pointer2) noexcept
Definition juce_Memory.h:54
static String serialiseDouble(double input)
Definition juce_String.cpp:2260
CharPointer_UTF32 CharPointer_wchar_t
Definition juce_String.cpp:39
long long int64
Definition juce_MathsFunctions.h:54
wchar_t juce_wchar
Definition juce_CharacterFunctions.h:42
static int naturalStringCompare(String::CharPointerType s1, String::CharPointerType s2, bool isCaseSensitive) noexcept
Definition juce_String.cpp:640
static String hexToString(Type v)
Definition juce_String.cpp:1902
static const char hexDigits[]
Definition juce_String.cpp:1899
Type * addBytesToPointer(Type *basePointer, IntegerType bytes) noexcept
Definition juce_Memory.h:111
static String::CharPointerType findTrimmedEnd(const String::CharPointerType start, String::CharPointerType end)
Definition juce_String.cpp:1641
signed int int32
Definition juce_MathsFunctions.h:43
static CharPointer_wchar_t castToCharPointer_wchar_t(const void *t) noexcept
Definition juce_String.cpp:42
unsigned char uint8
Definition juce_MathsFunctions.h:37
constexpr int numElementsInArray(Type(&)[N]) noexcept
Definition juce_MathsFunctions.h:344
void zeromem(void *memory, size_t numBytes) noexcept
Definition juce_Memory.h:28
std::string trim(const char *input, bool(*pred)(char))
Definition ysfx_utils.cpp:288
#define false
Definition ordinals.h:83
png_uint_32 length
Definition png.c:2247
short word
Definition private.h:22
static int test(SerdEnv *env, bool top_level, bool pretty_numbers)
Definition sratom_test.c:79
PreallocationBytes(size_t) noexcept
Definition String.cpp:248
static ResultType parse(CharPointerType t) noexcept
Definition juce_CharacterFunctions.h:497
Definition juce_String.cpp:534
static Type calculate(CharPointer t) noexcept
Definition juce_String.cpp:536
Definition juce_String.cpp:443
StackArrayStream(char *d)
Definition juce_String.cpp:444
size_t writeDouble(double n, int numDecPlaces, bool useScientificNotation)
Definition juce_String.cpp:451
Definition juce_String.h:1343
size_t numBytes
Definition juce_String.h:1345
Definition juce_String.cpp:2092
static size_t copyToBuffer(const CharPointerType_Src source, typename CharPointerType_Dest::CharType *const buffer, const size_t maxBufferSizeBytes)
Definition juce_String.cpp:2093
Definition juce_String.cpp:1310
size_t bytesWritten
Definition juce_String.cpp:1341
StringCreationHelper(size_t initialBytes)
Definition juce_String.cpp:1311
String::CharPointerType source
Definition juce_String.cpp:1340
void write(juce_wchar c)
Definition juce_String.cpp:1324
size_t allocatedBytes
Definition juce_String.cpp:1341
String result
Definition juce_String.cpp:1339
String::CharPointerType dest
Definition juce_String.cpp:1340
StringCreationHelper(const String::CharPointerType s)
Definition juce_String.cpp:1317
static CharPointer_UTF16 convert(const String &source) noexcept
Definition juce_String.cpp:2061
static CharPointer_UTF32 convert(const String &source) noexcept
Definition juce_String.cpp:2067
static CharPointer_UTF8 convert(const String &source) noexcept
Definition juce_String.cpp:2055
Definition juce_String.cpp:2022
static CharPointerType_Dest convert(const String &s)
Definition juce_String.cpp:2023
Definition juce_String.cpp:49
CharType text[1]
Definition juce_String.cpp:55
String::CharPointerType::CharType CharType
Definition juce_String.cpp:51
size_t allocatedNumBytes
Definition juce_String.cpp:54
std::atomic< int > refCount
Definition juce_String.cpp:53
String::CharPointerType CharPointerType
Definition juce_String.cpp:50
Definition juce_String.cpp:1107
static bool characterMatches(const juce_wchar wc, const juce_wchar tc, const bool ignoreCase) noexcept
Definition juce_String.cpp:1125
static bool matches(CharPointer wildcard, CharPointer test, const bool ignoreCase) noexcept
Definition juce_String.cpp:1108
static bool matchesAnywhere(const CharPointer wildcard, CharPointer test, const bool ignoreCase) noexcept
Definition juce_String.cpp:1131
const char * text
Definition swell-functions.h:167
int n
Definition crypt.c:458
return c
Definition crypt.c:175
memcpy(hh, h, RAND_HEAD_LEN)
int r
Definition crypt.c:458
int result
Definition process.c:1455
typedef int(UZ_EXP MsgFn)()
#define const
Definition zconf.h:137