OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce::PropertySet Class Reference

#include <juce_PropertySet.h>

Inheritance diagram for juce::PropertySet:
juce::PropertiesFile

Public Member Functions

 PropertySet (bool ignoreCaseOfKeyNames=false)
 
 PropertySet (const PropertySet &other)
 
PropertySetoperator= (const PropertySet &other)
 
virtual ~PropertySet ()
 
String getValue (StringRef keyName, const String &defaultReturnValue=String()) const noexcept
 
int getIntValue (StringRef keyName, int defaultReturnValue=0) const noexcept
 
double getDoubleValue (StringRef keyName, double defaultReturnValue=0.0) const noexcept
 
bool getBoolValue (StringRef keyName, bool defaultReturnValue=false) const noexcept
 
std::unique_ptr< XmlElementgetXmlValue (StringRef keyName) const
 
void setValue (const String &keyName, const var &value)
 
void setValue (const String &keyName, const XmlElement *xml)
 
void addAllPropertiesFrom (const PropertySet &source)
 
void removeValue (StringRef keyName)
 
bool containsKey (StringRef keyName) const noexcept
 
void clear ()
 
StringPairArraygetAllProperties () noexcept
 
const CriticalSectiongetLock () const noexcept
 
std::unique_ptr< XmlElementcreateXml (const String &nodeName) const
 
void restoreFromXml (const XmlElement &xml)
 
void setFallbackPropertySet (PropertySet *fallbackProperties) noexcept
 
PropertySetgetFallbackPropertySet () const noexcept
 

Protected Member Functions

virtual void propertyChanged ()
 

Detailed Description

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 38 of file juce_PropertySet.h.

Constructor & Destructor Documentation

◆ PropertySet() [1/2]

juce::PropertySet::PropertySet ( bool  ignoreCaseOfKeyNames = false)

Creates an empty PropertySet.

Parameters
ignoreCaseOfKeyNamesif true, the names of properties are compared in a case-insensitive way

Definition at line 26 of file juce_PropertySet.cpp.

◆ PropertySet() [2/2]

juce::PropertySet::PropertySet ( const PropertySet other)

Creates a copy of another PropertySet.

Definition at line 33 of file juce_PropertySet.cpp.

◆ ~PropertySet()

juce::PropertySet::~PropertySet ( )
virtual

Destructor.

Definition at line 50 of file juce_PropertySet.cpp.

Member Function Documentation

◆ addAllPropertiesFrom()

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 163 of file juce_PropertySet.cpp.

◆ clear()

void juce::PropertySet::clear ( )

Removes all values.

Definition at line 54 of file juce_PropertySet.cpp.

Referenced by restoreFromXml().

◆ containsKey()

bool juce::PropertySet::containsKey ( StringRef  keyName) const
noexcept

Returns true if the properties include the given key.

Definition at line 157 of file juce_PropertySet.cpp.

◆ createXml()

std::unique_ptr< 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.

See also
restoreFromXml

Definition at line 178 of file juce_PropertySet.cpp.

◆ getAllProperties()

StringPairArray & juce::PropertySet::getAllProperties ( )
inlinenoexcept

Returns the keys/value pair array containing all the properties.

Definition at line 154 of file juce_PropertySet.h.

◆ getBoolValue()

bool juce::PropertySet::getBoolValue ( StringRef  keyName,
bool  defaultReturnValue = false 
) const
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.

Parameters
keyNamethe name of the property to retrieve
defaultReturnValuea value to return if the named property doesn't actually exist

Definition at line 101 of file juce_PropertySet.cpp.

◆ getDoubleValue()

double juce::PropertySet::getDoubleValue ( StringRef  keyName,
double  defaultReturnValue = 0.0 
) const
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.

Parameters
keyNamethe name of the property to retrieve
defaultReturnValuea value to return if the named property doesn't actually exist

Definition at line 89 of file juce_PropertySet.cpp.

◆ getFallbackPropertySet()

PropertySet * juce::PropertySet::getFallbackPropertySet ( ) const
inlinenoexcept

Returns the fallback property set.

See also
setFallbackPropertySet

Definition at line 190 of file juce_PropertySet.h.

◆ getIntValue()

int juce::PropertySet::getIntValue ( StringRef  keyName,
int  defaultReturnValue = 0 
) const
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.

Parameters
keyNamethe name of the property to retrieve
defaultReturnValuea value to return if the named property doesn't actually exist

Definition at line 77 of file juce_PropertySet.cpp.

◆ getLock()

const CriticalSection & juce::PropertySet::getLock ( ) const
inlinenoexcept

◆ getValue()

String juce::PropertySet::getValue ( StringRef  keyName,
const String defaultReturnValue = String() 
) const
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.

Parameters
keyNamethe name of the property to retrieve
defaultReturnValuea value to return if the named property doesn't actually exist

Definition at line 65 of file juce_PropertySet.cpp.

Referenced by getXmlValue().

◆ getXmlValue()

std::unique_ptr< 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.

Parameters
keyNamethe name of the property to retrieve

Definition at line 113 of file juce_PropertySet.cpp.

◆ operator=()

PropertySet & juce::PropertySet::operator= ( const PropertySet other)

Copies another PropertySet over this one.

Definition at line 40 of file juce_PropertySet.cpp.

◆ propertyChanged()

void juce::PropertySet::propertyChanged ( )
protectedvirtual

Subclasses can override this to be told when one of the properties has been changed.

Reimplemented in juce::PropertiesFile.

Definition at line 213 of file juce_PropertySet.cpp.

Referenced by clear(), operator=(), removeValue(), restoreFromXml(), and setValue().

◆ removeValue()

void juce::PropertySet::removeValue ( StringRef  keyName)

Deletes a property.

Parameters
keyNamethe name of the property to delete. (This mustn't be an empty string)

Definition at line 136 of file juce_PropertySet.cpp.

◆ restoreFromXml()

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.

See also
createXml

Definition at line 194 of file juce_PropertySet.cpp.

◆ setFallbackPropertySet()

void juce::PropertySet::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.

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.

See also
getFallbackPropertySet

Definition at line 172 of file juce_PropertySet.cpp.

◆ setValue() [1/2]

void juce::PropertySet::setValue ( const String keyName,
const var value 
)

Sets a named property.

Parameters
keyNamethe name of the property to set. (This mustn't be an empty string)
valuethe new value to set it to

Definition at line 118 of file juce_PropertySet.cpp.

Referenced by addAllPropertiesFrom(), and setValue().

◆ setValue() [2/2]

void juce::PropertySet::setValue ( const String keyName,
const XmlElement xml 
)

Sets a named property to an XML element.

Parameters
keyNamethe name of the property to set. (This mustn't be an empty string)
xmlthe new element to set it to. If this is a nullptr, the value will be set to an empty string
See also
getXmlValue

Definition at line 151 of file juce_PropertySet.cpp.


The documentation for this class was generated from the following files: