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)
73 return fallbackProperties !=
nullptr ? fallbackProperties->
getValue (keyName, defaultValue)
85 return fallbackProperties !=
nullptr ? fallbackProperties->
getIntValue (keyName, defaultValue)
95 return properties.
getAllValues()[index].getDoubleValue();
97 return fallbackProperties !=
nullptr ? fallbackProperties->
getDoubleValue (keyName, defaultValue)
107 return properties.
getAllValues() [index].getIntValue() != 0;
109 return fallbackProperties !=
nullptr ? fallbackProperties->
getBoolValue (keyName, defaultValue)
115 return parseXML (
getValue (keyName));
124 auto value = v.toString();
128 if (index < 0 || properties.
getAllValues() [index] != value)
130 properties.
set (keyName, value);
145 properties.
remove (keyName);
167 for (
int i = 0; i < source.properties.
size(); ++i)
175 fallbackProperties = fallbackProperties_;
180 auto xml = std::make_unique<XmlElement> (nodeName);
186 auto e = xml->createNewChildElement (
"VALUE");
187 e->setAttribute (
"name", properties.
getAllKeys()[i]);
199 forEachXmlChildElementWithTagName (xml, e,
"VALUE")
201 if (e->hasAttribute (
"name")
202 && e->hasAttribute (
"val"))
204 properties.
set (e->getStringAttribute (
"name"),
205 e->getStringAttribute (
"val"));
209 if (properties.
size() > 0)
const StringArray & getAllValues() const noexcept
Returns a list of all values in the array.
TextFormat singleLine() const
returns a copy of this format with newLineChars set to nullptr.
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 properties 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.
std::unique_ptr< XmlElement > getXmlValue(StringRef keyName) const
Returns one of the properties as an XML element.
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 properties include the given key.
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Searches for a string in the array.
std::unique_ptr< XmlElement > createXml(const String &nodeName) const
Returns an XML element which encapsulates all the items in this property set.
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 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.
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.
A struct containing options for formatting the text when representing an XML element as a string...
TextFormat withoutHeader() const
returns a copy of this format with the addDefaultHeader flag set to false.
String toString(const TextFormat &format={}) const
Returns a text version of this XML element.