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)
74 return fallbackProperties !=
nullptr ? fallbackProperties->
getValue (keyName, defaultValue)
86 return fallbackProperties !=
nullptr ? fallbackProperties->
getIntValue (keyName, defaultValue)
96 return properties.
getAllValues()[index].getDoubleValue();
98 return fallbackProperties !=
nullptr ? fallbackProperties->
getDoubleValue (keyName, defaultValue)
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);
169 for (
int i = 0; i < source.properties.
size(); ++i)
177 fallbackProperties = fallbackProperties_;
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)
const StringArray & getAllValues() const noexcept
Returns a list of all values in the array.
XmlElement * getXmlValue(StringRef keyName) const
Returns one of the properties as an XML element.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
A simple class for holding temporary references to a string literal or String.
virtual ~PropertySet()
Destructor.
A variant class, that can be used to hold a range of primitive values.
A set of named property values, which can be strings, integers, floating point, etc.
const StringArray & getAllKeys() const noexcept
Returns a list of all keys in the array.
void restoreFromXml(const XmlElement &xml)
Reloads a set of properties that were previously stored as XML.
virtual void propertyChanged()
Subclasses can override this to be told when one of the properies has been changed.
bool isNotEmpty() const noexcept
Returns true if the string is not empty.
Used to build a tree of elements representing an XML document.
PropertySet & operator=(const PropertySet &other)
Copies another PropertySet over this one.
String getValue(StringRef keyName, const String &defaultReturnValue=String()) const noexcept
Returns one of the properties as a string.
bool getBoolValue(StringRef keyName, bool defaultReturnValue=false) const noexcept
Returns one of the properties as an boolean.
void clear()
Removes all elements from the array.
int size() const noexcept
Returns the number of strings in the array.
bool containsKey(StringRef keyName) const noexcept
Returns true if the properies include the given key.
XmlElement * createNewChildElement(StringRef tagName)
Creates a new element with the given name and returns it, after adding it as a child element...
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Searches for a string in the array.
XmlElement * createXml(const String &nodeName) const
Returns an XML element which encapsulates all the items in this property set.
void setAttribute(const Identifier &attributeName, const String &newValue)
Adds a named attribute to the element.
void removeValue(StringRef keyName)
Deletes a property.
int getIntValue(StringRef keyName, int defaultReturnValue=0) const noexcept
Returns one of the properties as an integer.
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 addAllPropertiesFrom(const PropertySet &source)
This copies all the values from a source PropertySet to this one.
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.
static XmlElement * parse(const File &file)
A handy static method that parses a file.
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.
double getDoubleValue(StringRef keyName, double defaultReturnValue=0.0) const noexcept
Returns one of the properties as an double.
void setValue(const String &keyName, const var &value)
Sets a named property.
void clear()
Removes all values.
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...
Automatically locks and unlocks a mutex object.
PropertySet(bool ignoreCaseOfKeyNames=false)
Creates an empty PropertySet.
const CriticalSection & getLock() const noexcept
Returns the lock used when reading or writing to this set.