OpenShot Library | libopenshot-audio
0.1.9
|
A set of named property values, which can be strings, integers, floating point, etc. More...
#include <juce_PropertySet.h>
Public Member Functions | |
PropertySet (bool ignoreCaseOfKeyNames=false) | |
Creates an empty PropertySet. More... | |
PropertySet (const PropertySet &other) | |
Creates a copy of another PropertySet. More... | |
PropertySet & | operator= (const PropertySet &other) |
Copies another PropertySet over this one. More... | |
virtual | ~PropertySet () |
Destructor. More... | |
String | getValue (StringRef keyName, const String &defaultReturnValue=String()) const noexcept |
Returns one of the properties as a string. More... | |
int | getIntValue (StringRef keyName, int defaultReturnValue=0) const noexcept |
Returns one of the properties as an integer. More... | |
double | getDoubleValue (StringRef keyName, double defaultReturnValue=0.0) const noexcept |
Returns one of the properties as an double. More... | |
bool | getBoolValue (StringRef keyName, bool defaultReturnValue=false) const noexcept |
Returns one of the properties as an boolean. More... | |
XmlElement * | getXmlValue (StringRef keyName) const |
Returns one of the properties as an XML element. More... | |
void | setValue (const String &keyName, const var &value) |
Sets a named property. More... | |
void | setValue (const String &keyName, const XmlElement *xml) |
Sets a named property to an XML element. More... | |
void | addAllPropertiesFrom (const PropertySet &source) |
This copies all the values from a source PropertySet to this one. More... | |
void | removeValue (StringRef keyName) |
Deletes a property. More... | |
bool | containsKey (StringRef keyName) const noexcept |
Returns true if the properies include the given key. More... | |
void | clear () |
Removes all values. More... | |
StringPairArray & | getAllProperties () noexcept |
Returns the keys/value pair array containing all the properties. More... | |
const CriticalSection & | getLock () const noexcept |
Returns the lock used when reading or writing to this set. | |
XmlElement * | createXml (const String &nodeName) const |
Returns an XML element which encapsulates all the items in this property set. More... | |
void | restoreFromXml (const XmlElement &xml) |
Reloads a set of properties that were previously stored as XML. More... | |
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. More... | |
PropertySet * | getFallbackPropertySet () const noexcept |
Returns the fallback property set. More... | |
Protected Member Functions | |
virtual void | propertyChanged () |
Subclasses can override this to be told when one of the properies has been changed. More... | |
A set of named property values, which can be strings, integers, floating point, etc.
Effectively, this just wraps a StringPairArray in an interface that makes it easier to load and save types other than strings.
See the PropertiesFile class for a subclass of this, which automatically broadcasts change messages and saves/loads the list from a file.
Definition at line 42 of file juce_PropertySet.h.
juce::PropertySet::PropertySet | ( | bool | ignoreCaseOfKeyNames = false | ) |
Creates an empty PropertySet.
ignoreCaseOfKeyNames | if true, the names of properties are compared in a case-insensitive way |
Definition at line 26 of file juce_PropertySet.cpp.
juce::PropertySet::PropertySet | ( | const PropertySet & | other | ) |
Creates a copy of another PropertySet.
Definition at line 33 of file juce_PropertySet.cpp.
|
virtual |
Destructor.
Definition at line 50 of file juce_PropertySet.cpp.
PropertySet & juce::PropertySet::operator= | ( | const PropertySet & | other | ) |
Copies another PropertySet over this one.
Definition at line 40 of file juce_PropertySet.cpp.
References propertyChanged().
|
noexcept |
Returns one of the properties as a string.
If the value isn't found in this set, then this will look for it in a fallback property set (if you've specified one with the setFallbackPropertySet() method), and if it can't find one there, it'll return the default value passed-in.
keyName | the name of the property to retrieve |
defaultReturnValue | a value to return if the named property doesn't actually exist |
Definition at line 65 of file juce_PropertySet.cpp.
References juce::StringPairArray::getAllKeys(), juce::StringPairArray::getAllValues(), getValue(), and juce::StringArray::indexOf().
Referenced by getValue(), and getXmlValue().
|
noexcept |
Returns one of the properties as an integer.
If the value isn't found in this set, then this will look for it in a fallback property set (if you've specified one with the setFallbackPropertySet() method), and if it can't find one there, it'll return the default value passed-in.
keyName | the name of the property to retrieve |
defaultReturnValue | a value to return if the named property doesn't actually exist |
Definition at line 78 of file juce_PropertySet.cpp.
References juce::StringPairArray::getAllKeys(), juce::StringPairArray::getAllValues(), getIntValue(), and juce::StringArray::indexOf().
Referenced by getIntValue().
|
noexcept |
Returns one of the properties as an double.
If the value isn't found in this set, then this will look for it in a fallback property set (if you've specified one with the setFallbackPropertySet() method), and if it can't find one there, it'll return the default value passed-in.
keyName | the name of the property to retrieve |
defaultReturnValue | a value to return if the named property doesn't actually exist |
Definition at line 90 of file juce_PropertySet.cpp.
References juce::StringPairArray::getAllKeys(), juce::StringPairArray::getAllValues(), getDoubleValue(), and juce::StringArray::indexOf().
Referenced by getDoubleValue().
|
noexcept |
Returns one of the properties as an boolean.
The result will be true if the string found for this key name can be parsed as a non-zero integer.
If the value isn't found in this set, then this will look for it in a fallback property set (if you've specified one with the setFallbackPropertySet() method), and if it can't find one there, it'll return the default value passed-in.
keyName | the name of the property to retrieve |
defaultReturnValue | a value to return if the named property doesn't actually exist |
Definition at line 102 of file juce_PropertySet.cpp.
References juce::StringPairArray::getAllKeys(), juce::StringPairArray::getAllValues(), getBoolValue(), and juce::StringArray::indexOf().
Referenced by getBoolValue().
XmlElement * juce::PropertySet::getXmlValue | ( | StringRef | keyName | ) | const |
Returns one of the properties as an XML element.
The result will a new XMLElement object that the caller must delete. If may return nullptr if the key isn't found, or if the entry contains an string that isn't valid XML.
If the value isn't found in this set, then this will look for it in a fallback property set (if you've specified one with the setFallbackPropertySet() method), and if it can't find one there, it'll return the default value passed-in.
keyName | the name of the property to retrieve |
Definition at line 114 of file juce_PropertySet.cpp.
References getValue(), and juce::XmlDocument::parse().
Sets a named property.
keyName | the name of the property to set. (This mustn't be an empty string) |
value | the new value to set it to |
Definition at line 119 of file juce_PropertySet.cpp.
References juce::StringPairArray::getAllKeys(), juce::StringPairArray::getAllValues(), juce::StringArray::indexOf(), juce::String::isNotEmpty(), propertyChanged(), and juce::StringPairArray::set().
Referenced by addAllPropertiesFrom(), and setValue().
void juce::PropertySet::setValue | ( | const String & | keyName, |
const XmlElement * | xml | ||
) |
Sets a named property to an XML element.
keyName | the name of the property to set. (This mustn't be an empty string) |
xml | the new element to set it to. If this is a nullptr, the value will be set to an empty string |
Definition at line 153 of file juce_PropertySet.cpp.
References juce::XmlElement::createDocument(), and setValue().
void juce::PropertySet::addAllPropertiesFrom | ( | const PropertySet & | source | ) |
This copies all the values from a source PropertySet to this one.
This won't remove any existing settings, it just adds any that it finds in the source set.
Definition at line 165 of file juce_PropertySet.cpp.
References juce::StringPairArray::getAllKeys(), juce::StringPairArray::getAllValues(), getLock(), setValue(), and juce::StringPairArray::size().
void juce::PropertySet::removeValue | ( | StringRef | keyName | ) |
Deletes a property.
keyName | the name of the property to delete. (This mustn't be an empty string) |
Definition at line 138 of file juce_PropertySet.cpp.
References juce::StringPairArray::getAllKeys(), juce::StringArray::indexOf(), juce::StringRef::isNotEmpty(), propertyChanged(), and juce::StringPairArray::remove().
|
noexcept |
Returns true if the properies include the given key.
Definition at line 159 of file juce_PropertySet.cpp.
References juce::StringArray::contains(), and juce::StringPairArray::getAllKeys().
void juce::PropertySet::clear | ( | ) |
Removes all values.
Definition at line 54 of file juce_PropertySet.cpp.
References juce::StringPairArray::clear(), propertyChanged(), and juce::StringPairArray::size().
Referenced by restoreFromXml().
|
inlinenoexcept |
Returns the keys/value pair array containing all the properties.
Definition at line 158 of file juce_PropertySet.h.
Referenced by juce::PropertiesFile::save().
XmlElement * juce::PropertySet::createXml | ( | const String & | nodeName | ) | const |
Returns an XML element which encapsulates all the items in this property set.
The string parameter is the tag name that should be used for the node.
Definition at line 180 of file juce_PropertySet.cpp.
References juce::XmlElement::createNewChildElement(), juce::StringPairArray::getAllKeys(), juce::StringPairArray::getAllValues(), juce::XmlElement::setAttribute(), and juce::StringArray::size().
void juce::PropertySet::restoreFromXml | ( | const XmlElement & | xml | ) |
Reloads a set of properties that were previously stored as XML.
The node passed in must have been created by the createXml() method.
Definition at line 195 of file juce_PropertySet.cpp.
References clear(), propertyChanged(), juce::StringPairArray::set(), and juce::StringPairArray::size().
|
noexcept |
Sets up a second PopertySet that will be used to look up any values that aren't set in this one.
If you set this up to be a pointer to a second property set, then whenever one of the getValue() methods fails to find an entry in this set, it will look up that value in the fallback set, and if it finds it, it will return that.
Make sure that you don't delete the fallback set while it's still being used by another set! To remove the fallback set, just call this method with a null pointer.
Definition at line 174 of file juce_PropertySet.cpp.
|
inlinenoexcept |
Returns the fallback property set.
Definition at line 194 of file juce_PropertySet.h.
|
protectedvirtual |
Subclasses can override this to be told when one of the properies has been changed.
Reimplemented in juce::PropertiesFile.
Definition at line 214 of file juce_PropertySet.cpp.
Referenced by clear(), operator=(), removeValue(), restoreFromXml(), and setValue().