31#if JUCE_WINDOWS && ! DOXYGEN
32 #define JUCE_NATIVE_WCHAR_IS_UTF8 0
33 #define JUCE_NATIVE_WCHAR_IS_UTF16 1
34 #define JUCE_NATIVE_WCHAR_IS_UTF32 0
37 #define JUCE_NATIVE_WCHAR_IS_UTF8 0
39 #define JUCE_NATIVE_WCHAR_IS_UTF16 0
41 #define JUCE_NATIVE_WCHAR_IS_UTF32 1
44#if JUCE_NATIVE_WCHAR_IS_UTF32 || DOXYGEN
46 using juce_wchar = wchar_t;
48 using juce_wchar = uint32;
53 #define JUCE_T(stringLiteral) (L##stringLiteral)
56#if JUCE_DEFINE_T_MACRO
64 #define T(stringLiteral) JUCE_T(stringLiteral)
73 template <
typename Type>
struct make_unsigned {
using type = Type; };
74 template <>
struct make_unsigned<signed char> {
using type =
unsigned char; };
75 template <>
struct make_unsigned<char> {
using type =
unsigned char; };
76 template <>
struct make_unsigned<short> {
using type =
unsigned short; };
77 template <>
struct make_unsigned<int> {
using type =
unsigned int; };
78 template <>
struct make_unsigned<long> {
using type =
unsigned long; };
79 template <>
struct make_unsigned<long long> {
using type =
unsigned long long; };
100 static juce_wchar toUpperCase (juce_wchar
character)
noexcept;
102 static juce_wchar toLowerCase (juce_wchar
character)
noexcept;
105 static bool isUpperCase (juce_wchar
character)
noexcept;
107 static bool isLowerCase (juce_wchar
character)
noexcept;
110 static bool isWhitespace (
char character)
noexcept;
112 static bool isWhitespace (juce_wchar
character)
noexcept;
115 static bool isDigit (
char character)
noexcept;
117 static bool isDigit (juce_wchar
character)
noexcept;
120 static bool isLetter (
char character)
noexcept;
122 static bool isLetter (juce_wchar
character)
noexcept;
125 static bool isLetterOrDigit (
char character)
noexcept;
127 static bool isLetterOrDigit (juce_wchar
character)
noexcept;
132 static bool isPrintable (
char character)
noexcept;
137 static bool isPrintable (juce_wchar
character)
noexcept;
140 static int getHexDigitValue (juce_wchar
digit)
noexcept;
143 static juce_wchar getUnicodeCharFromWindows1252Codepage (uint8
windows1252Char)
noexcept;
150 template <
typename CharPo
interType>
154 bool isNegative =
false;
158 char buffer[bufferSize] = {};
162 text = text.findEndOfWhitespace();
182 if ((text[1] ==
'a' || text[1] ==
'A') && (text[2] ==
'n' || text[2] ==
'N'))
183 return std::numeric_limits<double>::quiet_NaN();
188 if ((text[1] ==
'n' || text[1] ==
'N') && (text[2] ==
'f' || text[2] ==
'F'))
189 return std::numeric_limits<double>::infinity();
208 digit = (
int) text.getAndAdvance() -
'0';
229 while (text.isDigit())
258 while (text.isDigit())
285 while (text.isDigit())
296 return isNegative ? -r : r;
308 auto digit = (
int) text.getAndAdvance() -
'0';
372 while (text.isDigit())
374 auto digit = (
int) text.getAndAdvance() -
'0';
387 if (
exponent > std::numeric_limits<double>::max_exponent10)
388 return std::numeric_limits<double>::quiet_NaN();
414 template <
typename CharPo
interType>
417 return readDoubleValue (text);
422 template <
typename IntType,
typename CharPo
interType>
425 using UIntType =
typename internal::make_unsigned<IntType>::type;
428 auto s = text.findEndOfWhitespace();
429 const bool isNeg = *
s ==
'-';
436 auto c =
s.getAndAdvance();
438 if (
c >=
'0' &&
c <=
'9')
448 template <
typename ResultType>
451 template <
typename CharPo
interType>
452 static ResultType parse (CharPointerType
t)
noexcept
458 auto hexValue = CharacterFunctions::getHexDigitValue (
t.getAndAdvance());
471 template <
typename CharPo
interType>
484 template <
typename CharPo
interType>
485 static size_t lengthUpTo (CharPointerType start,
const CharPointerType end)
noexcept
489 while (start < end && start.getAndAdvance() != 0)
496 template <
typename DestCharPo
interType,
typename SrcCharPo
interType>
499 while (
auto c =
src.getAndAdvance())
507 template <
typename DestCharPo
interType,
typename SrcCharPo
interType>
512 maxBytes -=
sizeof (
typename DestCharPointerType::CharType);
516 auto c =
src.getAndAdvance();
517 auto bytesNeeded = DestCharPointerType::getBytesRequiredFor (
c);
528 return (
size_t) getAddressDifference (dest.getAddress(),
startAddress)
529 +
sizeof (
typename DestCharPointerType::CharType);
534 template <
typename DestCharPo
interType,
typename SrcCharPo
interType>
539 auto c =
src.getAndAdvance();
553 if (
auto diff =
static_cast<int> (
char1) -
static_cast<int> (
char2))
554 return diff < 0 ? -1 : 1;
560 template <
typename CharPo
interType1,
typename CharPo
interType2>
565 auto c1 =
s1.getAndAdvance();
567 if (
auto diff = compare (
c1,
s2.getAndAdvance()))
578 template <
typename CharPo
interType1,
typename CharPo
interType2>
583 auto c1 =
s1.getAndAdvance();
585 if (
auto diff = compare (
c1,
s2.getAndAdvance()))
602 template <
typename CharPo
interType1,
typename CharPo
interType2>
607 auto c1 =
s1.getAndAdvance();
609 if (
auto diff = compareIgnoreCase (
c1,
s2.getAndAdvance()))
620 template <
typename CharPo
interType1,
typename CharPo
interType2>
625 auto c1 =
s1.getAndAdvance();
627 if (
auto diff = compareIgnoreCase (
c1,
s2.getAndAdvance()))
640 template <
typename CharPo
interType1,
typename CharPo
interType2>
662 template <
typename CharPo
interType1,
typename CharPo
interType2>
678 template <
typename CharPo
interType>
696 template <
typename CharPo
interType1,
typename CharPo
interType2>
717 template <
typename Type>
722 while (! text.isEmpty())
737 template <
typename Type>
743 while (! text.isEmpty())
759 template <
typename Type>
762 while (text.isWhitespace())
771 template <
typename Type,
typename BreakType>
776 while (! text.isEmpty())
778 auto c = text.getAndAdvance();
799 static double mulexp10 (
double value,
int exponent)
noexcept;
Holds a resizable array of primitive or copy-by-value objects.
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
int indexOf(ParameterType elementToLookFor) const
Finds the index of the first element which matches the value passed in.
A collection of functions for manipulating characters and character strings.
static int indexOfIgnoreCase(CharPointerType1 haystack, const CharPointerType2 needle) noexcept
Finds the character index of a given substring in another string, using a case-independent match.
static int compare(juce_wchar char1, juce_wchar char2) noexcept
Compares two characters.
static size_t copyWithDestByteLimit(DestCharPointerType &dest, SrcCharPointerType src, size_t maxBytesToWrite) noexcept
Copies characters from one string to another, up to a null terminator or a given byte size limit.
static int indexOfCharIgnoreCase(Type text, juce_wchar charToFind) noexcept
Finds the character index of a given character in another string, using a case-independent match.
static IntType getIntValue(const CharPointerType text) noexcept
Parses a character string, to read an integer value.
static int compareIgnoreCaseUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
Compares two null-terminated character strings, using a case-independent match.
static int indexOfChar(Type text, const juce_wchar charToFind) noexcept
Finds the character index of a given character in another string.
static int compare(CharPointerType1 s1, CharPointerType2 s2) noexcept
Compares two null-terminated character strings.
static int compareIgnoreCase(juce_wchar char1, juce_wchar char2) noexcept
Compares two characters, using a case-independant match.
static size_t lengthUpTo(CharPointerType start, const CharPointerType end) noexcept
Counts the number of characters in a given string, stopping if the count exceeds a specified end-poin...
static int indexOf(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
Finds the character index of a given substring in another string.
static size_t lengthUpTo(CharPointerType text, const size_t maxCharsToCount) noexcept
Counts the number of characters in a given string, stopping if the count exceeds a specified limit.
static double readDoubleValue(CharPointerType &text) noexcept
Parses a character string to read a floating-point number.
static CharPointerType find(CharPointerType textToSearch, const juce_wchar charToLookFor) noexcept
Returns a pointer to the first occurrence of a substring in a string.
static Type findEndOfWhitespace(Type text) noexcept
Returns a pointer to the first non-whitespace character in a string.
static void copyWithCharLimit(DestCharPointerType &dest, SrcCharPointerType src, int maxChars) noexcept
Copies characters from one string to another, up to a null terminator or a given maximum number of ch...
static Type findEndOfToken(Type text, BreakType breakCharacters, Type quoteCharacters)
Returns a pointer to the first character in the string which is found in the breakCharacters string.
static CharPointerType1 find(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
Returns a pointer to the first occurrence of a substring in a string.
static int compareIgnoreCase(CharPointerType1 s1, CharPointerType2 s2) noexcept
Compares two null-terminated character strings, using a case-independant match.
static double getDoubleValue(CharPointerType text) noexcept
Parses a character string, to read a floating-point value.
static void copyAll(DestCharPointerType &dest, SrcCharPointerType src) noexcept
Copies null-terminated characters from one string to another.
static int compareUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
Compares two null-terminated character strings, up to a given number of characters.
#define JUCE_API
This macro is added to all JUCE public class declarations.
Parses a character string, to read a hexadecimal value.