37 using CharType =
char;
54 data =
const_cast<CharType*
> (text);
61 bool operator<= (CharPointer_UTF8
other)
const noexcept {
return data <=
other.data; }
62 bool operator< (CharPointer_UTF8
other)
const noexcept {
return data <
other.data; }
63 bool operator>= (CharPointer_UTF8
other)
const noexcept {
return data >=
other.data; }
64 bool operator> (CharPointer_UTF8
other)
const noexcept {
return data >
other.data; }
70 operator const CharType*()
const noexcept {
return data; }
81 auto byte = (
signed char) *data;
91 while ((n & bit) != 0 && bit > 0x8)
118 auto n = (
signed char) *data++;
124 while ((
static_cast<uint8> (n) & bit) != 0 && bit > 0x8)
127 bit =
static_cast<uint8> (bit >> 1);
139 while ((*--data & 0xc0) == 0x80 && ++count < 4)
149 auto byte = (
signed char) *data++;
159 while ((n & bit) != 0 && bit > 0x8)
248 while ((*d & 0xc0) == 0x80)
277 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6387)
280 JUCE_END_IGNORE_WARNINGS_MSVC
309 template <
class CharPo
inter>
314 while (
auto n = text.getAndAdvance())
344 *data++ = (CharType) (0x80 | (0x3f & (c >> (
numExtraBytes * 6))));
348 *data++ = (CharType) c;
359 template <
typename CharPo
inter>
370 while ((*data = *s) != 0)
381 template <
typename CharPo
inter>
391 template <
typename CharPo
inter>
398 template <
typename CharPo
inter>
405 template <
typename CharPo
inter>
412 template <
typename CharPo
inter>
425 template <
typename CharPo
inter>
432 template <
typename CharPo
inter>
454 bool isDigit()
const noexcept {
const CharType c = *data;
return c >=
'0' && c <=
'9'; }
475 #if JUCE_WINDOWS && ! JUCE_MINGW
509 while ((
byte & bit) != 0)
547 byteOrderMark1 = 0xef,
548 byteOrderMark2 = 0xbb,
549 byteOrderMark3 = 0xbf
557 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182)
561 return c[0] == (
uint8) byteOrderMark1
562 && c[1] == (
uint8) byteOrderMark2
563 && c[2] == (
uint8) byteOrderMark3;
564 JUCE_END_IGNORE_WARNINGS_MSVC
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
int compareIgnoreCase(const CharPointer_UTF8 other) const noexcept
Compares this string with another one.
int indexOf(const juce_wchar charToFind) const noexcept
Returns the character index of a unicode character, or -1 if it isn't found.
int compareUpTo(const CharPointer other, const int maxChars) const noexcept
Compares this string with another one, up to a specified number of characters.
void writeAll(const CharPointer src) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
CharPointer_UTF8 & operator++() noexcept
Moves this pointer along to the next character in the string.
CharPointer_UTF8 findTerminatingNull() const noexcept
Returns a pointer to the null character that terminates this string.
int compareIgnoreCaseUpTo(const CharPointer other, const int maxChars) const noexcept
Compares this string with another one, up to a specified number of characters.
static size_t getBytesRequiredFor(CharPointer text) noexcept
Returns the number of bytes that would be needed to represent the given string in this encoding forma...
void operator+=(int numToSkip) noexcept
Moves this pointer forwards by the specified number of characters.
bool isLetterOrDigit() const noexcept
Returns true if the first character of this string is a letter or digit.
juce_wchar operator*() const noexcept
Returns the unicode character that this pointer is pointing to.
bool isLetter() const noexcept
Returns true if the first character of this string is a letter.
void incrementToEndOfWhitespace() noexcept
Move this pointer to the first non-whitespace character in the string.
size_t lengthUpTo(const CharPointer_UTF8 end) const noexcept
Returns the number of characters in this string, or up to the given end pointer, whichever is lower.
juce_wchar getAndAdvance() noexcept
Returns the character that this pointer is currently pointing to, and then advances the pointer to po...
size_t writeWithDestByteLimit(const CharPointer src, const size_t maxDestBytes) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
bool isNotEmpty() const noexcept
Returns true if this pointer is not pointing to a null character.
size_t lengthUpTo(const size_t maxCharsToCount) const noexcept
Returns the number of characters in this string, or the given value, whichever is lower.
CharPointer_UTF8 operator-(int numToSkip) const noexcept
Returns a pointer which is moved backwards from this one by the specified number of characters.
void operator-=(int numToSkip) noexcept
Moves this pointer backwards by the specified number of characters.
double getDoubleValue() const noexcept
Parses this string as a floating point double.
size_t sizeInBytes() const noexcept
Returns the number of bytes that are used to represent this string.
CharPointer_UTF8 operator--() noexcept
Moves this pointer back to the previous character in the string.
void writeAll(const CharPointer_UTF8 src) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
void writeNull() const noexcept
Writes a null character to this string (leaving the pointer's position unchanged).
bool isEmpty() const noexcept
Returns true if this pointer is pointing to a null character.
juce_wchar toUpperCase() const noexcept
Returns an upper-case version of the first character of this string.
static size_t getBytesRequiredFor(const juce_wchar charToWrite) noexcept
Returns the number of bytes that would be needed to represent the given unicode character in this enc...
int indexOf(const CharPointer stringToFind) const noexcept
Returns the character index of a substring, or -1 if it isn't found.
int64 getIntValue64() const noexcept
Parses this string as a 64-bit integer.
static bool canRepresent(juce_wchar character) noexcept
Returns true if the given unicode character can be represented in this encoding.
int indexOf(const juce_wchar charToFind, const bool ignoreCase) const noexcept
Returns the character index of a unicode character, or -1 if it isn't found.
int getIntValue32() const noexcept
Parses this string as a 32-bit integer.
bool isUpperCase() const noexcept
Returns true if the first character of this string is upper-case.
int compareIgnoreCase(const CharPointer other) const noexcept
Compares this string with another one.
bool isLowerCase() const noexcept
Returns true if the first character of this string is lower-case.
static bool isByteOrderMark(const void *possibleByteOrder) noexcept
Returns true if the first three bytes in this pointer are the UTF8 byte-order mark (BOM).
void writeWithCharLimit(const CharPointer src, const int maxChars) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
CharPointer_UTF8 atomicSwap(const CharPointer_UTF8 newValue)
Atomically swaps this pointer for a new value, returning the previous value.
static bool isValidString(const CharType *dataToTest, int maxBytesToRead)
Returns true if this data contains a valid string in this encoding.
juce_wchar toLowerCase() const noexcept
Returns a lower-case version of the first character of this string.
juce_wchar operator[](int characterIndex) const noexcept
Returns the character at a given character index from the start of the string.
CharPointer_UTF8 operator+(int numToSkip) const noexcept
Returns a pointer which is moved forwards from this one by the specified number of characters.
int compare(const CharPointer other) const noexcept
Compares this string with another one.
bool isWhitespace() const noexcept
Returns true if the first character of this string is whitespace.
bool operator==(CharPointer_UTF8 other) const noexcept
This is a pointer comparison, it doesn't compare the actual text.
CharPointer_UTF8 findEndOfWhitespace() const noexcept
Returns the first non-whitespace character in the string.
bool isDigit() const noexcept
Returns true if the first character of this string is a digit.
void write(const juce_wchar charToWrite) noexcept
Writes a unicode character to this string, and advances this pointer to point to the next position.
CharType * getAddress() const noexcept
Returns the address that this pointer is pointing to.
size_t length() const noexcept
Returns the number of characters in this string.
static void incrementToEndOfWhitespace(Type &text) noexcept
Increments a pointer until it points to the first non-whitespace character in a string.
static int compare(juce_wchar char1, juce_wchar char2) noexcept
Compares two characters.
static juce_wchar toLowerCase(juce_wchar character) noexcept
Converts a character to lower-case.
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 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 compareIgnoreCase(juce_wchar char1, juce_wchar char2) noexcept
Compares two characters, using a case-independant match.
static bool isLowerCase(juce_wchar character) noexcept
Checks whether a unicode character is lower-case.
static bool isLetter(char character) noexcept
Checks whether a character is alphabetic.
static int indexOf(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
Finds the character index of a given substring in another string.
static bool isWhitespace(char character) noexcept
Checks whether a character is whitespace.
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 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 bool isLetterOrDigit(char character) noexcept
Checks whether a character is alphabetic or numeric.
static juce_wchar toUpperCase(juce_wchar character) noexcept
Converts a character to upper-case.
static bool isUpperCase(juce_wchar character) noexcept
Checks whether a unicode character is upper-case.
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.
wchar_t juce_wchar
A platform-independent 32-bit unicode character type.
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Returns a default-constructed sentinel value.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
long long int64
A platform-independent 64-bit integer type.
A simple wrapper around std::atomic.