44 using CharType = char;
47 : data (const_cast<CharType*> (rawPointer))
61 data =
const_cast<CharType*
> (text);
67 inline bool operator!= (
CharPointer_ASCII other)
const noexcept {
return data != other.data; }
68 inline bool operator<= (
CharPointer_ASCII other)
const noexcept {
return data <= other.data; }
69 inline bool operator< (
CharPointer_ASCII other)
const noexcept {
return data < other.data; }
70 inline bool operator>= (
CharPointer_ASCII other)
const noexcept {
return data >= other.data; }
71 inline bool operator> (
CharPointer_ASCII other)
const noexcept {
return data > other.data; }
74 inline CharType*
getAddress() const noexcept {
return data; }
77 inline operator const CharType*()
const noexcept {
return data; }
80 inline bool isEmpty() const noexcept {
return *data == 0; }
83 inline bool isNotEmpty() const noexcept {
return *data != 0; }
86 inline juce_wchar
operator*() const noexcept {
return (juce_wchar) (uint8) *data; }
104 inline juce_wchar
getAndAdvance() noexcept {
return (juce_wchar) (uint8) *data++; }
120 inline void operator-= (
const int numToSkip) noexcept
126 inline juce_wchar
operator[] (
const int characterIndex)
const noexcept
128 return (juce_wchar) (uint8) data [characterIndex];
144 inline void write (
const juce_wchar charToWrite) noexcept
146 *data++ = (char) charToWrite;
149 inline void replaceChar (
const juce_wchar newChar) noexcept
151 *data = (char) newChar;
163 return (
size_t) strlen (data);
167 size_t lengthUpTo (
const size_t maxCharsToCount)
const noexcept
198 template <
class CharPo
inter>
201 return text.length();
211 template <
typename CharPo
inter>
221 template <
typename CharPo
inter>
231 template <
typename CharPo
inter>
238 template <
typename CharPo
inter>
239 int compare (
const CharPointer other)
const noexcept
247 return strcmp (data, other.data);
251 template <
typename CharPo
inter>
252 int compareUpTo (
const CharPointer other,
const int maxChars)
const noexcept
260 return strncmp (data, other.data, (
size_t) maxChars);
264 template <
typename CharPo
inter>
272 #if JUCE_MINGW || (JUCE_WINDOWS && JUCE_CLANG) 275 return stricmp (data, other.data);
277 return strcasecmp (data, other.data);
282 template <
typename CharPo
inter>
289 template <
typename CharPo
inter>
290 int indexOf (
const CharPointer stringToFind)
const noexcept
296 int indexOf (
const juce_wchar charToFind)
const noexcept
302 if (data[i] == (
char) charToFind)
312 int indexOf (
const juce_wchar charToFind,
const bool ignoreCase)
const noexcept
342 #if JUCE_LINUX || JUCE_ANDROID || JUCE_MINGW 345 return _atoi64 (data);
347 return CharacterFunctions::getIntValue <int64, CharPointer_ASCII> (*this);
360 return ((
unsigned int) character) < (
unsigned int) 128;
366 while (--maxBytesToRead >= 0)
368 if (((
signed char) *dataToTest) <= 0)
369 return *dataToTest == 0;
Wraps a pointer to a null-terminated ASCII character string, and provides various methods to operate ...
int indexOf(const juce_wchar charToFind) const noexcept
Returns the character index of a unicode character, or -1 if it isn't found.
static double getDoubleValue(CharPointerType text) noexcept
Parses a character string, to read a floating-point value.
static juce_wchar toUpperCase(juce_wchar character) noexcept
Converts a character to upper-case.
static size_t getBytesRequiredFor(const juce_wchar) noexcept
Returns the number of bytes that would be needed to represent the given unicode character in this enc...
int getIntValue32() const noexcept
Parses this string as a 32-bit integer.
static bool isValidString(const CharType *dataToTest, int maxBytesToRead)
Returns true if this data contains a valid string in this encoding.
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 void copyAll(DestCharPointerType &dest, SrcCharPointerType src) noexcept
Copies null-terminated characters from one string to another.
int compare(const CharPointer other) const noexcept
Compares this string with another one.
CharPointer_ASCII operator-(const int numToSkip) const noexcept
Returns a pointer which is moved backwards from this one by the specified number of characters...
size_t length() const noexcept
Returns the number of characters in this string.
static int compareIgnoreCase(juce_wchar char1, juce_wchar char2) noexcept
Compares two characters, using a case-independant match.
CharPointer_ASCII operator++() noexcept
Moves this pointer along to the next character in the string.
bool isNotEmpty() const noexcept
Returns true if this pointer is not pointing to a null character.
bool isLetterOrDigit() const
Returns true if the first character of this string is a letter or digit.
static bool isDigit(char character) noexcept
Checks whether a character is a digit.
static Type findEndOfWhitespace(Type text) noexcept
Returns a pointer to the first non-whitespace character in a string.
int indexOf(const CharPointer stringToFind) const noexcept
Returns the character index of a substring, or -1 if it isn't found.
static bool isWhitespace(char character) noexcept
Checks whether a character is whitespace.
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.
size_t lengthUpTo(const size_t maxCharsToCount) const noexcept
Returns the number of characters in this string, or the given value, whichever is lower...
static int indexOfChar(Type text, const juce_wchar charToFind) noexcept
Finds the character index of a given character in another string.
bool isDigit() const
Returns true if the first character of this string is a digit.
bool isUpperCase() const
Returns true if the first character of this string is upper-case.
void writeNull() const noexcept
Writes a null character to this string (leaving the pointer's position unchanged).
static int compareIgnoreCaseUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
Compares two null-terminated character strings, using a case-independent match.
void writeWithCharLimit(const CharPointer src, const int maxChars) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
CharPointer_ASCII 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 bool isUpperCase(juce_wchar character) noexcept
Checks whether a unicode character is upper-case.
bool isLetter() const
Returns true if the first character of this string is a letter.
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...
juce_wchar operator*() const noexcept
Returns the unicode character that this pointer is pointing to.
bool isEmpty() const noexcept
Returns true if this pointer is pointing to a null character.
size_t lengthUpTo(const CharPointer_ASCII end) const noexcept
Returns the number of characters in this string, or up to the given end pointer, whichever is lower...
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...
void operator+=(const int numToSkip) noexcept
Moves this pointer forwards by the specified number of characters.
void writeAll(const CharPointer src) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
int compare(const CharPointer_ASCII other) const noexcept
Compares this string with another one.
int compareUpTo(const CharPointer_ASCII other, const int maxChars) const noexcept
Compares this string with another one, up to a specified number of characters.
double getDoubleValue() const noexcept
Parses this string as a floating point double.
juce_wchar toLowerCase() const noexcept
Returns a lower-case version of the first character of this string.
static size_t getBytesRequiredFor(const CharPointer text) noexcept
Returns the number of bytes that would be needed to represent the given string in this encoding forma...
int compareIgnoreCase(const CharPointer other) const
Compares this string with another one.
CharPointer_ASCII findEndOfWhitespace() const noexcept
Returns the first non-whitespace character in the string.
int compareUpTo(const CharPointer other, const int maxChars) const noexcept
Compares this string with another one, up to a specified number of characters.
bool isLowerCase() const
Returns true if the first character of this string is lower-case.
static juce_wchar toLowerCase(juce_wchar character) noexcept
Converts a character to lower-case.
CharPointer_ASCII operator--() noexcept
Moves this pointer to the previous character in the string.
static bool isLetter(char character) noexcept
Checks whether a character is alphabetic.
size_t writeWithDestByteLimit(const CharPointer src, const size_t maxDestBytes) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
juce_wchar getAndAdvance() noexcept
Returns the character that this pointer is currently pointing to, and then advances the pointer to po...
juce_wchar operator[](const int characterIndex) const noexcept
Returns the character at a given character index from the start of the string.
int64 getIntValue64() const noexcept
Parses this string as a 64-bit integer.
void write(const juce_wchar charToWrite) noexcept
Writes a unicode character to this string, and advances this pointer to point to the next position...
static int indexOf(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
Finds the character index of a given substring in another string.
juce_wchar toUpperCase() const noexcept
Returns an upper-case version of the first character of this string.
bool operator==(CharPointer_ASCII other) const noexcept
This is a pointer comparison, it doesn't compare the actual text.
CharPointer_ASCII operator+(const int numToSkip) const noexcept
Returns a pointer which is moved forwards from this one by the specified number of characters...
static bool canRepresent(juce_wchar character) noexcept
Returns true if the given unicode character can be represented in this encoding.
bool isWhitespace() const
Returns true if the first character of this string is whitespace.
static bool isLowerCase(juce_wchar character) noexcept
Checks whether a unicode character is lower-case.
static bool isLetterOrDigit(char character) noexcept
Checks whether a character is alphabetic or numeric.
CharType * getAddress() const noexcept
Returns the address that this pointer is pointing to.
static int compareUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
Compares two null-terminated character strings, up to a given number of characters.
size_t sizeInBytes() const noexcept
Returns the number of bytes that are used to represent this 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 int compare(juce_wchar char1, juce_wchar char2) noexcept
Compares two characters.