JUCE
Public Member Functions | List of all members
NamedValueSet Class Reference

Holds a set of named var objects. More...

Public Member Functions

 NamedValueSet () noexcept
 Creates an empty set. More...
 
 NamedValueSet (const NamedValueSet &)
 Creates a copy of another set. More...
 
NamedValueSetoperator= (const NamedValueSet &)
 Replaces this set with a copy of another set. More...
 
 NamedValueSet (NamedValueSet &&) noexcept
 
NamedValueSetoperator= (NamedValueSet &&) noexcept
 
 ~NamedValueSet () noexcept
 Destructor. More...
 
bool operator== (const NamedValueSet &) const
 
bool operator!= (const NamedValueSet &) const
 
int size () const noexcept
 Returns the total number of values that the set contains. More...
 
bool isEmpty () const noexcept
 Returns true if the set is empty. More...
 
const varoperator[] (const Identifier &name) const noexcept
 Returns the value of a named item. More...
 
var getWithDefault (const Identifier &name, const var &defaultReturnValue) const
 Tries to return the named value, but if no such value is found, this will instead return the supplied default value. More...
 
bool set (const Identifier &name, const var &newValue)
 Changes or adds a named value. More...
 
bool set (const Identifier &name, var &&newValue)
 Changes or adds a named value. More...
 
bool contains (const Identifier &name) const noexcept
 Returns true if the set contains an item with the specified name. More...
 
bool remove (const Identifier &name)
 Removes a value from the set. More...
 
Identifier getName (int index) const noexcept
 Returns the name of the value at a given index. More...
 
vargetVarPointer (const Identifier &name) const noexcept
 Returns a pointer to the var that holds a named value, or null if there is no value with this name. More...
 
const vargetValueAt (int index) const noexcept
 Returns the value of the item at a given index. More...
 
vargetVarPointerAt (int index) const noexcept
 Returns the value of the item at a given index. More...
 
int indexOf (const Identifier &name) const noexcept
 Returns the index of the given name, or -1 if it's not found. More...
 
void clear ()
 Removes all values. More...
 
void setFromXmlAttributes (const XmlElement &xml)
 Sets properties to the values of all of an XML element's attributes. More...
 
void copyToXmlAttributes (XmlElement &xml) const
 Sets attributes in an XML element corresponding to each of this object's properties. More...
 

Detailed Description

Holds a set of named var objects.

This can be used as a basic structure to hold a set of var object, which can be retrieved by using their identifier.

Constructor & Destructor Documentation

NamedValueSet::NamedValueSet ( )
noexcept

Creates an empty set.

NamedValueSet::NamedValueSet ( const NamedValueSet )

Creates a copy of another set.

NamedValueSet::NamedValueSet ( NamedValueSet &&  )
noexcept
NamedValueSet::~NamedValueSet ( )
noexcept

Destructor.

Member Function Documentation

NamedValueSet& NamedValueSet::operator= ( const NamedValueSet )

Replaces this set with a copy of another set.

NamedValueSet& NamedValueSet::operator= ( NamedValueSet &&  )
noexcept
bool NamedValueSet::operator== ( const NamedValueSet ) const
bool NamedValueSet::operator!= ( const NamedValueSet ) const
int NamedValueSet::size ( ) const
noexcept

Returns the total number of values that the set contains.

bool NamedValueSet::isEmpty ( ) const
noexcept

Returns true if the set is empty.

const var& NamedValueSet::operator[] ( const Identifier name) const
noexcept

Returns the value of a named item.

If the name isn't found, this will return a void variant.

See also
getProperty
var NamedValueSet::getWithDefault ( const Identifier name,
const var defaultReturnValue 
) const

Tries to return the named value, but if no such value is found, this will instead return the supplied default value.

bool NamedValueSet::set ( const Identifier name,
const var newValue 
)

Changes or adds a named value.

Returns
true if a value was changed or added; false if the value was already set the value passed-in.
bool NamedValueSet::set ( const Identifier name,
var &&  newValue 
)

Changes or adds a named value.

Returns
true if a value was changed or added; false if the value was already set the value passed-in.
bool NamedValueSet::contains ( const Identifier name) const
noexcept

Returns true if the set contains an item with the specified name.

bool NamedValueSet::remove ( const Identifier name)

Removes a value from the set.

Returns
true if a value was removed; false if there was no value with the name that was given.
Identifier NamedValueSet::getName ( int  index) const
noexcept

Returns the name of the value at a given index.

The index must be between 0 and size() - 1.

var* NamedValueSet::getVarPointer ( const Identifier name) const
noexcept

Returns a pointer to the var that holds a named value, or null if there is no value with this name.

Do not use this method unless you really need access to the internal var object for some reason - for normal reading and writing always prefer operator[]() and set().

const var& NamedValueSet::getValueAt ( int  index) const
noexcept

Returns the value of the item at a given index.

The index must be between 0 and size() - 1.

var* NamedValueSet::getVarPointerAt ( int  index) const
noexcept

Returns the value of the item at a given index.

The index must be between 0 and size() - 1, or this will return a nullptr

int NamedValueSet::indexOf ( const Identifier name) const
noexcept

Returns the index of the given name, or -1 if it's not found.

void NamedValueSet::clear ( )

Removes all values.

void NamedValueSet::setFromXmlAttributes ( const XmlElement xml)

Sets properties to the values of all of an XML element's attributes.

void NamedValueSet::copyToXmlAttributes ( XmlElement xml) const

Sets attributes in an XML element corresponding to each of this object's properties.


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