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