27 : properties (ignoreCaseOfKeyNames),
28 fallbackProperties (nullptr),
29 ignoreCaseOfKeys (ignoreCaseOfKeyNames)
34 : properties (other.properties),
35 fallbackProperties (other.fallbackProperties),
36 ignoreCaseOfKeys (other.ignoreCaseOfKeys)
42 properties = other.properties;
43 fallbackProperties = other.fallbackProperties;
44 ignoreCaseOfKeys = other.ignoreCaseOfKeys;
58 if (properties.
size() > 0)
69 const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
72 return properties.getAllValues() [index];
74 return fallbackProperties !=
nullptr ? fallbackProperties->getValue (keyName, defaultValue)
81 const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
84 return properties.getAllValues() [index].getIntValue();
86 return fallbackProperties !=
nullptr ? fallbackProperties->getIntValue (keyName, defaultValue)
93 const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
96 return properties.getAllValues()[index].getDoubleValue();
98 return fallbackProperties !=
nullptr ? fallbackProperties->getDoubleValue (keyName, defaultValue)
105 const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
108 return properties.getAllValues() [index].getIntValue() != 0;
110 return fallbackProperties !=
nullptr ? fallbackProperties->getBoolValue (keyName, defaultValue)
125 const String value (v.toString());
130 if (index < 0 || properties.
getAllValues() [index] != value)
132 properties.
set (keyName, value);
147 properties.
remove (keyName);
162 return properties.getAllKeys().contains (keyName, ignoreCaseOfKeys);
169 for (
int i = 0; i < source.properties.
size(); ++i)
177 fallbackProperties = fallbackProperties_;
185 for (
int i = 0; i < properties.
getAllKeys().size(); ++i)
200 forEachXmlChildElementWithTagName (xml, e,
"VALUE")
202 if (e->hasAttribute (
"name")
203 && e->hasAttribute (
"val"))
205 properties.
set (e->getStringAttribute (
"name"),
206 e->getStringAttribute (
"val"));
210 if (properties.
size() > 0)
Automatically locks and unlocks a mutex object.
A set of named property values, which can be strings, integers, floating point, etc.
virtual void propertyChanged()
Subclasses can override this to be told when one of the properies has been changed.
const CriticalSection & getLock() const noexcept
Returns the lock used when reading or writing to this set.
void setFallbackPropertySet(PropertySet *fallbackProperties) noexcept
Sets up a second PopertySet that will be used to look up any values that aren't set in this one.
void clear()
Removes all values.
virtual ~PropertySet()
Destructor.
XmlElement * createXml(const String &nodeName) const
Returns an XML element which encapsulates all the items in this property set.
void addAllPropertiesFrom(const PropertySet &source)
This copies all the values from a source PropertySet to this one.
PropertySet(bool ignoreCaseOfKeyNames=false)
Creates an empty PropertySet.
String getValue(StringRef keyName, const String &defaultReturnValue=String()) const noexcept
Returns one of the properties as a string.
double getDoubleValue(StringRef keyName, double defaultReturnValue=0.0) const noexcept
Returns one of the properties as an double.
bool containsKey(StringRef keyName) const noexcept
Returns true if the properies include the given key.
void removeValue(StringRef keyName)
Deletes a property.
int getIntValue(StringRef keyName, int defaultReturnValue=0) const noexcept
Returns one of the properties as an integer.
void setValue(const String &keyName, const var &value)
Sets a named property.
bool getBoolValue(StringRef keyName, bool defaultReturnValue=false) const noexcept
Returns one of the properties as an boolean.
void restoreFromXml(const XmlElement &xml)
Reloads a set of properties that were previously stored as XML.
PropertySet & operator=(const PropertySet &other)
Copies another PropertySet over this one.
XmlElement * getXmlValue(StringRef keyName) const
Returns one of the properties as an XML element.
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Searches for a string in the array.
void set(const String &key, const String &value)
Adds or amends a key/value pair.
void clear()
Removes all elements from the array.
void remove(StringRef key)
Removes a string from the array based on its key.
const StringArray & getAllValues() const noexcept
Returns a list of all values in the array.
int size() const noexcept
Returns the number of strings in the array.
const StringArray & getAllKeys() const noexcept
Returns a list of all keys in the array.
A simple class for holding temporary references to a string literal or String.
bool isNotEmpty() const noexcept
Returns true if the string is not empty.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
static XmlElement * parse(const File &file)
A handy static method that parses a file.
Used to build a tree of elements representing an XML document.
XmlElement * createNewChildElement(StringRef tagName)
Creates a new element with the given name and returns it, after adding it as a child element.
String createDocument(StringRef dtdToUse, bool allOnOneLine=false, bool includeXmlHeader=true, StringRef encodingType="UTF-8", int lineWrapLength=60) const
Returns an XML text document that represents this element.
void setAttribute(const Identifier &attributeName, const String &newValue)
Adds a named attribute to the element.
A variant class, that can be used to hold a range of primitive values.