36 :
strings (std::move (other.strings))
52 strings.addArray (initialStrings, numberOfStrings);
57 strings.addNullTerminatedArray (initialStrings);
62 strings.addArray (initialStrings, numberOfStrings);
67 strings.addNullTerminatedArray (initialStrings);
72 strings.addArray (initialStrings, numberOfStrings);
88 strings = std::move (other.strings);
98 return strings == other.strings;
108 strings.swapWith (other.strings);
123 if (isPositiveAndBelow (index,
strings.size()))
124 return strings.getReference (index);
132 return strings.getReference (index);
139 strings.add (std::move (newString));
146 strings.insert (index, std::move (newString));
151 if (
contains (newString, ignoreCase))
160 jassert (
this != &otherArray);
168 if (numElementsToAdd < 0 || startIndex + numElementsToAdd > otherArray.
size())
169 numElementsToAdd = otherArray.
size() - startIndex;
171 while (--numElementsToAdd >= 0)
177 jassert (
this != &otherArray);
179 for (
auto& s : otherArray)
185 strings.set (index, std::move (newString));
190 return indexOf (stringToLookFor, ignoreCase) >= 0;
198 auto numElements =
size();
202 for (; i < numElements; ++i)
203 if (
strings.getReference(i).equalsIgnoreCase (stringToLookFor))
208 for (; i < numElements; ++i)
209 if (stringToLookFor ==
strings.getReference (i))
218 strings.move (currentIndex, newIndex);
231 for (
int i =
size(); --i >= 0;)
232 if (
strings.getReference(i).equalsIgnoreCase (stringToRemove))
237 for (
int i =
size(); --i >= 0;)
238 if (stringToRemove ==
strings.getReference (i))
245 strings.removeRange (startIndex, numberToRemove);
251 if (removeWhitespaceStrings)
253 for (
int i =
size(); --i >= 0;)
254 if (!
strings.getReference(i).containsNonWhitespaceChars())
259 for (
int i =
size(); --i >= 0;)
260 if (
strings.getReference(i).isEmpty())
290 auto last = (numberToJoin < 0) ?
size()
291 : jmin (
size(), start + numberToJoin);
299 if (start == last - 1)
300 return strings.getReference (start);
302 auto separatorBytes = separator.
text.sizeInBytes() -
sizeof (String::CharPointerType::CharType);
303 auto bytesNeeded = (size_t) (last - start - 1) * separatorBytes;
305 for (
int i = start; i < last; ++i)
306 bytesNeeded +=
strings.getReference(i).getCharPointer().sizeInBytes() -
sizeof (String::CharPointerType::CharType);
315 auto& s =
strings.getReference (start);
318 dest.writeAll (s.getCharPointer());
320 if (++start < last && separatorBytes > 0)
321 dest.writeAll (separator.
text);
330 return addTokens (text,
" \n\r\t", preserveQuotedStrings ?
"\"" :
"");
339 for (
auto t = text.
text;;)
342 breakCharacters.
text,
343 quoteCharacters.
text);
347 if (tokenEnd.isEmpty())
360 auto text = sourceText.
text;
361 bool finished = text.isEmpty();
365 for (
auto startOfLine = text;;)
367 auto endOfLine = text;
369 switch (text.getAndAdvance())
371 case 0: finished =
true;
break;
373 case '\r':
if (*text ==
'\n') ++text;
break;
389 s.
addTokens (stringToTokenise, preserveQuotedStrings);
398 s.
addTokens (stringToTokenise, breakCharacters, quoteCharacters);
412 for (
int i = 0; i <
size() - 1; ++i)
414 auto s =
strings.getReference(i);
416 for (
int nextIndex = i + 1;;)
418 nextIndex =
indexOf (s, ignoreCase, nextIndex);
429 bool appendNumberToFirstInstance,
439 for (
int i = 0; i <
size() - 1; ++i)
441 auto& s =
strings.getReference(i);
442 auto nextIndex =
indexOf (s, ignoreCase, i + 1);
449 if (appendNumberToFirstInstance)
450 s = original +
String (preNumberString) +
String (++number) +
String (postNumberString);
454 while (nextIndex >= 0)
456 set (nextIndex, (*this)[nextIndex] + String (preNumberString) + String (++number) + String (postNumberString));
457 nextIndex =
indexOf (original, ignoreCase, nextIndex + 1);
465 strings.ensureStorageAllocated (minNumElements);
470 strings.minimiseStorageOverheads();
void addArray(const StringArray &other, int startIndex=0, int numElementsToAdd=-1)
static Type findEndOfToken(Type text, BreakType breakCharacters, Type quoteCharacters)
bool operator!=(const StringArray &) const noexcept
bool isNotEmpty() const noexcept
void appendNumbersToDuplicates(bool ignoreCaseWhenComparing, bool appendNumberToFirstInstance, CharPointer_UTF8 preNumberString=CharPointer_UTF8(nullptr), CharPointer_UTF8 postNumberString=CharPointer_UTF8(nullptr))
void removeEmptyStrings(bool removeWhitespaceStrings=true)
void removeDuplicates(bool ignoreCase)
int compareNatural(StringRef other, bool isCaseSensitive=false) const noexcept
CharPointerType getCharPointer() const noexcept
int addLines(StringRef stringToBreakUp)
void move(int currentIndex, int newIndex) noexcept
String & getReference(int index) noexcept
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
void minimiseStorageOverheads()
void set(int index, String newString)
int compareIgnoreCase(const String &other) const noexcept
bool operator==(const StringArray &) const noexcept
CharType * getAddress() const noexcept
void ensureStorageAllocated(int minNumElements)
void removeString(StringRef stringToRemove, bool ignoreCase=false)
void removeRange(int startIndex, int numberToRemove)
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
bool addIfNotAlreadyThere(const String &stringToAdd, bool ignoreCase=false)
void sort(bool ignoreCase)
void preallocateBytes(size_t numBytesNeeded)
String::CharPointerType text
bool contains(StringRef stringToLookFor, bool ignoreCase=false) const
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
static StringArray fromLines(StringRef stringToBreakUp)
void insert(int index, String stringToAdd)
int size() const noexcept
const String & operator[](int index) const noexcept
void mergeArray(const StringArray &other, bool ignoreCase=false)
StringArray & operator=(const StringArray &)
void swapWith(StringArray &) noexcept
void add(String stringToAdd)