31 : strings (
other.strings)
36 : strings (std::move (
other.strings))
41 : strings (std::move (
other))
88 strings = std::move (
other.strings);
94 return strings ==
other.strings;
99 return ! operator== (
other);
104 strings.swapWith (
other.strings);
120 return strings.getReference (index);
128 return strings.getReference (index);
133 return strings.getReference (index);
232 for (
int i =
size(); --i >= 0;)
238 for (
int i =
size(); --i >= 0;)
254 for (
int i =
size(); --i >= 0;)
255 if (!
strings.getReference (i).containsNonWhitespaceChars())
260 for (
int i =
size(); --i >= 0;)
261 if (
strings.getReference (i).isEmpty())
277 [] (
const String& a,
const String& b) { return a.compareIgnoreCase (b) < 0; });
285 [] (
const String& a,
const String& b) { return a.compareNatural (b) < 0; });
300 if (start == last - 1)
301 return strings.getReference (start);
306 for (
int i = start; i < last; ++i)
307 bytesNeeded +=
strings.getReference (i).getCharPointer().sizeInBytes() -
sizeof (String::CharPointerType::CharType);
316 auto& s =
strings.getReference (start);
322 dest.writeAll (separator.
text);
340 for (
auto t = text.
text;;)
362 bool finished = text.isEmpty();
370 switch (text.getAndAdvance())
372 case 0: finished =
true;
break;
374 case '\r':
if (*text ==
'\n') ++text;
break;
413 for (
int i = 0; i <
size() - 1; ++i)
417 for (
int nextIndex = i + 1;;)
419 nextIndex =
indexOf (s, ignoreCase, nextIndex);
440 for (
int i = 0; i <
size() - 1; ++i)
442 auto& s =
strings.getReference (i);
443 auto nextIndex =
indexOf (s, ignoreCase, i + 1);
455 while (nextIndex >= 0)
471 strings.minimiseStorageOverheads();
Holds a resizable array of primitive or copy-by-value objects.
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
void writeAll(const CharPointer src) noexcept
Copies a source string to this pointer, advancing this pointer as it goes.
size_t sizeInBytes() const noexcept
Returns the number of bytes that are used to represent this string.
static Type findEndOfToken(Type text, BreakType breakCharacters, Type quoteCharacters)
Returns a pointer to the first character in the string which is found in the breakCharacters string.
A special array for holding a list of strings.
bool operator==(const StringArray &) const noexcept
Compares two arrays.
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
Joins the strings in the array together into one string.
void appendNumbersToDuplicates(bool ignoreCaseWhenComparing, bool appendNumberToFirstInstance, CharPointer_UTF8 preNumberString=CharPointer_UTF8(nullptr), CharPointer_UTF8 postNumberString=CharPointer_UTF8(nullptr))
Adds numbers to the strings in the array, to make each string unique.
String & getReference(int index) noexcept
Returns a reference to one of the strings in the array.
void removeEmptyStrings(bool removeWhitespaceStrings=true)
Removes empty strings from the array.
void addArray(const StringArray &other, int startIndex=0, int numElementsToAdd=-1)
Appends some strings from another array to the end of this one.
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Searches for a string in the array.
void sortNatural()
Sorts the array using extra language-aware rules to do a better job of comparing words containing spa...
bool contains(StringRef stringToLookFor, bool ignoreCase=false) const
Searches for a string in the array.
void removeDuplicates(bool ignoreCase)
Removes any duplicated elements from the array.
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Returns an array containing the tokens in a given string.
void insert(int index, String stringToAdd)
Inserts a string into the array.
static StringArray fromLines(StringRef stringToBreakUp)
Returns an array containing the lines in a given string.
void minimiseStorageOverheads()
Reduces the amount of storage being used by the array.
void clear()
Removes all elements from the array.
Array< String > strings
This is the array holding the actual strings.
StringArray() noexcept
Creates an empty string array.
const String & operator[](int index) const noexcept
Returns one of the strings from the array.
void removeString(StringRef stringToRemove, bool ignoreCase=false)
Finds a string in the array and removes it.
void sort(bool ignoreCase)
Sorts the array into alphabetical order.
void move(int currentIndex, int newIndex) noexcept
Moves one of the strings to a different position.
void swapWith(StringArray &) noexcept
Swaps the contents of this and another StringArray.
int size() const noexcept
Returns the number of strings in the array.
bool operator!=(const StringArray &) const noexcept
Compares two arrays.
void trim()
Deletes any whitespace characters from the starts and ends of all the strings.
void add(String stringToAdd)
Appends a string at the end of the array.
int addLines(StringRef stringToBreakUp)
Breaks up a string into lines and adds them to this array.
void clearQuick()
Removes all elements from the array without freeing the array's allocated storage.
void mergeArray(const StringArray &other, bool ignoreCase=false)
Merges the strings from another array into this one.
bool addIfNotAlreadyThere(const String &stringToAdd, bool ignoreCase=false)
Adds a string to the array as long as it's not already in there.
void removeRange(int startIndex, int numberToRemove)
Removes a range of elements from the array.
StringArray & operator=(const StringArray &)
Copies the contents of another string array into this one.
void set(int index, String newString)
Replaces one of the strings in the array with another one.
void remove(int index)
Removes a string from the array.
void ensureStorageAllocated(int minNumElements)
Increases the array's internal storage to hold a minimum number of elements.
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Breaks up a string into tokens and adds them to this array.
A simple class for holding temporary references to a string literal or String.
bool isNotEmpty() const noexcept
Returns true if the string is not empty.
String::CharPointerType text
The text that is referenced.
CharPointerType getCharPointer() const noexcept
Returns the character pointer currently being used to store this string.
void preallocateBytes(size_t numBytesNeeded)
Increases the string's internally allocated storage.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.