JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::CharPointer_UTF16 Class Referencefinal

Wraps a pointer to a null-terminated UTF-16 character string, and provides various methods to operate on the data. More...

#include <juce_CharPointer_UTF16.h>

Collaboration diagram for juce::CharPointer_UTF16:

Public Types

enum  {
  byteOrderMarkBE1 = 0xfe,
  byteOrderMarkBE2 = 0xff,
  byteOrderMarkLE1 = 0xff,
  byteOrderMarkLE2 = 0xfe
}
 These values are the byte-order-mark (BOM) values for a UTF-16 stream. More...
 
using CharType = int16
 

Public Member Functions

 CharPointer_UTF16 (const CharType *rawPointer) noexcept
 
 CharPointer_UTF16 (const CharPointer_UTF16 &other) noexcept
 
CharPointer_UTF16 atomicSwap (CharPointer_UTF16 newValue)
 Atomically swaps this pointer for a new value, returning the previous value. More...
 
template<typename CharPointer >
int compare (CharPointer other) const noexcept
 Compares this string with another one. More...
 
template<typename CharPointer >
int compareIgnoreCase (CharPointer other) const noexcept
 Compares this string with another one. More...
 
template<typename CharPointer >
int compareIgnoreCaseUpTo (CharPointer other, int maxChars) const noexcept
 Compares this string with another one, up to a specified number of characters. More...
 
template<typename CharPointer >
int compareUpTo (CharPointer other, int maxChars) const noexcept
 Compares this string with another one, up to a specified number of characters. More...
 
CharPointer_UTF16 findEndOfWhitespace () const noexcept
 Returns the first non-whitespace character in the string. More...
 
CharPointer_UTF16 findTerminatingNull () const noexcept
 Returns a pointer to the null character that terminates this string. More...
 
CharTypegetAddress () const noexcept
 Returns the address that this pointer is pointing to. More...
 
juce_wchar getAndAdvance () noexcept
 Returns the character that this pointer is currently pointing to, and then advances the pointer to point to the next character. More...
 
double getDoubleValue () const noexcept
 Parses this string as a floating point double. More...
 
int getIntValue32 () const noexcept
 Parses this string as a 32-bit integer. More...
 
int64 getIntValue64 () const noexcept
 Parses this string as a 64-bit integer. More...
 
template<typename CharPointer >
int indexOf (CharPointer stringToFind) const noexcept
 Returns the character index of a substring, or -1 if it isn't found. More...
 
int indexOf (juce_wchar charToFind) const noexcept
 Returns the character index of a unicode character, or -1 if it isn't found. More...
 
int indexOf (juce_wchar charToFind, bool ignoreCase) const noexcept
 Returns the character index of a unicode character, or -1 if it isn't found. More...
 
bool isDigit () const noexcept
 Returns true if the first character of this string is a digit. More...
 
bool isEmpty () const noexcept
 Returns true if this pointer is pointing to a null character. More...
 
bool isLetter () const noexcept
 Returns true if the first character of this string is a letter. More...
 
bool isLetterOrDigit () const noexcept
 Returns true if the first character of this string is a letter or digit. More...
 
bool isLowerCase () const noexcept
 Returns true if the first character of this string is lower-case. More...
 
bool isNotEmpty () const noexcept
 Returns true if this pointer is not pointing to a null character. More...
 
bool isUpperCase () const noexcept
 Returns true if the first character of this string is upper-case. More...
 
bool isWhitespace () const noexcept
 Returns true if the first character of this string is whitespace. More...
 
size_t length () const noexcept
 Returns the number of characters in this string. More...
 
size_t lengthUpTo (size_t maxCharsToCount) const noexcept
 Returns the number of characters in this string, or the given value, whichever is lower. More...
 
size_t lengthUpTo (CharPointer_UTF16 end) const noexcept
 Returns the number of characters in this string, or up to the given end pointer, whichever is lower. More...
 
 operator const CharType * () const noexcept
 Returns the address that this pointer is pointing to. More...
 
bool operator!= (CharPointer_UTF16 other) const noexcept
 
juce_wchar operator* () const noexcept
 Returns the unicode character that this pointer is pointing to. More...
 
CharPointer_UTF16 operator+ (int numToSkip) const noexcept
 Returns a pointer which is moved forwards from this one by the specified number of characters. More...
 
CharPointer_UTF16 operator++ () noexcept
 Moves this pointer along to the next character in the string. More...
 
CharPointer_UTF16 operator++ (int) noexcept
 Moves this pointer along to the next character in the string. More...
 
void operator+= (int numToSkip) noexcept
 Moves this pointer forwards by the specified number of characters. More...
 
CharPointer_UTF16 operator- (int numToSkip) const noexcept
 Returns a pointer which is moved backwards from this one by the specified number of characters. More...
 
CharPointer_UTF16 operator-- () noexcept
 Moves this pointer back to the previous character in the string. More...
 
void operator-= (int numToSkip) noexcept
 Moves this pointer backwards by the specified number of characters. More...
 
bool operator< (CharPointer_UTF16 other) const noexcept
 
bool operator<= (CharPointer_UTF16 other) const noexcept
 
CharPointer_UTF16 operator= (CharPointer_UTF16 other) noexcept
 
CharPointer_UTF16 operator= (const CharType *text) noexcept
 
bool operator== (CharPointer_UTF16 other) const noexcept
 This is a pointer comparison, it doesn't compare the actual text. More...
 
bool operator> (CharPointer_UTF16 other) const noexcept
 
bool operator>= (CharPointer_UTF16 other) const noexcept
 
juce_wchar operator[] (int characterIndex) const noexcept
 Returns the character at a given character index from the start of the string. More...
 
size_t sizeInBytes () const noexcept
 Returns the number of bytes that are used to represent this string. More...
 
juce_wchar toLowerCase () const noexcept
 Returns a lower-case version of the first character of this string. More...
 
juce_wchar toUpperCase () const noexcept
 Returns an upper-case version of the first character of this string. More...
 
void write (juce_wchar charToWrite) noexcept
 Writes a unicode character to this string, and advances this pointer to point to the next position. More...
 
template<typename CharPointer >
void writeAll (CharPointer src) noexcept
 Copies a source string to this pointer, advancing this pointer as it goes. More...
 
void writeAll (CharPointer_UTF16 src) noexcept
 Copies a source string to this pointer, advancing this pointer as it goes. More...
 
void writeNull () const noexcept
 Writes a null character to this string (leaving the pointer's position unchanged). More...
 
template<typename CharPointer >
void writeWithCharLimit (CharPointer src, int maxChars) noexcept
 Copies a source string to this pointer, advancing this pointer as it goes. More...
 
template<typename CharPointer >
size_t writeWithDestByteLimit (CharPointer src, size_t maxDestBytes) noexcept
 Copies a source string to this pointer, advancing this pointer as it goes. More...
 

Static Public Member Functions

static bool canRepresent (juce_wchar character) noexcept
 Returns true if the given unicode character can be represented in this encoding. More...
 
static size_t getBytesRequiredFor (juce_wchar charToWrite) noexcept
 Returns the number of bytes that would be needed to represent the given unicode character in this encoding format. More...
 
template<class CharPointer >
static size_t getBytesRequiredFor (CharPointer text) noexcept
 Returns the number of bytes that would be needed to represent the given string in this encoding format. More...
 
static bool isByteOrderMarkBigEndian (const void *possibleByteOrder) noexcept
 Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (big endian). More...
 
static bool isByteOrderMarkLittleEndian (const void *possibleByteOrder) noexcept
 Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (little endian). More...
 
static bool isValidString (const CharType *dataToTest, int maxBytesToRead)
 Returns true if this data contains a valid string in this encoding. More...
 

Static Private Member Functions

static unsigned int findNullIndex (const CharType *t) noexcept
 

Private Attributes

CharTypedata
 

Detailed Description

Wraps a pointer to a null-terminated UTF-16 character string, and provides various methods to operate on the data.

See also
CharPointer_UTF8, CharPointer_UTF32

{Core}

Member Typedef Documentation

◆ CharType

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

These values are the byte-order-mark (BOM) values for a UTF-16 stream.

Enumerator
byteOrderMarkBE1 
byteOrderMarkBE2 
byteOrderMarkLE1 
byteOrderMarkLE2 

Constructor & Destructor Documentation

◆ CharPointer_UTF16() [1/2]

juce::CharPointer_UTF16::CharPointer_UTF16 ( const CharType rawPointer)
inlineexplicitnoexcept

Referenced by atomicSwap(), and findTerminatingNull().

◆ CharPointer_UTF16() [2/2]

juce::CharPointer_UTF16::CharPointer_UTF16 ( const CharPointer_UTF16 other)
inlinenoexcept

Member Function Documentation

◆ atomicSwap()

CharPointer_UTF16 juce::CharPointer_UTF16::atomicSwap ( CharPointer_UTF16  newValue)
inline

Atomically swaps this pointer for a new value, returning the previous value.

References CharPointer_UTF16(), and data.

◆ canRepresent()

static bool juce::CharPointer_UTF16::canRepresent ( juce_wchar  character)
inlinestaticnoexcept

Returns true if the given unicode character can be represented in this encoding.

◆ compare()

template<typename CharPointer >
int juce::CharPointer_UTF16::compare ( CharPointer  other) const
inlinenoexcept

Compares this string with another one.

References juce::CharacterFunctions::compare().

◆ compareIgnoreCase()

template<typename CharPointer >
int juce::CharPointer_UTF16::compareIgnoreCase ( CharPointer  other) const
inlinenoexcept

Compares this string with another one.

References juce::CharacterFunctions::compareIgnoreCase().

Referenced by compareIgnoreCaseUpTo().

◆ compareIgnoreCaseUpTo()

template<typename CharPointer >
int juce::CharPointer_UTF16::compareIgnoreCaseUpTo ( CharPointer  other,
int  maxChars 
) const
inlinenoexcept

Compares this string with another one, up to a specified number of characters.

References compareIgnoreCase(), juce::CharacterFunctions::compareIgnoreCaseUpTo(), data, getAddress(), indexOf(), and int().

◆ compareUpTo()

template<typename CharPointer >
int juce::CharPointer_UTF16::compareUpTo ( CharPointer  other,
int  maxChars 
) const
inlinenoexcept

Compares this string with another one, up to a specified number of characters.

References juce::CharacterFunctions::compareUpTo().

◆ findEndOfWhitespace()

CharPointer_UTF16 juce::CharPointer_UTF16::findEndOfWhitespace ( ) const
inlinenoexcept

Returns the first non-whitespace character in the string.

References juce::CharacterFunctions::findEndOfWhitespace().

◆ findNullIndex()

static unsigned int juce::CharPointer_UTF16::findNullIndex ( const CharType t)
inlinestaticprivatenoexcept

Referenced by sizeInBytes().

◆ findTerminatingNull()

CharPointer_UTF16 juce::CharPointer_UTF16::findTerminatingNull ( ) const
inlinenoexcept

Returns a pointer to the null character that terminates this string.

References CharPointer_UTF16(), and data.

◆ getAddress()

CharType* juce::CharPointer_UTF16::getAddress ( ) const
inlinenoexcept

Returns the address that this pointer is pointing to.

References data.

Referenced by compareIgnoreCaseUpTo().

◆ getAndAdvance()

juce_wchar juce::CharPointer_UTF16::getAndAdvance ( )
inlinenoexcept

Returns the character that this pointer is currently pointing to, and then advances the pointer to point to the next character.

References data.

◆ getBytesRequiredFor() [1/2]

static size_t juce::CharPointer_UTF16::getBytesRequiredFor ( juce_wchar  charToWrite)
inlinestaticnoexcept

Returns the number of bytes that would be needed to represent the given unicode character in this encoding format.

Referenced by getBytesRequiredFor().

◆ getBytesRequiredFor() [2/2]

template<class CharPointer >
static size_t juce::CharPointer_UTF16::getBytesRequiredFor ( CharPointer  text)
inlinestaticnoexcept

Returns the number of bytes that would be needed to represent the given string in this encoding format.

The value returned does NOT include the terminating null character.

References getBytesRequiredFor().

◆ getDoubleValue()

double juce::CharPointer_UTF16::getDoubleValue ( ) const
inlinenoexcept

Parses this string as a floating point double.

References juce::CharacterFunctions::getDoubleValue().

◆ getIntValue32()

int juce::CharPointer_UTF16::getIntValue32 ( ) const
inlinenoexcept

Parses this string as a 32-bit integer.

References data.

◆ getIntValue64()

int64 juce::CharPointer_UTF16::getIntValue64 ( ) const
inlinenoexcept

Parses this string as a 64-bit integer.

References data.

◆ indexOf() [1/3]

template<typename CharPointer >
int juce::CharPointer_UTF16::indexOf ( CharPointer  stringToFind) const
inlinenoexcept

Returns the character index of a substring, or -1 if it isn't found.

References juce::CharacterFunctions::indexOf().

Referenced by compareIgnoreCaseUpTo().

◆ indexOf() [2/3]

int juce::CharPointer_UTF16::indexOf ( juce_wchar  charToFind) const
inlinenoexcept

Returns the character index of a unicode character, or -1 if it isn't found.

References juce::CharacterFunctions::indexOfChar().

◆ indexOf() [3/3]

int juce::CharPointer_UTF16::indexOf ( juce_wchar  charToFind,
bool  ignoreCase 
) const
inlinenoexcept

Returns the character index of a unicode character, or -1 if it isn't found.

References juce::CharacterFunctions::indexOfChar(), and juce::CharacterFunctions::indexOfCharIgnoreCase().

◆ isByteOrderMarkBigEndian()

static bool juce::CharPointer_UTF16::isByteOrderMarkBigEndian ( const void *  possibleByteOrder)
inlinestaticnoexcept

Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (big endian).

The pointer must not be null, and must contain at least two valid bytes.

References byteOrderMarkBE1, byteOrderMarkBE2, and jassert.

◆ isByteOrderMarkLittleEndian()

static bool juce::CharPointer_UTF16::isByteOrderMarkLittleEndian ( const void *  possibleByteOrder)
inlinestaticnoexcept

Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (little endian).

The pointer must not be null, and must contain at least two valid bytes.

References byteOrderMarkLE1, byteOrderMarkLE2, and jassert.

◆ isDigit()

bool juce::CharPointer_UTF16::isDigit ( ) const
inlinenoexcept

Returns true if the first character of this string is a digit.

References juce::CharacterFunctions::isDigit().

◆ isEmpty()

bool juce::CharPointer_UTF16::isEmpty ( ) const
inlinenoexcept

Returns true if this pointer is pointing to a null character.

References data.

◆ isLetter()

bool juce::CharPointer_UTF16::isLetter ( ) const
inlinenoexcept

Returns true if the first character of this string is a letter.

References juce::CharacterFunctions::isLetter().

◆ isLetterOrDigit()

bool juce::CharPointer_UTF16::isLetterOrDigit ( ) const
inlinenoexcept

Returns true if the first character of this string is a letter or digit.

References juce::CharacterFunctions::isLetterOrDigit().

◆ isLowerCase()

bool juce::CharPointer_UTF16::isLowerCase ( ) const
inlinenoexcept

Returns true if the first character of this string is lower-case.

References juce::CharacterFunctions::isLowerCase().

◆ isNotEmpty()

bool juce::CharPointer_UTF16::isNotEmpty ( ) const
inlinenoexcept

Returns true if this pointer is not pointing to a null character.

References data.

◆ isUpperCase()

bool juce::CharPointer_UTF16::isUpperCase ( ) const
inlinenoexcept

Returns true if the first character of this string is upper-case.

References juce::CharacterFunctions::isUpperCase().

◆ isValidString()

static bool juce::CharPointer_UTF16::isValidString ( const CharType dataToTest,
int  maxBytesToRead 
)
inlinestatic

Returns true if this data contains a valid string in this encoding.

References int().

◆ isWhitespace()

bool juce::CharPointer_UTF16::isWhitespace ( ) const
inlinenoexcept

Returns true if the first character of this string is whitespace.

References juce::CharacterFunctions::isWhitespace().

◆ length()

size_t juce::CharPointer_UTF16::length ( ) const
inlinenoexcept

Returns the number of characters in this string.

References data.

◆ lengthUpTo() [1/2]

size_t juce::CharPointer_UTF16::lengthUpTo ( size_t  maxCharsToCount) const
inlinenoexcept

Returns the number of characters in this string, or the given value, whichever is lower.

References juce::CharacterFunctions::lengthUpTo().

◆ lengthUpTo() [2/2]

size_t juce::CharPointer_UTF16::lengthUpTo ( CharPointer_UTF16  end) const
inlinenoexcept

Returns the number of characters in this string, or up to the given end pointer, whichever is lower.

References juce::CharacterFunctions::lengthUpTo().

◆ operator const CharType *()

juce::CharPointer_UTF16::operator const CharType * ( ) const
inlinenoexcept

Returns the address that this pointer is pointing to.

References data.

◆ operator!=()

bool juce::CharPointer_UTF16::operator!= ( CharPointer_UTF16  other) const
inlinenoexcept

References data.

◆ operator*()

juce_wchar juce::CharPointer_UTF16::operator* ( ) const
inlinenoexcept

Returns the unicode character that this pointer is pointing to.

References data.

◆ operator+()

CharPointer_UTF16 juce::CharPointer_UTF16::operator+ ( int  numToSkip) const
inlinenoexcept

Returns a pointer which is moved forwards from this one by the specified number of characters.

◆ operator++() [1/2]

CharPointer_UTF16 juce::CharPointer_UTF16::operator++ ( )
inlinenoexcept

Moves this pointer along to the next character in the string.

References data.

◆ operator++() [2/2]

CharPointer_UTF16 juce::CharPointer_UTF16::operator++ ( int  )
inlinenoexcept

Moves this pointer along to the next character in the string.

◆ operator+=()

void juce::CharPointer_UTF16::operator+= ( int  numToSkip)
inlinenoexcept

Moves this pointer forwards by the specified number of characters.

Referenced by operator-=().

◆ operator-()

CharPointer_UTF16 juce::CharPointer_UTF16::operator- ( int  numToSkip) const
inlinenoexcept

Returns a pointer which is moved backwards from this one by the specified number of characters.

◆ operator--()

CharPointer_UTF16 juce::CharPointer_UTF16::operator-- ( )
inlinenoexcept

Moves this pointer back to the previous character in the string.

References data.

◆ operator-=()

void juce::CharPointer_UTF16::operator-= ( int  numToSkip)
inlinenoexcept

Moves this pointer backwards by the specified number of characters.

References operator+=().

◆ operator<()

bool juce::CharPointer_UTF16::operator< ( CharPointer_UTF16  other) const
inlinenoexcept

References data.

◆ operator<=()

bool juce::CharPointer_UTF16::operator<= ( CharPointer_UTF16  other) const
inlinenoexcept

References data.

◆ operator=() [1/2]

CharPointer_UTF16 juce::CharPointer_UTF16::operator= ( CharPointer_UTF16  other)
inlinenoexcept

References data.

◆ operator=() [2/2]

CharPointer_UTF16 juce::CharPointer_UTF16::operator= ( const CharType text)
inlinenoexcept

References data.

◆ operator==()

bool juce::CharPointer_UTF16::operator== ( CharPointer_UTF16  other) const
inlinenoexcept

This is a pointer comparison, it doesn't compare the actual text.

References data.

◆ operator>()

bool juce::CharPointer_UTF16::operator> ( CharPointer_UTF16  other) const
inlinenoexcept

References data.

◆ operator>=()

bool juce::CharPointer_UTF16::operator>= ( CharPointer_UTF16  other) const
inlinenoexcept

References data.

◆ operator[]()

juce_wchar juce::CharPointer_UTF16::operator[] ( int  characterIndex) const
inlinenoexcept

Returns the character at a given character index from the start of the string.

◆ sizeInBytes()

size_t juce::CharPointer_UTF16::sizeInBytes ( ) const
inlinenoexcept

Returns the number of bytes that are used to represent this string.

This includes the terminating null character.

References data, and findNullIndex().

◆ toLowerCase()

juce_wchar juce::CharPointer_UTF16::toLowerCase ( ) const
inlinenoexcept

Returns a lower-case version of the first character of this string.

References juce::CharacterFunctions::toLowerCase().

◆ toUpperCase()

juce_wchar juce::CharPointer_UTF16::toUpperCase ( ) const
inlinenoexcept

Returns an upper-case version of the first character of this string.

References juce::CharacterFunctions::toUpperCase().

◆ write()

void juce::CharPointer_UTF16::write ( juce_wchar  charToWrite)
inlinenoexcept

Writes a unicode character to this string, and advances this pointer to point to the next position.

References data.

◆ writeAll() [1/2]

template<typename CharPointer >
void juce::CharPointer_UTF16::writeAll ( CharPointer  src)
inlinenoexcept

Copies a source string to this pointer, advancing this pointer as it goes.

References juce::CharacterFunctions::copyAll().

◆ writeAll() [2/2]

void juce::CharPointer_UTF16::writeAll ( CharPointer_UTF16  src)
inlinenoexcept

Copies a source string to this pointer, advancing this pointer as it goes.

References data.

◆ writeNull()

void juce::CharPointer_UTF16::writeNull ( ) const
inlinenoexcept

Writes a null character to this string (leaving the pointer's position unchanged).

References data.

◆ writeWithCharLimit()

template<typename CharPointer >
void juce::CharPointer_UTF16::writeWithCharLimit ( CharPointer  src,
int  maxChars 
)
inlinenoexcept

Copies a source string to this pointer, advancing this pointer as it goes.

The maxChars parameter specifies the maximum number of characters that can be written to the destination buffer before stopping (including the terminating null).

References juce::CharacterFunctions::copyWithCharLimit().

◆ writeWithDestByteLimit()

template<typename CharPointer >
size_t juce::CharPointer_UTF16::writeWithDestByteLimit ( CharPointer  src,
size_t  maxDestBytes 
)
inlinenoexcept

Copies a source string to this pointer, advancing this pointer as it goes.

The maxDestBytes parameter specifies the maximum number of bytes that can be written to the destination buffer before stopping.

References juce::CharacterFunctions::copyWithDestByteLimit().

Member Data Documentation

◆ data


The documentation for this class was generated from the following file: