27#if JUCE_WINDOWS && ! defined (DOXYGEN)
28 #define JUCE_NATIVE_WCHAR_IS_UTF8 0
29 #define JUCE_NATIVE_WCHAR_IS_UTF16 1
30 #define JUCE_NATIVE_WCHAR_IS_UTF32 0
33 #define JUCE_NATIVE_WCHAR_IS_UTF8 0
35 #define JUCE_NATIVE_WCHAR_IS_UTF16 0
37 #define JUCE_NATIVE_WCHAR_IS_UTF32 1
40#if JUCE_NATIVE_WCHAR_IS_UTF32 || DOXYGEN
42 using juce_wchar = wchar_t;
44 using juce_wchar = uint32;
49 #define JUCE_T(stringLiteral) (L##stringLiteral)
52#if JUCE_DEFINE_T_MACRO
60 #define T(stringLiteral) JUCE_T(stringLiteral)
69 template <
typename Type>
struct make_unsigned {
using type = Type; };
70 template <>
struct make_unsigned<signed char> {
using type =
unsigned char; };
71 template <>
struct make_unsigned<char> {
using type =
unsigned char; };
72 template <>
struct make_unsigned<short> {
using type =
unsigned short; };
73 template <>
struct make_unsigned<int> {
using type =
unsigned int; };
74 template <>
struct make_unsigned<long> {
using type =
unsigned long; };
75 template <>
struct make_unsigned<long long> {
using type =
unsigned long long; };
96 static juce_wchar toUpperCase (juce_wchar
character)
noexcept;
98 static juce_wchar toLowerCase (juce_wchar
character)
noexcept;
101 static bool isUpperCase (juce_wchar
character)
noexcept;
103 static bool isLowerCase (juce_wchar
character)
noexcept;
106 static bool isWhitespace (
char character)
noexcept;
108 static bool isWhitespace (juce_wchar
character)
noexcept;
111 static bool isDigit (
char character)
noexcept;
113 static bool isDigit (juce_wchar
character)
noexcept;
116 static bool isLetter (
char character)
noexcept;
118 static bool isLetter (juce_wchar
character)
noexcept;
121 static bool isLetterOrDigit (
char character)
noexcept;
123 static bool isLetterOrDigit (juce_wchar
character)
noexcept;
128 static bool isPrintable (
char character)
noexcept;
133 static bool isPrintable (juce_wchar
character)
noexcept;
136 static int getHexDigitValue (juce_wchar
digit)
noexcept;
139 static juce_wchar getUnicodeCharFromWindows1252Codepage (uint8
windows1252Char)
noexcept;
146 template <
typename CharPo
interType>
149 constexpr auto inf = std::numeric_limits<double>::infinity();
151 bool isNegative =
false;
155 char buffer[(
size_t) bufferSize] = {};
184 if ((text[1] ==
'a' || text[1] ==
'A') && (text[2] ==
'n' || text[2] ==
'N'))
187 return std::numeric_limits<double>::quiet_NaN();
197 if ((text[1] ==
'n' || text[1] ==
'N') && (text[2] ==
'f' || text[2] ==
'F'))
200 return isNegative ? -
inf :
inf;
226 digit = (
int) text.getAndAdvance() -
'0';
247 while (text.isDigit())
276 while (text.isDigit())
303 while (text.isDigit())
314 return isNegative ? -r : r;
325 auto digit = (
int) text.getAndAdvance() -
'0';
385 if (c ==
'e' || c ==
'E')
406 while (text.isDigit())
408 auto digit = (
int) text.getAndAdvance() -
'0';
421 if (
exponent < std::numeric_limits<double>::min_exponent10 - 1)
422 return isNegative ? -0.0 : 0.0;
427 else if (
exponent > std::numeric_limits<double>::max_exponent10 + 1)
429 return isNegative ? -
inf :
inf;
456 template <
typename CharPo
interType>
459 return readDoubleValue (text);
464 template <
typename IntType,
typename CharPo
interType>
470 auto s = text.findEndOfWhitespace();
471 const bool isNeg = *s ==
'-';
478 auto c = s.getAndAdvance();
480 if (c >=
'0' && c <=
'9')
490 template <
typename ResultType>
493 static_assert (std::is_unsigned_v<ResultType>,
"ResultType must be unsigned because "
494 "left-shifting a negative value is UB");
496 template <
typename CharPo
interType>
497 static ResultType parse (CharPointerType
t)
noexcept
501 while (!
t.isEmpty())
503 auto hexValue = CharacterFunctions::getHexDigitValue (
t.getAndAdvance());
516 template <
typename CharPo
interType>
529 template <
typename CharPo
interType>
530 static size_t lengthUpTo (CharPointerType start,
const CharPointerType end)
noexcept
534 while (start < end && start.getAndAdvance() != 0)
541 template <
typename DestCharPo
interType,
typename SrcCharPo
interType>
544 while (
auto c =
src.getAndAdvance())
552 template <
typename DestCharPo
interType,
typename SrcCharPo
interType>
561 auto c =
src.getAndAdvance();
573 return (
size_t) getAddressDifference (dest.getAddress(),
startAddress)
574 +
sizeof (
typename DestCharPointerType::CharType);
579 template <
typename DestCharPo
interType,
typename SrcCharPo
interType>
584 auto c =
src.getAndAdvance();
598 if (
auto diff =
static_cast<int> (
char1) -
static_cast<int> (
char2))
599 return diff < 0 ? -1 : 1;
605 template <
typename CharPo
interType1,
typename CharPo
interType2>
610 auto c1 = s1.getAndAdvance();
612 if (
auto diff = compare (
c1, s2.getAndAdvance()))
623 template <
typename CharPo
interType1,
typename CharPo
interType2>
628 auto c1 = s1.getAndAdvance();
630 if (
auto diff = compare (
c1, s2.getAndAdvance()))
647 template <
typename CharPo
interType1,
typename CharPo
interType2>
652 auto c1 = s1.getAndAdvance();
654 if (
auto diff = compareIgnoreCase (
c1, s2.getAndAdvance()))
665 template <
typename CharPo
interType1,
typename CharPo
interType2>
670 auto c1 = s1.getAndAdvance();
672 if (
auto diff = compareIgnoreCase (
c1, s2.getAndAdvance()))
685 template <
typename CharPo
interType1,
typename CharPo
interType2>
707 template <
typename CharPo
interType1,
typename CharPo
interType2>
723 template <
typename CharPo
interType>
741 template <
typename CharPo
interType1,
typename CharPo
interType2>
762 template <
typename Type>
767 while (! text.isEmpty())
782 template <
typename Type>
788 while (! text.isEmpty())
806 template <
typename Type>
809 while (text.isWhitespace())
817 template <
typename Type>
820 incrementToEndOfWhitespace (text);
827 template <
typename Type,
typename BreakType>
832 while (! text.isEmpty())
834 auto c = text.getAndAdvance();
855 static double mulexp10 (
double value,
int exponent)
noexcept;
static int indexOfIgnoreCase(CharPointerType1 haystack, const CharPointerType2 needle) noexcept
static void incrementToEndOfWhitespace(Type &text) noexcept
static int compare(juce_wchar char1, juce_wchar char2) noexcept
static size_t copyWithDestByteLimit(DestCharPointerType &dest, SrcCharPointerType src, size_t maxBytesToWrite) noexcept
static int indexOfCharIgnoreCase(Type text, juce_wchar charToFind) noexcept
static IntType getIntValue(const CharPointerType text) noexcept
static int compareIgnoreCaseUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
static int indexOfChar(Type text, const juce_wchar charToFind) noexcept
static int compare(CharPointerType1 s1, CharPointerType2 s2) noexcept
static int compareIgnoreCase(juce_wchar char1, juce_wchar char2) noexcept
static size_t lengthUpTo(CharPointerType start, const CharPointerType end) noexcept
static int indexOf(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
static size_t lengthUpTo(CharPointerType text, const size_t maxCharsToCount) noexcept
static double readDoubleValue(CharPointerType &text) noexcept
static CharPointerType find(CharPointerType textToSearch, const juce_wchar charToLookFor) noexcept
static Type findEndOfWhitespace(Type text) noexcept
static void copyWithCharLimit(DestCharPointerType &dest, SrcCharPointerType src, int maxChars) noexcept
static Type findEndOfToken(Type text, BreakType breakCharacters, Type quoteCharacters)
static CharPointerType1 find(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
static int compareIgnoreCase(CharPointerType1 s1, CharPointerType2 s2) noexcept
static double getDoubleValue(CharPointerType text) noexcept
static void copyAll(DestCharPointerType &dest, SrcCharPointerType src) noexcept
static int compareUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept