OpenShot Audio Library | OpenShotAudio 0.3.2
|
#include <juce_String.h>
Static Public Member Functions | |
static String | charToString (juce_wchar character) |
static String | repeatedString (StringRef stringToRepeat, int numberOfTimesToRepeat) |
static String | createStringFromData (const void *data, int size) |
template<typename... Args> | |
static String | formatted (const String &formatStr, Args... args) |
template<typename IntegerType > | |
static String | toHexString (IntegerType number) |
static String | toHexString (const void *data, int size, int groupSize=1) |
template<typename DecimalType > | |
static String | toDecimalStringWithSignificantFigures (DecimalType number, int numberOfSignificantFigures) |
static String | fromUTF8 (const char *utf8buffer, int bufferSizeBytes=-1) |
The JUCE String class!
Using a reference-counted internal representation, these strings are fast and efficient, and there are methods to do just about any operation you'll ever dream of.
Definition at line 38 of file juce_String.h.
|
noexcept |
Creates a copy of another string.
Definition at line 255 of file juce_String.cpp.
|
noexcept |
Move constructor
Definition at line 278 of file juce_String.cpp.
Creates a string from a zero-terminated ascii text string.
The string passed-in must not contain any characters with a value above 127, because these can't be converted to unicode without knowing the original encoding that was used to create the string. If you attempt to pass-in values above 127, you'll get an assertion.
To create strings with extended characters from UTF-8, you should explicitly call String (CharPointer_UTF8 ("my utf8 string..")). It's highly recommended that you use UTF-8 with escape characters in your source code to represent extended characters, because there's no other way to represent unicode strings in a way that isn't dependent on the compiler, source code editor and platform.
Definition at line 307 of file juce_String.cpp.
Creates a string from a string of 8-bit ascii characters.
The string passed-in must not contain any characters with a value above 127, because these can't be converted to unicode without knowing the original encoding that was used to create the string. If you attempt to pass-in values above 127, you'll get an assertion.
To create strings with extended characters from UTF-8, you should explicitly call String (CharPointer_UTF8 ("my utf8 string..")). It's highly recommended that you use UTF-8 with escape characters in your source code to represent extended characters, because there's no other way to represent unicode strings in a way that isn't dependent on the compiler, source code editor and platform.
This will use up to the first maxChars characters of the string (or less if the string is actually shorter).
Definition at line 330 of file juce_String.cpp.
Creates a string from a wchar_t character string. Depending on the platform, this may be treated as either UTF-32 or UTF-16.
Definition at line 353 of file juce_String.cpp.
Creates a string from a wchar_t character string. Depending on the platform, this may be treated as either UTF-32 or UTF-16.
Definition at line 362 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF8 | text | ) |
Creates a string from a UTF-8 character string
Definition at line 354 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF8 | text, |
size_t | maxChars | ||
) |
Creates a string from a UTF-8 character string
Definition at line 359 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF8 | start, |
CharPointer_UTF8 | end | ||
) |
Creates a string from a UTF-8 character string
Definition at line 364 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF16 | text | ) |
Creates a string from a UTF-16 character string
Definition at line 355 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF16 | text, |
size_t | maxChars | ||
) |
Creates a string from a UTF-16 character string
Definition at line 360 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF16 | start, |
CharPointer_UTF16 | end | ||
) |
Creates a string from a UTF-16 character string
Definition at line 365 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF32 | text | ) |
Creates a string from a UTF-32 character string
Definition at line 356 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF32 | text, |
size_t | maxChars | ||
) |
Creates a string from a UTF-32 character string
Definition at line 361 of file juce_String.cpp.
juce::String::String | ( | CharPointer_UTF32 | start, |
CharPointer_UTF32 | end | ||
) |
Creates a string from a UTF-32 character string
Definition at line 366 of file juce_String.cpp.
juce::String::String | ( | CharPointer_ASCII | text | ) |
Creates a string from an ASCII character string
Definition at line 357 of file juce_String.cpp.
juce::String::String | ( | const std::string & | s | ) |
Creates a string from a UTF-8 encoded std::string.
Definition at line 368 of file juce_String.cpp.
juce::String::String | ( | StringRef | s | ) |
Creates a string from a StringRef
Definition at line 369 of file juce_String.cpp.
|
noexcept |
Destructor.
Definition at line 250 of file juce_String.cpp.
|
explicit |
Creates a string containing this signed 32-bit integer as a decimal number.
Definition at line 508 of file juce_String.cpp.
Creates a string containing this unsigned 32-bit integer as a decimal number.
Definition at line 509 of file juce_String.cpp.
|
explicit |
Creates a string containing this signed 16-bit integer as a decimal number.
Definition at line 510 of file juce_String.cpp.
Creates a string containing this unsigned 16-bit integer as a decimal number.
Definition at line 511 of file juce_String.cpp.
|
explicit |
Creates a string containing this signed 64-bit integer as a decimal number.
Definition at line 512 of file juce_String.cpp.
|
explicit |
Creates a string containing this unsigned 64-bit integer as a decimal number.
Definition at line 513 of file juce_String.cpp.
|
explicit |
Creates a string containing this signed long integer as a decimal number.
Definition at line 514 of file juce_String.cpp.
Creates a string containing this unsigned long integer as a decimal number.
Definition at line 515 of file juce_String.cpp.
|
explicit |
Creates a string representing this floating-point number.
floatValue | the value to convert to a string |
Definition at line 517 of file juce_String.cpp.
|
explicit |
Creates a string representing this floating-point number.
doubleValue | the value to convert to a string |
Definition at line 518 of file juce_String.cpp.
juce::String::String | ( | float | floatValue, |
int | numberOfDecimalPlaces, | ||
bool | useScientificNotation = false |
||
) |
Creates a string representing this floating-point number.
floatValue | the value to convert to a string |
numberOfDecimalPlaces | if this is > 0 the number will be formatted using that many decimal places, adding trailing zeros as required. If 0 or less the number will be formatted using the C++ standard library default format, which uses scientific notation for large and small numbers. |
useScientificNotation | if the number should be formatted using scientific notation |
Definition at line 519 of file juce_String.cpp.
juce::String::String | ( | double | doubleValue, |
int | numberOfDecimalPlaces, | ||
bool | useScientificNotation = false |
||
) |
Creates a string representing this floating-point number.
doubleValue | the value to convert to a string |
numberOfDecimalPlaces | if this is > 0, it will format the number using that many decimal places, adding trailing zeros as required, and will not use exponent notation. If 0 or less, it will use exponent notation if necessary. |
useScientificNotation | if the number should be formatted using scientific notation |
Definition at line 520 of file juce_String.cpp.
Appends a string to the end of this one.
textToAppend | the string to add |
maxCharsToTake | the maximum number of characters to take from the string passed in |
Definition at line 718 of file juce_String.cpp.
|
inline |
Appends a string to the end of this one.
startOfTextToAppend | the start of the string to add. This must not be a nullptr |
endOfTextToAppend | the end of the string to add. This must not be a nullptr |
Definition at line 233 of file juce_String.h.
|
inline |
Appends a string to the end of this one.
Definition at line 284 of file juce_String.h.
|
inline |
Appends a string to the end of this one.
textToAppend | the string to add |
maxCharsToTake | the maximum number of characters to take from the string passed in |
Definition at line 262 of file juce_String.h.
void juce::String::appendCharPointer | ( | CharPointerType | startOfTextToAppend, |
CharPointerType | endOfTextToAppend | ||
) |
Appends a string to the end of this one.
startOfTextToAppend | the start of the string to add. This must not be a nullptr |
endOfTextToAppend | the end of the string to add. This must not be a nullptr |
Definition at line 729 of file juce_String.cpp.
void juce::String::appendCharPointer | ( | CharPointerType | textToAppend | ) |
Appends a string to the end of this one.
Definition at line 724 of file juce_String.cpp.
|
static |
Creates a string from a single character.
Definition at line 371 of file juce_String.cpp.
Referenced by juce::BigInteger::toString().
|
noexcept |
Resets this string to be empty.
Definition at line 265 of file juce_String.cpp.
Case-sensitive comparison with another string.
Definition at line 609 of file juce_String.cpp.
Case-sensitive comparison with another string.
Definition at line 608 of file juce_String.cpp.
Case-sensitive comparison with another string.
Definition at line 610 of file juce_String.cpp.
Case-insensitive comparison with another string.
Definition at line 611 of file juce_String.cpp.
Compares two strings, taking into account textual characteristics like numbers and spaces.
This comparison is case-insensitive and can detect words and embedded numbers in the strings, making it good for sorting human-readable lists of things like filenames.
Definition at line 712 of file juce_String.cpp.
Tests whether the string contains another substring. If the parameter is an empty string, this will always return true. Uses a case-sensitive comparison.
Definition at line 1046 of file juce_String.cpp.
Referenced by juce::Time::getTimeZone().
Looks for any of a set of characters in the string. Uses a case-sensitive comparison.
Definition at line 1816 of file juce_String.cpp.
|
noexcept |
Tests whether the string contains a particular character. Uses a case-sensitive comparison.
Definition at line 1051 of file juce_String.cpp.
Tests whether the string contains another substring. Uses a case-insensitive comparison.
Definition at line 1056 of file juce_String.cpp.
Referenced by juce::Time::getTimeZone().
|
noexcept |
Returns true if this string contains any non-whitespace characters.
This will return false if the string contains only whitespace characters, or if it's empty.
It is equivalent to calling "myString.trim().isNotEmpty()".
Definition at line 1825 of file juce_String.cpp.
Looks for a set of characters in the string. Uses a case-sensitive comparison.
Definition at line 1807 of file juce_String.cpp.
Referenced by juce::DirectoryIterator::next(), and juce::Expression::withRenamedSymbol().
Tests whether the string contains another substring as a distinct word.
Definition at line 1105 of file juce_String.cpp.
Tests whether the string contains another substring as a distinct word.
Definition at line 1110 of file juce_String.cpp.
|
noexcept |
Copies the string to a buffer as UTF-16 characters.
Returns the number of bytes copied to the buffer, including the terminating null character.
To find out how many bytes you need to store this string as UTF-16, you can call CharPointer_UTF16::getBytesRequiredFor (myString.getCharPointer())
destBuffer | the place to copy it to; if this is a null pointer, the method just returns the number of bytes required (including the terminating null character). |
maxBufferSizeBytes | the size of the destination buffer, in bytes. If the string won't fit, it'll put in as many as it can while still allowing for a terminating null char at the end, and will return the number of bytes that were actually used. |
Definition at line 2112 of file juce_String.cpp.
|
noexcept |
Copies the string to a buffer as UTF-32 characters.
Returns the number of bytes copied to the buffer, including the terminating null character.
To find out how many bytes you need to store this string as UTF-32, you can call CharPointer_UTF32::getBytesRequiredFor (myString.getCharPointer())
destBuffer | the place to copy it to; if this is a null pointer, the method just returns the number of bytes required (including the terminating null character). |
maxBufferSizeBytes | the size of the destination buffer, in bytes. If the string won't fit, it'll put in as many as it can while still allowing for a terminating null char at the end, and will return the number of bytes that were actually used. |
Definition at line 2117 of file juce_String.cpp.
|
noexcept |
Copies the string to a buffer as UTF-8 characters.
Returns the number of bytes copied to the buffer, including the terminating null character.
To find out how many bytes you need to store this string as UTF-8, you can call CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer())
destBuffer | the place to copy it to; if this is a null pointer, the method just returns the number of bytes required (including the terminating null character). |
maxBufferSizeBytes | the size of the destination buffer, in bytes. If the string won't fit, it'll put in as many as it can while still allowing for a terminating null char at the end, and will return the number of bytes that were actually used. |
Definition at line 2107 of file juce_String.cpp.
Referenced by juce::OutputStream::writeString().
Creates a string from data in an unknown format.
This looks at some binary data and tries to guess whether it's Unicode or 8-bit characters, then returns a string that represents it correctly.
Should be able to handle Unicode endianness correctly, by looking at the first two bytes.
Definition at line 1971 of file juce_String.cpp.
Referenced by juce::MemoryOutputStream::toString().
Returns a version of this string with a number of characters removed from the end.
numberToDrop | the number of characters to drop from the end of the string. If this is greater than the length of the string, an empty string will be returned. If zero or less, the original string will be returned. |
Definition at line 1566 of file juce_String.cpp.
Tests whether the string ends with another string. If the parameter is an empty string, this will always return true. Uses a case-sensitive comparison.
Definition at line 1432 of file juce_String.cpp.
|
noexcept |
Tests whether the string ends with a particular character. If the character is 0, this will always return false. Uses a case-sensitive comparison.
Definition at line 1421 of file juce_String.cpp.
Referenced by juce::File::addTrailingSeparator().
Tests whether the string ends with another string. If the parameter is an empty string, this will always return true. Uses a case-insensitive comparison.
Definition at line 1449 of file juce_String.cpp.
Referenced by juce::File::hasFileExtension().
Case-insensitive comparison with another string.
Definition at line 591 of file juce_String.cpp.
Case-insensitive comparison with another string.
Definition at line 602 of file juce_String.cpp.
Case-insensitive comparison with another string.
Definition at line 585 of file juce_String.cpp.
Case-insensitive comparison with another string.
Definition at line 597 of file juce_String.cpp.
|
inlinestatic |
Creates a String from a printf-style parameter list.
I don't like this method. I don't use it myself, and I recommend avoiding it and using the operator<< methods or pretty much anything else instead. It's only provided here because of the popular unrest that was stirred-up when I tried to remove it...
If you're really determined to use it, at least make sure that you never, ever, pass any String objects to it as parameters. And bear in mind that internally, depending on the platform, it may be using wchar_t or char character types, so that even string literals can't be safely used as parameters if you're writing portable code.
Definition at line 906 of file juce_String.h.
Referenced by juce::Time::getUTCOffsetString(), and juce::Time::toISO8601().
String juce::String::fromFirstOccurrenceOf | ( | StringRef | substringToStartFrom, |
bool | includeSubStringInResult, | ||
bool | ignoreCase | ||
) | const |
Returns a section of the string starting from a given substring.
This will search for the first occurrence of the given substring, and return the section of the string starting from the point where this is found (optionally not including the substring itself).
e.g. for the string "123456", fromFirstOccurrenceOf ("34", true) would return "3456", and fromFirstOccurrenceOf ("34", false) would return "56".
If the substring isn't found, the method will return an empty string.
If ignoreCase is true, the comparison will be case-insensitive.
Definition at line 1576 of file juce_String.cpp.
Referenced by juce::URL::URL().
String juce::String::fromLastOccurrenceOf | ( | StringRef | substringToFind, |
bool | includeSubStringInResult, | ||
bool | ignoreCase | ||
) | const |
Returns a section of the string starting from the last occurrence of a given substring.
Similar to fromFirstOccurrenceOf(), but using the last occurrence of the substring, and unlike fromFirstOccurrenceOf(), if the substring isn't found, this method will return the whole of the original string.
Definition at line 1586 of file juce_String.cpp.
Referenced by juce::URL::getFileName(), and juce::XmlElement::getTagNameWithoutNamespace().
Creates a String from a UTF-8 encoded buffer. If the size is < 0, it'll keep reading until it hits a zero.
Definition at line 2128 of file juce_String.cpp.
Referenced by juce::URL::addEscapeChars(), juce::BufferedInputStream::readString(), juce::URL::removeEscapeChars(), and juce::MemoryBlock::toString().
|
inlinenoexcept |
Returns the character pointer currently being used to store this string.
Because it returns a reference to the string's internal data, the pointer that is returned must not be stored anywhere, as it can be deleted whenever the string changes.
Definition at line 1198 of file juce_String.h.
Referenced by juce::XmlDocument::getDocumentElement(), juce::StringArray::joinIntoString(), juce::JSON::parse(), and juce::OutputStream::writeText().
|
noexcept |
Parses this string as a floating point number.
Definition at line 1877 of file juce_String.cpp.
|
noexcept |
Parses this string as a floating point number.
Definition at line 1876 of file juce_String.cpp.
|
noexcept |
Parses the string as a hexadecimal number.
Non-hexadecimal characters in the string are ignored.
If the string contains too many characters, then the lowest significant digits are returned, e.g. "ffff12345678" would produce 0x12345678.
Definition at line 1956 of file juce_String.cpp.
|
noexcept |
Parses the string as a hexadecimal number.
Non-hexadecimal characters in the string are ignored.
If the string contains too many characters, then the lowest significant digits are returned, e.g. "ffff1234567812345678" would produce 0x1234567812345678.
Definition at line 1957 of file juce_String.cpp.
|
noexcept |
Reads the value of the string as a decimal number (up to 32 bits in size).
Definition at line 1874 of file juce_String.cpp.
Referenced by juce::MemoryBlock::fromBase64Encoding().
|
noexcept |
Reads the value of the string as a decimal number (up to 64 bits in size).
Definition at line 1875 of file juce_String.cpp.
|
noexcept |
Returns the final character of the string. If the string is empty this will return 0.
Definition at line 1504 of file juce_String.cpp.
Returns a number of characters from the end of the string.
This returns the last numCharacters characters from the end of the string. If the string is shorter than numCharacters, the whole string is returned.
Definition at line 1571 of file juce_String.cpp.
|
noexcept |
Returns the number of bytes required to represent this string as UTF8. The number returned does NOT include the trailing zero.
Definition at line 2123 of file juce_String.cpp.
Referenced by juce::URL::addEscapeChars(), juce::OutputStream::writeString(), and juce::OutputStream::writeText().
|
noexcept |
Returns the number of String objects which are currently sharing the same internal data as this one.
Definition at line 301 of file juce_String.cpp.
|
noexcept |
Parses a decimal number from the end of the string.
This will look for a value at the end of the string. e.g. for "321 xyz654" it will return 654; for "2 3 4" it'll return 4.
Negative numbers are not handled, so "xyz-5" returns 5.
Definition at line 1879 of file juce_String.cpp.
|
noexcept |
Generates a probably-unique hashcode from this string.
Definition at line 563 of file juce_String.cpp.
|
noexcept |
This is the character encoding type used internally to store the string.
By setting the value of JUCE_STRING_UTF_TYPE to 8, 16, or 32, you can change the internal storage format of the String class. UTF-8 uses the least space (if your strings contain few extended characters), but call operator[] involves iterating the string to find the required index. UTF-32 provides instant random access to its characters, but uses 4 bytes per character to store them. UTF-16 uses more space than UTF-8 and is also slow to index, but is the native wchar_t format used in Windows.
It doesn't matter too much which format you pick, because the toUTF8(), toUTF16() and toUTF32() methods let you access the string's content in any of the other formats. Generates a probably-unique 32-bit hashcode from this string.
Definition at line 561 of file juce_String.cpp.
Referenced by juce::File::hashCode().
|
noexcept |
Generates a probably-unique 64-bit hashcode from this string.
Definition at line 562 of file juce_String.cpp.
Referenced by juce::File::hashCode64().
Searches for a substring within this string. Uses a case-sensitive comparison.
startIndex | the index from which the search should proceed |
textToLookFor | the string to search for |
Definition at line 952 of file juce_String.cpp.
Searches for a substring within this string. Uses a case-sensitive comparison.
Definition at line 942 of file juce_String.cpp.
Referenced by replace().
|
noexcept |
Returns the index of the first character that matches one of the characters passed-in to this method.
This scans the string, beginning from the startIndex supplied, and if it finds a character that appears in the string charactersToLookFor, it returns its index.
If none of these characters are found, it returns -1.
If ignoreCase is true, the comparison will be case-insensitive.
Definition at line 922 of file juce_String.cpp.
Searches for a character inside this string. Uses a case-sensitive comparison.
startIndex | the index from which the search should proceed |
characterToLookFor | the character to look for |
Definition at line 890 of file juce_String.cpp.
|
noexcept |
Searches for a character inside this string. Uses a case-sensitive comparison.
Definition at line 885 of file juce_String.cpp.
Searches for a substring within this string. Uses a case-insensitive comparison.
startIndex | the index from which the search should proceed |
textToLookFor | the string to search for |
Definition at line 971 of file juce_String.cpp.
Searches for a substring within this string. Uses a case-insensitive comparison.
Definition at line 947 of file juce_String.cpp.
Referenced by replace().
Finds an instance of another substring if it exists as a distinct word.
Definition at line 1061 of file juce_String.cpp.
Finds an instance of another substring if it exists as a distinct word.
Definition at line 1083 of file juce_String.cpp.
Returns a section from the start of the string that only contains a certain set of characters.
This returns the leftmost section of the string, up to (and not including) the first character that doesn't appear in the string passed in.
Definition at line 1789 of file juce_String.cpp.
Returns a section from the start of the string that only contains a certain set of characters.
This returns the leftmost section of the string, up to (and not including) the first character that occurs in the string passed in. (If none of the specified characters are found in the string, the return value will just be the original string).
Definition at line 1798 of file juce_String.cpp.
|
inlinenoexcept |
Returns true if the string contains no characters. Note that there's also an isNotEmpty() method to help write readable code.
Definition at line 296 of file juce_String.h.
Referenced by juce::ZipFile::Builder::addFile(), juce::AudioDeviceManager::addMidiInputCallback(), juce::AudioDeviceManager::addMidiInputDeviceCallback(), juce::MidiMessage::getDescription(), juce::XmlDocument::getDocumentElement(), juce::UnitTest::getTestsInCategory(), juce::TextDiff::Change::isDeletion(), juce::AudioDeviceManager::restartLastAudioDevice(), juce::AudioDeviceManager::setAudioDeviceSetup(), and juce::File::withFileExtension().
|
inlinenoexcept |
Returns true if the string contains at least one character. Note that there's also an isEmpty() method to help write readable code.
Definition at line 302 of file juce_String.h.
Referenced by juce::ZipFile::Builder::addEntry(), juce::ValueWithDefault::get(), juce::File::isRoot(), juce::ConsoleApplication::printCommandDetails(), juce::AudioDeviceManager::setAudioDeviceSetup(), juce::AudioDeviceManager::setDefaultMidiOutputDevice(), and juce::XmlElement::writeTo().
bool juce::String::isQuotedString | ( | ) | const |
Checks whether the string might be in quotation marks.
Definition at line 1621 of file juce_String.cpp.
Searches for a substring inside this string (working backwards from the end of the string). Uses a case-sensitive comparison.
Definition at line 990 of file juce_String.cpp.
|
noexcept |
Returns the index of the last character in this string that matches one of the characters passed-in to this method.
This scans the string backwards, starting from its end, and if it finds a character that appears in the string charactersToLookFor, it returns its index.
If none of these characters are found, it returns -1.
If ignoreCase is true, the comparison will be case-insensitive.
Definition at line 1034 of file juce_String.cpp.
|
noexcept |
Searches for a character inside this string (working backwards from the end of the string). Uses a case-sensitive comparison.
Definition at line 910 of file juce_String.cpp.
Referenced by juce::File::getFileExtension(), juce::File::getFileName(), juce::File::getFileNameWithoutExtension(), and juce::File::hasFileExtension().
Searches for a substring inside this string (working backwards from the end of the string). Uses a case-insensitive comparison.
Definition at line 1012 of file juce_String.cpp.
|
noexcept |
Returns the number of characters in the string.
Definition at line 523 of file juce_String.cpp.
Referenced by juce::File::hasFileExtension(), and juce::dsp::Matrix< ElementType >::toString().
Returns true if the string matches this simple wildcard expression.
So for example String ("abcdef").matchesWildcard ("*DEF", true) would return true.
This isn't a full-blown regex though! The only wildcard characters supported are "*" and "?". It's mainly intended for filename pattern matching.
Definition at line 1152 of file juce_String.cpp.
Appends a character at the end of this string.
Definition at line 778 of file juce_String.cpp.
Appends another string at the end of this one.
Definition at line 755 of file juce_String.cpp.
Appends another string at the end of this one.
Definition at line 761 of file juce_String.cpp.
Appends another string at the end of this one.
Definition at line 749 of file juce_String.cpp.
Appends a decimal number at the end of this string.
Definition at line 818 of file juce_String.cpp.
String & juce::String::operator+= | ( | int64 | numberToAppend | ) |
Appends a decimal number at the end of this string.
Definition at line 819 of file juce_String.cpp.
String & juce::String::operator+= | ( | juce_wchar | characterToAppend | ) |
Appends a character at the end of this string.
Appends a decimal number at the end of this string.
Appends another string at the end of this one.
Definition at line 773 of file juce_String.cpp.
String & juce::String::operator+= | ( | uint64 | numberToAppend | ) |
Appends a decimal number at the end of this string.
Definition at line 820 of file juce_String.cpp.
Appends a character at the end of this string.
Definition at line 784 of file juce_String.cpp.
Replaces this string's contents with another string.
Definition at line 271 of file juce_String.cpp.
Moves the contents of another string to the receiver
Definition at line 283 of file juce_String.cpp.
|
noexcept |
Returns the character at this index in the string. In a release build, no checks are made to see if the index is within a valid range, so be careful! In a debug build, the index is checked and an assertion fires if it's out-of-range.
Also beware that depending on the encoding format that the string is using internally, this method may execute in either O(1) or O(n) time, so be careful when using it in your algorithms. If you're scanning through a string to inspect its characters, you should never use this operator for random access, it's far more efficient to call getCharPointer() to return a pointer, and then to use that to iterate the string.
Definition at line 538 of file juce_String.cpp.
Returns a copy of this string with the specified character repeatedly added to its beginning until the total length is at least the minimum length specified.
Definition at line 1172 of file juce_String.cpp.
Referenced by juce::BigInteger::toString().
Returns a copy of this string with the specified character repeatedly added to its end until the total length is at least the minimum length specified.
Definition at line 1199 of file juce_String.cpp.
Increases the string's internally allocated storage.
Although the string's contents won't be affected by this call, it will increase the amount of memory allocated internally for the string to grow into.
If you're about to make a large number of calls to methods such as += or <<, it's more efficient to preallocate enough extra space beforehand, so that these methods won't have to keep resizing the string to append the extra characters.
numBytesNeeded | the number of bytes to allocate storage for. If this value is less than the currently allocated size, it will have no effect. |
Definition at line 296 of file juce_String.cpp.
Referenced by juce::StringArray::joinIntoString().
String juce::String::quoted | ( | juce_wchar | quoteCharacter = '"' | ) | const |
Adds quotation marks around a string.
This will return a copy of the string with a quote at the start and end, (but won't add the quote if there's already one there, so it's safe to call this on strings that may already have quotes around them).
Note that this is a const method, and won't alter the string itself.
quoteCharacter | the character to add at the start and end |
Definition at line 1635 of file juce_String.cpp.
Returns a version of this string with a set of characters removed.
This will return a copy of this string, omitting any characters which are found in the string passed-in.
e.g. for "1122334455", removeCharacters ("432") would return "1155"
Note that this is a const method, and won't alter the string itself.
Definition at line 1768 of file juce_String.cpp.
Referenced by juce::File::createLegalPathName().
Creates a string which is a version of a string repeated and joined together.
stringToRepeat | the string to repeat |
numberOfTimesToRepeat | how many times to repeat it |
Definition at line 1158 of file juce_String.cpp.
Referenced by juce::IPAddress::getFormattedAddress(), and juce::File::getRelativePathFrom().
String juce::String::replace | ( | StringRef | stringToReplace, |
StringRef | stringToInsertInstead, | ||
bool | ignoreCase = false |
||
) | const |
Replaces all occurrences of a substring with another string.
Returns a copy of this string, with any occurrences of stringToReplace swapped for stringToInsertInstead.
Note that this is a const method, and won't alter the string itself.
Definition at line 1290 of file juce_String.cpp.
String juce::String::replaceCharacter | ( | juce_wchar | characterToReplace, |
juce_wchar | characterToInsertInstead | ||
) | const |
Returns a string with all occurrences of a character replaced with a different one.
Definition at line 1355 of file juce_String.cpp.
Referenced by juce::URL::removeEscapeChars().
String juce::String::replaceCharacters | ( | StringRef | charactersToReplace, |
StringRef | charactersToInsertInstead | ||
) | const |
Replaces a set of characters with another set.
Returns a string in which each character from charactersToReplace has been replaced by the character at the equivalent position in newCharacters (so the two strings passed in must be the same length).
e.g. replaceCharacters ("abc", "def") replaces 'a' with 'd', 'b' with 'e', etc.
Note that this is a const method, and won't affect the string itself.
Definition at line 1378 of file juce_String.cpp.
String juce::String::replaceFirstOccurrenceOf | ( | StringRef | stringToReplace, |
StringRef | stringToInsertInstead, | ||
bool | ignoreCase = false |
||
) | const |
Replaces the first occurrence of a substring with another string.
Returns a copy of this string, with the first occurrence of stringToReplace swapped for stringToInsertInstead.
Note that this is a const method, and won't alter the string itself.
Definition at line 1308 of file juce_String.cpp.
String juce::String::replaceSection | ( | int | startIndex, |
int | numCharactersToReplace, | ||
StringRef | stringToInsert | ||
) | const |
Replaces a sub-section of the string with another string.
This will return a copy of this string, with a set of characters from startIndex to startIndex + numCharsToReplace removed, and with a new string inserted in their place.
Note that this is a const method, and won't alter the string itself.
startIndex | the first character to remove. If this is beyond the bounds of the string, it will be constrained to a valid range. |
numCharactersToReplace | the number of characters to remove. If zero or less, no characters will be taken out. |
stringToInsert | the new string to insert at startIndex after the characters have been removed. |
Definition at line 1229 of file juce_String.cpp.
Referenced by juce::TextDiff::Change::appliedTo(), and replace().
Returns a version of this string that only retains a fixed set of characters.
This will return a copy of this string, omitting any characters which are not found in the string passed-in.
e.g. for "1122334455", retainCharacters ("432") would return "223344"
Note that this is a const method, and won't alter the string itself.
Definition at line 1746 of file juce_String.cpp.
Tests whether the string begins with another string. If the parameter is an empty string, this will always return true. Uses a case-sensitive comparison.
Definition at line 1404 of file juce_String.cpp.
|
noexcept |
Tests whether the string begins with a particular character. If the character is 0, this will always return false. Uses a case-sensitive comparison.
Definition at line 1414 of file juce_String.cpp.
Referenced by juce::URL::URL().
Tests whether the string begins with another string. If the parameter is an empty string, this will always return true. Uses a case-insensitive comparison.
Definition at line 1409 of file juce_String.cpp.
Returns a section of the string, starting from a given position.
startIndex | the first character to include. If this is beyond the end of the string, an empty string is returned. If it is zero or less, the whole string is returned. |
Definition at line 1548 of file juce_String.cpp.
Returns a subsection of the string.
If the range specified is beyond the limits of the string, as much as possible is returned.
startIndex | the index of the start of the substring needed |
endIndex | all characters from startIndex up to (but not including) this index are returned |
Definition at line 1509 of file juce_String.cpp.
Referenced by juce::File::createLegalPathName(), juce::File::getFileExtension(), juce::File::getFileName(), juce::File::getFileNameWithoutExtension(), juce::URL::getScheme(), juce::Time::getTimeZone(), juce::File::hasFileExtension(), and juce::URL::withNewSubPath().
Swaps the contents of this string with another one. This is a very fast operation, as no allocation or copying needs to be done.
Definition at line 260 of file juce_String.cpp.
|
inlinestatic |
Returns a string containing a decimal with a set number of significant figures.
number | the input number |
numberOfSignificantFigures | the number of significant figures to use |
Definition at line 1072 of file juce_String.h.
Returns a string containing a hex dump of a block of binary data.
data | the binary data to use as input |
size | how many bytes of data to use |
groupSize | how many bytes are grouped together before inserting a space into the output. e.g. group size 0 has no spaces, group size 1 looks like: "be a1 c2 ff", group size 2 looks like "bea1 c2ff". |
Definition at line 1928 of file juce_String.cpp.
|
inlinestatic |
Returns a string representing this numeric value in hexadecimal.
Definition at line 1053 of file juce_String.h.
Referenced by juce::File::createTempFile(), juce::MidiMessage::getDescription(), juce::SystemStats::getDeviceIdentifiers(), juce::SystemStats::getStackBacktrace(), juce::ChildProcessMaster::launchSlaveProcess(), juce::UnitTestRunner::runTests(), juce::IPAddress::toString(), and juce::MACAddress::toString().
String juce::String::toLowerCase | ( | ) | const |
Returns an lower-case version of this string.
Definition at line 1485 of file juce_String.cpp.
Referenced by juce::Expression::withRenamedSymbol().
Returns a pointer to a UTF-8 version of this string.
Because it returns a reference to the string's internal data, the pointer that is returned must not be stored anywhere, as it can be deleted whenever the string changes.
To find out how many bytes you need to store this string as UTF-8, you can call CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer())
Definition at line 2077 of file juce_String.cpp.
Referenced by juce::URL::addEscapeChars(), juce::Base64::toBase64(), juce::OutputStream::writeString(), and juce::OutputStream::writeText().
std::string juce::String::toStdString | ( | ) | const |
Definition at line 2087 of file juce_String.cpp.
String juce::String::toUpperCase | ( | ) | const |
Returns an upper-case version of this string.
Definition at line 1467 of file juce_String.cpp.
CharPointer_UTF16 juce::String::toUTF16 | ( | ) | const |
Returns a pointer to a UTF-16 version of this string.
Because it returns a reference to the string's internal data, the pointer that is returned must not be stored anywhere, as it can be deleted whenever the string changes.
To find out how many bytes you need to store this string as UTF-16, you can call CharPointer_UTF16::getBytesRequiredFor (myString.getCharPointer())
Definition at line 2074 of file juce_String.cpp.
CharPointer_UTF32 juce::String::toUTF32 | ( | ) | const |
Returns a pointer to a UTF-32 version of this string.
Because it returns a reference to the string's internal data, the pointer that is returned must not be stored anywhere, as it can be deleted whenever the string changes.
Definition at line 2075 of file juce_String.cpp.
CharPointer_UTF8 juce::String::toUTF8 | ( | ) | const |
Returns a pointer to a UTF-8 version of this string.
Because it returns a reference to the string's internal data, the pointer that is returned must not be stored anywhere, as it can be deleted whenever the string changes.
To find out how many bytes you need to store this string as UTF-8, you can call CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer())
Definition at line 2073 of file juce_String.cpp.
Returns a pointer to a wchar_t version of this string.
Because it returns a reference to the string's internal data, the pointer that is returned must not be stored anywhere, as it can be deleted whenever the string changes.
Bear in mind that the wchar_t type is different on different platforms, so on Windows, this will be equivalent to calling toUTF16(), on unix it'll be the same as calling toUTF32(), etc.
Definition at line 2082 of file juce_String.cpp.
String juce::String::trim | ( | ) | const |
Returns a copy of this string with any whitespace characters removed from the start and end.
Definition at line 1667 of file juce_String.cpp.
Returns a copy of this string, having removed a specified set of characters from its end. Characters are removed from the end of the string until it finds one that is not in the specified set, and then it stops.
charactersToTrim | the set of characters to remove. |
Definition at line 1722 of file juce_String.cpp.
Referenced by juce::File::createDirectory().
Returns a copy of this string, having removed a specified set of characters from its start. Characters are removed from the start of the string until it finds one that is not in the specified set, and then it stops.
charactersToTrim | the set of characters to remove. |
Definition at line 1712 of file juce_String.cpp.
String juce::String::trimEnd | ( | ) | const |
Returns a copy of this string with any whitespace characters removed from the end.
Definition at line 1698 of file juce_String.cpp.
Referenced by juce::File::hasFileExtension(), and juce::Time::toString().
String juce::String::trimStart | ( | ) | const |
Returns a copy of this string with any whitespace characters removed from the start.
Definition at line 1685 of file juce_String.cpp.
String juce::String::unquoted | ( | ) | const |
Removes quotation marks from around the string, (if there are any).
Returns a copy of this string with any quotes removed from its ends. Quotes that aren't at the ends of the string are not affected. If there aren't any quotes, the original string is returned.
Note that this is a const method, and won't alter the string itself.
Definition at line 1626 of file juce_String.cpp.
String juce::String::upToFirstOccurrenceOf | ( | StringRef | substringToEndWith, |
bool | includeSubStringInResult, | ||
bool | ignoreCase | ||
) | const |
Returns the start of this string, up to the first occurrence of a substring.
This will search for the first occurrence of a given substring, and then return a copy of the string, up to the position of this substring, optionally including or excluding the substring itself in the result.
e.g. for the string "123456", upTo ("34", false) would return "12", and upTo ("34", true) would return "1234".
If the substring isn't found, this will return the whole of the original string.
Definition at line 1596 of file juce_String.cpp.
Referenced by juce::XmlElement::getNamespace().
String juce::String::upToLastOccurrenceOf | ( | StringRef | substringToFind, |
bool | includeSubStringInResult, | ||
bool | ignoreCase | ||
) | const |
Returns the start of this string, up to the last occurrence of a substring.
Similar to upToFirstOccurrenceOf(), but this finds the last occurrence rather than the first. If the substring isn't found, this will return the whole of the original string.
Definition at line 1606 of file juce_String.cpp.