OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_StringArray.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
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
23namespace juce
24{
25
26//==============================================================================
34class JUCE_API StringArray
35{
36public:
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) : strings (firstValue, otherValues...) {}
53
55 StringArray (const std::initializer_list<const char*>& strings);
56
58 StringArray (Array<String>&&) noexcept;
59
61 template <typename Type>
62 StringArray (const Array<Type>& stringArray)
63 {
64 addArray (stringArray.begin(), stringArray.end());
65 }
66
71 StringArray (const String* strings, int numberOfStrings);
72
78 StringArray (const char* const* strings, int numberOfStrings);
79
85 explicit StringArray (const char* const* strings);
86
91 explicit StringArray (const wchar_t* const* strings);
92
98 StringArray (const wchar_t* const* strings, int numberOfStrings);
99
101 ~StringArray();
102
104 StringArray& operator= (const StringArray&);
105
107 StringArray& operator= (StringArray&&) noexcept;
108
110 template <typename Type>
111 StringArray& operator= (const Array<Type>& stringArray)
112 {
113 addArray (stringArray.begin(), stringArray.end());
114 return *this;
115 }
116
118 void swapWith (StringArray&) noexcept;
119
120 //==============================================================================
125 bool operator== (const StringArray&) const noexcept;
126
131 bool operator!= (const StringArray&) const noexcept;
132
133 //==============================================================================
135 inline int size() const noexcept { return strings.size(); }
136
138 inline bool isEmpty() const noexcept { return size() == 0; }
139
147 const String& operator[] (int index) const noexcept;
148
153 String& getReference (int index) noexcept;
154
158 inline String* begin() noexcept { return strings.begin(); }
159
163 inline const String* begin() const noexcept { return strings.begin(); }
164
168 inline String* end() noexcept { return strings.end(); }
169
173 inline const String* end() const noexcept { return strings.end(); }
174
175
182 bool contains (StringRef stringToLookFor,
183 bool ignoreCase = false) const;
184
195 int indexOf (StringRef stringToLookFor,
196 bool ignoreCase = false,
197 int startIndex = 0) const;
198
199 //==============================================================================
201 void add (String stringToAdd);
202
210 void insert (int index, String stringToAdd);
211
217 bool addIfNotAlreadyThere (const String& stringToAdd, bool ignoreCase = false);
218
224 void set (int index, String newString);
225
233 void addArray (const StringArray& other,
234 int startIndex = 0,
235 int numElementsToAdd = -1);
236
240 template <typename Iterator>
241 void addArray (Iterator&& start, Iterator&& end)
242 {
243 ensureStorageAllocated (size() + (int) static_cast<size_t> (end - start));
244
245 while (start != end)
246 strings.add (*start++);
247 }
248
255 void mergeArray (const StringArray& other,
256 bool ignoreCase = false);
257
265 int addTokens (StringRef stringToTokenise, bool preserveQuotedStrings);
266
281 int addTokens (StringRef stringToTokenise,
282 StringRef breakCharacters,
283 StringRef quoteCharacters);
284
291 int addLines (StringRef stringToBreakUp);
292
299 static StringArray fromTokens (StringRef stringToTokenise,
300 bool preserveQuotedStrings);
301
315 static StringArray fromTokens (StringRef stringToTokenise,
316 StringRef breakCharacters,
317 StringRef quoteCharacters);
318
325 static StringArray fromLines (StringRef stringToBreakUp);
326
327 //==============================================================================
329 void clear();
330
334 void clearQuick();
335
339 void remove (int index);
340
345 void removeString (StringRef stringToRemove,
346 bool ignoreCase = false);
347
359 void removeRange (int startIndex, int numberToRemove);
360
368 void removeDuplicates (bool ignoreCase);
369
374 void removeEmptyStrings (bool removeWhitespaceStrings = true);
375
390 void move (int currentIndex, int newIndex) noexcept;
391
393 void trim();
394
410 void appendNumbersToDuplicates (bool ignoreCaseWhenComparing,
411 bool appendNumberToFirstInstance,
412 CharPointer_UTF8 preNumberString = CharPointer_UTF8 (nullptr),
413 CharPointer_UTF8 postNumberString = CharPointer_UTF8 (nullptr));
414
415 //==============================================================================
428 String joinIntoString (StringRef separatorString,
429 int startIndex = 0,
430 int numberOfElements = -1) const;
431
432 //==============================================================================
436 void sort (bool ignoreCase);
437
442 void sortNatural();
443
444 //==============================================================================
451 void ensureStorageAllocated (int minNumElements);
452
459 void minimiseStorageOverheads();
460
465
466private:
467 JUCE_LEAK_DETECTOR (StringArray)
468};
469
470} // namespace juce
StringArray(StringRef firstValue, OtherElements... otherValues)
const String * begin() const noexcept
Array< String > strings
void addArray(Iterator &&start, Iterator &&end)
int size() const noexcept
String * end() noexcept
const String * end() const noexcept
bool isEmpty() const noexcept
String * begin() noexcept