32 values (other.values),
33 ignoreCase (other.ignoreCase)
44 values = other.values;
52 if (num != other.
size())
55 for (
int i = 0; i < num; ++i)
57 if (keys[i] == other.keys[i])
59 if (values[i] != other.values[i])
65 for (
int j = i; j < num; ++j)
67 auto otherIndex = other.keys.
indexOf (keys[j], other.ignoreCase);
69 if (otherIndex < 0 || values[j] != other.values[otherIndex])
87 return values[keys.
indexOf (key, ignoreCase)];
92 auto i = keys.
indexOf (key, ignoreCase);
97 return defaultReturnValue;
102 return keys.contains (key, ignoreCase);
107 auto i = keys.
indexOf (key, ignoreCase);
111 values.
set (i, value);
122 for (
int i = 0; i < other.
size(); ++i)
123 set (other.keys[i], other.values[i]);
145 ignoreCase = shouldIgnoreCase;
152 for (
int i = 0; i < keys.
size(); ++i)
154 s << keys[i] <<
" = " << values[i];
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Searches for a string in the array.
void minimiseStorageOverheads()
Reduces the amount of storage being used by the array.
void clear()
Removes all elements from the array.
int size() const noexcept
Returns the number of strings in the array.
void add(String stringToAdd)
Appends a string at the end of the array.
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.
A container for holding a set of strings which are keyed by another string.
void setIgnoresCase(bool shouldIgnoreCase)
Indicates whether to use a case-insensitive search when looking up a key string.
String getValue(StringRef, const String &defaultReturnValue) const
Finds the value corresponding to a key string.
StringPairArray & operator=(const StringPairArray &other)
Copies the contents of another string array into this one.
bool containsKey(StringRef key) const noexcept
Returns true if the given key exists.
void set(const String &key, const String &value)
Adds or amends a key/value pair.
void clear()
Removes all elements from the array.
String getDescription() const
Returns a descriptive string containing the items.
void remove(StringRef key)
Removes a string from the array based on its key.
~StringPairArray()
Destructor.
StringPairArray(bool ignoreCaseWhenComparingKeys=true)
Creates an empty array.
const String & operator[](StringRef key) const
Finds the value corresponding to a key string.
bool operator!=(const StringPairArray &other) const
Compares two arrays.
void minimiseStorageOverheads()
Reduces the amount of storage being used by the array.
void addArray(const StringPairArray &other)
Adds the items from another array to this one.
int size() const noexcept
Returns the number of strings in the array.
bool operator==(const StringPairArray &other) const
Compares two arrays.
A simple class for holding temporary references to a string literal or String.