29 #ifndef JUCE_STRING_H_INCLUDED 30 #define JUCE_STRING_H_INCLUDED 55 #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 90 String (
const char* text,
size_t maxChars);
95 String (
const wchar_t* text);
100 String (
const wchar_t* text,
size_t maxChars);
137 String (
const std::string&);
166 #if (JUCE_STRING_UTF_TYPE == 32) 168 #elif (JUCE_STRING_UTF_TYPE == 16) 170 #elif (DOXYGEN || JUCE_STRING_UTF_TYPE == 8) 173 #error "You must set the value of JUCE_STRING_UTF_TYPE to be either 8, 16, or 32!" 184 size_t hash()
const noexcept;
195 #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 202 String& operator+= (
const char* textToAppend);
204 String& operator+= (
const wchar_t* textToAppend);
206 String& operator+= (
int numberToAppend);
210 String& operator+= (
char characterToAppend);
212 String& operator+= (
wchar_t characterToAppend);
213 #if ! JUCE_NATIVE_WCHAR_IS_UTF32 223 void append (
const String& textToAppend,
size_t maxCharsToTake);
230 void appendCharPointer (
const CharPointerType startOfTextToAppend,
231 const CharPointerType endOfTextToAppend);
238 template <
class CharPo
inter>
240 const CharPointer endOfTextToAppend)
242 jassert (startOfTextToAppend.getAddress() !=
nullptr && endOfTextToAppend.getAddress() !=
nullptr);
244 size_t extraBytesNeeded = 0, numChars = 1;
246 for (CharPointer t (startOfTextToAppend); t != endOfTextToAppend && ! t.isEmpty(); ++numChars)
247 extraBytesNeeded += CharPointerType::getBytesRequiredFor (t.getAndAdvance());
249 if (extraBytesNeeded > 0)
251 const size_t byteOffsetOfNull = getByteOffsetOfEnd();
253 preallocateBytes (byteOffsetOfNull + extraBytesNeeded);
255 .writeWithCharLimit (startOfTextToAppend, (
int) numChars);
260 void appendCharPointer (
const CharPointerType textToAppend);
267 template <
class CharPo
inter>
270 if (textToAppend.getAddress() !=
nullptr)
272 size_t extraBytesNeeded = 0, numChars = 1;
274 for (CharPointer t (textToAppend); numChars <= maxCharsToTake && ! t.isEmpty(); ++numChars)
275 extraBytesNeeded += CharPointerType::getBytesRequiredFor (t.getAndAdvance());
277 if (extraBytesNeeded > 0)
279 const size_t byteOffsetOfNull = getByteOffsetOfEnd();
281 preallocateBytes (byteOffsetOfNull + extraBytesNeeded);
283 .writeWithCharLimit (textToAppend, (
int) numChars);
289 template <
class CharPo
inter>
320 bool equalsIgnoreCase (
const wchar_t* other)
const noexcept;
323 bool equalsIgnoreCase (
const char* other)
const noexcept;
335 int compare (
const char* other)
const noexcept;
341 int compare (
const wchar_t* other)
const noexcept;
469 bool containsNonWhitespaceChars()
const noexcept;
511 int indexOfAnyOf (
StringRef charactersToLookFor,
513 bool ignoreCase =
false)
const noexcept;
579 int lastIndexOfAnyOf (
StringRef charactersToLookFor,
580 bool ignoreCase =
false)
const noexcept;
615 String substring (
int startIndex,
int endIndex)
const;
625 String substring (
int startIndex)
const;
636 String dropLastCharacters (
int numberToDrop)
const;
645 String getLastCharacters (
int numCharacters)
const;
664 bool includeSubStringInResult,
665 bool ignoreCase)
const;
676 bool includeSubStringInResult,
677 bool ignoreCase)
const;
693 bool includeSubStringInResult,
694 bool ignoreCase)
const;
704 bool includeSubStringInResult,
705 bool ignoreCase)
const;
735 String toUpperCase()
const;
738 String toLowerCase()
const;
756 String replaceSection (
int startIndex,
757 int numCharactersToReplace,
769 bool ignoreCase =
false)
const;
786 StringRef charactersToInsertInstead)
const;
815 String initialSectionContainingOnly (
StringRef permittedCharacters)
const;
823 String initialSectionNotContaining (
StringRef charactersToStopAt)
const;
832 bool isQuotedString()
const;
867 int numberOfTimesToRepeat);
887 static String createStringFromData (
const void*
data,
int size);
900 static String formatted (
const String formatString, ... );
908 explicit String (
int decimalInteger);
913 explicit String (
unsigned int decimalInteger);
918 explicit String (
short decimalInteger);
923 explicit String (
unsigned short decimalInteger);
939 explicit String (
float floatValue);
945 explicit String (
double doubleValue);
954 String (
float floatValue,
int numberOfDecimalPlaces);
963 String (
double doubleValue,
int numberOfDecimalPlaces);
986 int getTrailingIntValue()
const noexcept;
993 float getFloatValue()
const noexcept;
1000 double getDoubleValue()
const noexcept;
1011 int getHexValue32()
const noexcept;
1025 static String toHexString (
int number);
1031 static String toHexString (
short number);
1042 static String toHexString (
const void* data,
int size,
int groupSize = 1);
1077 const char* toRawUTF8()
const;
1114 const wchar_t* toWideCharPointer()
const;
1117 std::string toStdString()
const;
1123 static String fromUTF8 (
const char* utf8buffer,
int bufferSizeBytes = -1);
1129 size_t getNumBytesAsUTF8()
const noexcept;
1198 void preallocateBytes (
size_t numBytesNeeded);
1206 #if JUCE_MAC || JUCE_IOS || DOXYGEN 1208 static String fromCFString (CFStringRef cfString);
1214 CFStringRef toCFString()
const;
1218 String convertToPrecomposedUnicode()
const;
1224 int getReferenceCount()
const noexcept;
1228 CharPointerType text;
1231 struct PreallocationBytes
1233 explicit PreallocationBytes (
size_t)
noexcept;
1237 explicit String (
const PreallocationBytes&);
1238 size_t getByteOffsetOfEnd()
const noexcept;
1244 operator bool()
const noexcept {
return false; }
1256 #if ! JUCE_NATIVE_WCHAR_IS_UTF32 1271 #if ! JUCE_NATIVE_WCHAR_IS_UTF32 1281 #if ! JUCE_NATIVE_WCHAR_IS_UTF32 1348 template <
class traits>
1349 std::basic_ostream <char, traits>&
JUCE_CALLTYPE operator<< (std::basic_ostream <char, traits>& stream,
const String& stringToWrite)
1351 return stream << stringToWrite.
toRawUTF8();
1357 template <
class traits>
1358 std::basic_ostream <wchar_t, traits>&
JUCE_CALLTYPE operator<< (std::basic_ostream <wchar_t, traits>& stream,
const String& stringToWrite)
1370 #endif // JUCE_STRING_H_INCLUDED void appendCharPointer(const CharPointer textToAppend)
Definition: juce_String.h:290
JUCE_API bool JUCE_CALLTYPE operator<=(const String &string1, const String &string2) noexcept
Definition: juce_String.cpp:591
void appendCharPointer(const CharPointer startOfTextToAppend, const CharPointer endOfTextToAppend)
Definition: juce_String.h:239
static const String empty
Definition: juce_String.h:152
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_CharPointer_UTF16.h:39
Definition: juce_CharPointer_UTF8.h:38
char CharType
Definition: juce_CharPointer_UTF8.h:41
Type * addBytesToPointer(Type *basePointer, IntegerType bytes) noexcept
Definition: juce_Memory.h:53
void appendCharPointer(const CharPointer textToAppend, size_t maxCharsToTake)
Definition: juce_String.h:268
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
bool isNotEmpty() const noexcept
Definition: juce_String.h:308
JUCE_API String JUCE_CALLTYPE operator+(const char *string1, const String &string2)
Definition: juce_String.cpp:826
CharType * getAddress() const noexcept
Definition: juce_CharPointer_ASCII.h:78
unsigned long long uint64
Definition: juce_MathsFunctions.h:62
CharPointerType getCharPointer() const noexcept
Definition: juce_String.h:1051
JUCE_API bool JUCE_CALLTYPE operator!=(const String &string1, const String &string2) noexcept
Definition: juce_String.cpp:575
JUCE_API bool JUCE_CALLTYPE operator==(const String &string1, const String &string2) noexcept
Definition: juce_String.cpp:574
JUCE_API bool JUCE_CALLTYPE operator>=(const String &string1, const String &string2) noexcept
Definition: juce_String.cpp:590
png_uint_32 length
Definition: juce_PNGLoader.cpp:2078
bool isEmpty() const noexcept
Definition: juce_String.h:302
JUCE_API bool JUCE_CALLTYPE operator>(const String &string1, const String &string2) noexcept
Definition: juce_String.cpp:588
Definition: juce_OutputStream.h:42
juce_wchar CharType
Definition: juce_CharPointer_UTF32.h:42
long long int64
Definition: juce_MathsFunctions.h:60
Definition: juce_CharPointer_ASCII.h:42
Definition: juce_CharPointer_UTF32.h:39
const wchar_t * toWideCharPointer() const
Definition: juce_String.cpp:2066
int16 CharType
Definition: juce_CharPointer_UTF16.h:45
JUCE_API bool JUCE_CALLTYPE operator<(const String &string1, const String &string2) noexcept
Definition: juce_String.cpp:589
JUCE_API String &JUCE_CALLTYPE operator<<(String &string1, char characterToAppend)
Definition: juce_String.cpp:845
JSAMPIMAGE data
Definition: jpeglib.h:945
bool isEmpty() const noexcept
Definition: juce_CharPointer_ASCII.h:84
#define max(x, y)
Definition: os.h:79
const char * toRawUTF8() const
Definition: juce_String.cpp:2061
wchar_t juce_wchar
Definition: juce_CharacterFunctions.h:49
Definition: juce_StringRef.h:65