LMMS
Loading...
Searching...
No Matches
StringArray.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the Water library.
5 Copyright (c) 2016 ROLI Ltd.
6 Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
7
8 Permission is granted to use this software under the terms of the ISC license
9 http://www.isc.org/downloads/software-support-policy/isc-license/
10
11 Permission to use, copy, modify, and/or distribute this software for any
12 purpose with or without fee is hereby granted, provided that the above
13 copyright notice and this permission notice appear in all copies.
14
15 THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
16 TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
18 OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
19 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
21 OF THIS SOFTWARE.
22
23 ==============================================================================
24*/
25
26#ifndef WATER_STRINGARRAY_H_INCLUDED
27#define WATER_STRINGARRAY_H_INCLUDED
28
29#include "String.h"
30#include "../containers/Array.h"
31
32namespace water {
33
34//==============================================================================
41{
42public:
43 //==============================================================================
45 StringArray() noexcept;
46
48 StringArray (const StringArray&);
49
51 explicit StringArray (const String& firstValue);
52
57 StringArray (const String* strings, int numberOfStrings);
58
64 StringArray (const char* const* strings, int numberOfStrings);
65
71 explicit StringArray (const char* const* strings);
72
75
78
80 void swapWith (StringArray&) noexcept;
81
82 //==============================================================================
87 bool operator== (const StringArray&) const noexcept;
88
93 bool operator!= (const StringArray&) const noexcept;
94
95 //==============================================================================
97 inline int size() const noexcept { return strings.size(); }
98
100 inline bool isEmpty() const noexcept { return size() == 0; }
101
109 const String& operator[] (int index) const noexcept;
110
115 String& getReference (int index) noexcept;
116
120 inline String* begin() const noexcept { return strings.begin(); }
121
125 inline String* end() const noexcept { return strings.end(); }
126
133 bool contains (StringRef stringToLookFor,
134 bool ignoreCase = false) const;
135
146 int indexOf (StringRef stringToLookFor,
147 bool ignoreCase = false,
148 int startIndex = 0) const;
149
150 //==============================================================================
152 bool add (const String& stringToAdd);
153
161 bool insert (int index, const String& stringToAdd);
162
168 bool addIfNotAlreadyThere (const String& stringToAdd, bool ignoreCase = false);
169
175 void set (int index, const String& newString);
176
184 void addArray (const StringArray& other,
185 int startIndex = 0,
186 int numElementsToAdd = -1);
187
194 void mergeArray (const StringArray& other,
195 bool ignoreCase = false);
196
204 int addTokens (StringRef stringToTokenise, bool preserveQuotedStrings);
205
220 int addTokens (StringRef stringToTokenise,
221 StringRef breakCharacters,
222 StringRef quoteCharacters);
223
230 int addLines (StringRef stringToBreakUp);
231
238 static StringArray fromTokens (StringRef stringToTokenise,
239 bool preserveQuotedStrings);
240
254 static StringArray fromTokens (StringRef stringToTokenise,
255 StringRef breakCharacters,
256 StringRef quoteCharacters);
257
264 static StringArray fromLines (StringRef stringToBreakUp);
265
266 //==============================================================================
268 void clear();
269
273 void clearQuick();
274
278 void remove (int index);
279
284 void removeString (StringRef stringToRemove,
285 bool ignoreCase = false);
286
298 void removeRange (int startIndex, int numberToRemove);
299
307 void removeDuplicates (bool ignoreCase);
308
313 void removeEmptyStrings (bool removeWhitespaceStrings = true);
314
316 void trim();
317
333 void appendNumbersToDuplicates (bool ignoreCaseWhenComparing,
334 bool appendNumberToFirstInstance,
335 CharPointer_UTF8 preNumberString = CharPointer_UTF8 (nullptr),
336 CharPointer_UTF8 postNumberString = CharPointer_UTF8 (nullptr));
337
338 //==============================================================================
351 String joinIntoString (StringRef separatorString,
352 int startIndex = 0,
353 int numberOfElements = -1) const;
354
355 //==============================================================================
359 void sort (bool ignoreCase);
360
365 void sortNatural();
366
367 //==============================================================================
374 void ensureStorageAllocated (int minNumElements);
375
383
388};
389
390}
391
392#endif // WATER_STRINGARRAY_H_INCLUDED
#define noexcept
Definition DistrhoDefines.h:72
Array< String > strings
Definition StringArray.h:387
StringArray() noexcept
Definition StringArray.cpp:30
Definition Array.h:57
Definition CharPointer_UTF8.h:45
Definition StringArray.h:41
void set(int index, const String &newString)
Definition StringArray.cpp:147
bool operator!=(const StringArray &) const noexcept
Definition StringArray.cpp:74
String * begin() const noexcept
Definition StringArray.h:120
void clear()
Definition StringArray.cpp:84
bool add(const String &stringToAdd)
Definition StringArray.cpp:108
Array< String > strings
Definition StringArray.h:387
void trim()
Definition StringArray.cpp:224
int size() const noexcept
Definition StringArray.h:97
~StringArray()
Definition StringArray.cpp:65
bool contains(StringRef stringToLookFor, bool ignoreCase=false) const
Definition StringArray.cpp:152
bool insert(int index, const String &stringToAdd)
Definition StringArray.cpp:113
void sortNatural()
Definition StringArray.cpp:263
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Definition StringArray.cpp:369
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
Definition StringArray.cpp:270
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Definition StringArray.cpp:311
bool addIfNotAlreadyThere(const String &stringToAdd, bool ignoreCase=false)
Definition StringArray.cpp:118
void minimiseStorageOverheads()
Definition StringArray.cpp:455
void sort(bool ignoreCase)
Definition StringArray.cpp:249
void removeDuplicates(bool ignoreCase)
Definition StringArray.cpp:393
bool operator==(const StringArray &) const noexcept
Definition StringArray.cpp:69
bool isEmpty() const noexcept
Definition StringArray.h:100
String * end() const noexcept
Definition StringArray.h:125
void clearQuick()
Definition StringArray.cpp:89
static StringArray fromLines(StringRef stringToBreakUp)
Definition StringArray.cpp:385
void ensureStorageAllocated(int minNumElements)
Definition StringArray.cpp:450
const String & operator[](int index) const noexcept
Definition StringArray.cpp:94
String & getReference(int index) noexcept
Definition StringArray.cpp:103
int addLines(StringRef stringToBreakUp)
Definition StringArray.cpp:340
StringArray & operator=(const StringArray &)
Definition StringArray.cpp:59
void remove(int index)
Definition StringArray.cpp:181
void removeEmptyStrings(bool removeWhitespaceStrings=true)
Definition StringArray.cpp:208
void mergeArray(const StringArray &other, bool ignoreCase=false)
Definition StringArray.cpp:141
void appendNumbersToDuplicates(bool ignoreCaseWhenComparing, bool appendNumberToFirstInstance, CharPointer_UTF8 preNumberString=CharPointer_UTF8(nullptr), CharPointer_UTF8 postNumberString=CharPointer_UTF8(nullptr))
Definition StringArray.cpp:411
void swapWith(StringArray &) noexcept
Definition StringArray.cpp:79
void removeRange(int startIndex, int numberToRemove)
Definition StringArray.cpp:202
StringArray() noexcept
Definition StringArray.cpp:30
void removeString(StringRef stringToRemove, bool ignoreCase=false)
Definition StringArray.cpp:186
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Definition StringArray.cpp:157
void addArray(const StringArray &other, int startIndex=0, int numElementsToAdd=-1)
Definition StringArray.cpp:126
Definition String.h:48
Definition StringRef.h:67
Definition AudioSampleBuffer.h:33
#define const
Definition zconf.h:137