OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_StringArray.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23 namespace juce
24{
25
26//==============================================================================
34 class JUCE_API StringArray
35{
36 public:
37 //==============================================================================
39 StringArray() noexcept;
40
42 StringArray (const StringArray&);
43
45 StringArray (StringArray&&) noexcept;
46
48 StringArray (const String& firstValue);
49
51 template <typename... OtherElements>
52 StringArray (StringRef firstValue, OtherElements&&... otherValues)
53 : strings (firstValue, std::forward<OtherElements> (otherValues)...) {}
54
56 StringArray (const std::initializer_list<const char*>& strings);
57
59 StringArray (Array<String>&&) noexcept;
60
62 template <typename Type>
63 StringArray (const Array<Type>& stringArray)
64 {
65 addArray (stringArray.begin(), stringArray.end());
66 }
67
72 StringArray (const String* strings, int numberOfStrings);
73
79 StringArray (const char* const* strings, int numberOfStrings);
80
86 explicit StringArray (const char* const* strings);
87
92 explicit StringArray (const wchar_t* const* strings);
93
99 StringArray (const wchar_t* const* strings, int numberOfStrings);
100
102 ~StringArray() = default;
103
105 StringArray& operator= (const StringArray&);
106
108 StringArray& operator= (StringArray&&) noexcept;
109
111 template <typename Type>
112 StringArray& operator= (const Array<Type>& stringArray)
113 {
114 addArray (stringArray.begin(), stringArray.end());
115 return *this;
116 }
117
119 void swapWith (StringArray&) noexcept;
120
121 //==============================================================================
126 bool operator== (const StringArray&) const noexcept;
127
132 bool operator!= (const StringArray&) const noexcept;
133
134 //==============================================================================
136 inline int size() const noexcept { return strings.size(); }
137
139 inline bool isEmpty() const noexcept { return size() == 0; }
140
148 const String& operator[] (int index) const noexcept;
149
154 String& getReference (int index) noexcept;
155
160 const String& getReference (int index) const noexcept;
161
165 inline String* begin() noexcept { return strings.begin(); }
166
170 inline const String* begin() const noexcept { return strings.begin(); }
171
175 inline String* end() noexcept { return strings.end(); }
176
180 inline const String* end() const noexcept { return strings.end(); }
181
182
189 bool contains (StringRef stringToLookFor,
190 bool ignoreCase = false) const;
191
202 int indexOf (StringRef stringToLookFor,
203 bool ignoreCase = false,
204 int startIndex = 0) const;
205
206 //==============================================================================
208 void add (String stringToAdd);
209
217 void insert (int index, String stringToAdd);
218
224 bool addIfNotAlreadyThere (const String& stringToAdd, bool ignoreCase = false);
225
231 void set (int index, String newString);
232
240 void addArray (const StringArray& other,
241 int startIndex = 0,
242 int numElementsToAdd = -1);
243
247 template <typename Iterator>
248 void addArray (Iterator&& start, Iterator&& end)
249 {
250 ensureStorageAllocated (size() + (int) static_cast<size_t> (end - start));
251
252 while (start != end)
253 strings.add (*start++);
254 }
255
262 void mergeArray (const StringArray& other,
263 bool ignoreCase = false);
264
272 int addTokens (StringRef stringToTokenise, bool preserveQuotedStrings);
273
288 int addTokens (StringRef stringToTokenise,
289 StringRef breakCharacters,
290 StringRef quoteCharacters);
291
298 int addLines (StringRef stringToBreakUp);
299
306 static StringArray fromTokens (StringRef stringToTokenise,
307 bool preserveQuotedStrings);
308
322 static StringArray fromTokens (StringRef stringToTokenise,
323 StringRef breakCharacters,
324 StringRef quoteCharacters);
325
332 static StringArray fromLines (StringRef stringToBreakUp);
333
334 //==============================================================================
336 void clear();
337
341 void clearQuick();
342
346 void remove (int index);
347
352 void removeString (StringRef stringToRemove,
353 bool ignoreCase = false);
354
366 void removeRange (int startIndex, int numberToRemove);
367
375 void removeDuplicates (bool ignoreCase);
376
381 void removeEmptyStrings (bool removeWhitespaceStrings = true);
382
397 void move (int currentIndex, int newIndex) noexcept;
398
400 void trim();
401
417 void appendNumbersToDuplicates (bool ignoreCaseWhenComparing,
418 bool appendNumberToFirstInstance,
419 CharPointer_UTF8 preNumberString = CharPointer_UTF8 (nullptr),
420 CharPointer_UTF8 postNumberString = CharPointer_UTF8 (nullptr));
421
422 //==============================================================================
435 String joinIntoString (StringRef separatorString,
436 int startIndex = 0,
437 int numberOfElements = -1) const;
438
439 //==============================================================================
443 void sort (bool ignoreCase);
444
449 void sortNatural();
450
451 //==============================================================================
458 void ensureStorageAllocated (int minNumElements);
459
466 void minimiseStorageOverheads();
467
471 Array<String> strings;
472
473 private:
474 JUCE_LEAK_DETECTOR (StringArray)
475};
476
477} // namespace juce
juce::Array
Definition juce_Array.h:56
juce::CharPointer_UTF8
Definition juce_CharPointer_UTF8.h:35
juce::StringArray
Definition juce_StringArray.h:35
juce::StringArray::StringArray
StringArray(StringRef firstValue, OtherElements &&... otherValues)
Definition juce_StringArray.h:52
juce::StringArray::begin
const String * begin() const noexcept
Definition juce_StringArray.h:170
juce::StringArray::strings
Array< String > strings
Definition juce_StringArray.h:471
juce::StringArray::addArray
void addArray(Iterator &&start, Iterator &&end)
Definition juce_StringArray.h:248
juce::StringArray::~StringArray
~StringArray()=default
juce::StringArray::size
int size() const noexcept
Definition juce_StringArray.h:136
juce::StringArray::end
String * end() noexcept
Definition juce_StringArray.h:175
juce::StringArray::end
const String * end() const noexcept
Definition juce_StringArray.h:180
juce::StringArray::isEmpty
bool isEmpty() const noexcept
Definition juce_StringArray.h:139
juce::StringArray::begin
String * begin() noexcept
Definition juce_StringArray.h:165
juce::StringRef
Definition juce_StringRef.h:62
juce::String
Definition juce_String.h:53
juce::String::begin
CharPointerType begin() const
Definition juce_String.h:923
juce::String::end
CharPointerType end() const
Definition juce_String.h:949