Loading...
Searching...
No Matches
NamedValueSet Class Reference

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

#include <juce_NamedValueSet.h>

Classes

struct  NamedValue
 Structure for a named var object. More...
 

Public Member Functions

 NamedValueSet () noexcept
 Creates an empty set.
 
 NamedValueSet (const NamedValueSet &)
 
 NamedValueSet (NamedValueSet &&) noexcept
 
NamedValueSetoperator= (const NamedValueSet &)
 
NamedValueSetoperator= (NamedValueSet &&) noexcept
 
 NamedValueSet (std::initializer_list< NamedValue >)
 Creates a NamedValueSet from a list of names and properties.
 
 ~NamedValueSet () noexcept
 Destructor.
 
bool operator== (const NamedValueSet &) const noexcept
 Two NamedValueSets are considered equal if they contain all the same key/value pairs, regardless of the order.
 
bool operator!= (const NamedValueSet &) const noexcept
 
const NamedValueSet::NamedValuebegin () const noexcept
 
const NamedValueSet::NamedValueend () const noexcept
 
int size () const noexcept
 Returns the total number of values that the set contains.
 
bool isEmpty () const noexcept
 Returns true if the set is empty.
 
const varoperator[] (const Identifier &name) const noexcept
 Returns the value of a named item.
 
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.
 
bool set (const Identifier &name, const var &newValue)
 Changes or adds a named value.
 
bool set (const Identifier &name, var &&newValue)
 Changes or adds a named value.
 
bool contains (const Identifier &name) const noexcept
 Returns true if the set contains an item with the specified name.
 
bool remove (const Identifier &name)
 Removes a value from the set.
 
Identifier getName (int index) const noexcept
 Returns the name of the value at a given index.
 
vargetVarPointer (const Identifier &name) noexcept
 Returns a pointer to the var that holds a named value, or null if there is no value with this name.
 
const 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.
 
const vargetValueAt (int index) const noexcept
 Returns the value of the item at a given index.
 
vargetVarPointerAt (int index) noexcept
 Returns the value of the item at a given index.
 
const vargetVarPointerAt (int index) const noexcept
 Returns the value of the item at a given index.
 
int indexOf (const Identifier &name) const noexcept
 Returns the index of the given name, or -1 if it's not found.
 
void clear ()
 Removes all values.
 
void setFromXmlAttributes (const XmlElement &xml)
 Sets properties to the values of all of an XML element's attributes.
 
void copyToXmlAttributes (XmlElement &xml) const
 Sets attributes in an XML element corresponding to each of this object's properties.
 

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() [1/4]

NamedValueSet::NamedValueSet ( )
noexcept

Creates an empty set.

◆ NamedValueSet() [2/4]

NamedValueSet::NamedValueSet ( const NamedValueSet & )

◆ NamedValueSet() [3/4]

NamedValueSet::NamedValueSet ( NamedValueSet && )
noexcept

◆ NamedValueSet() [4/4]

NamedValueSet::NamedValueSet ( std::initializer_list< NamedValue > )

Creates a NamedValueSet from a list of names and properties.

◆ ~NamedValueSet()

NamedValueSet::~NamedValueSet ( )
noexcept

Destructor.

Member Function Documentation

◆ operator=() [1/2]

NamedValueSet & NamedValueSet::operator= ( const NamedValueSet & )

◆ operator=() [2/2]

NamedValueSet & NamedValueSet::operator= ( NamedValueSet && )
noexcept

◆ operator==()

bool NamedValueSet::operator== ( const NamedValueSet & ) const
noexcept

Two NamedValueSets are considered equal if they contain all the same key/value pairs, regardless of the order.

◆ operator!=()

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

◆ begin()

const NamedValueSet::NamedValue * NamedValueSet::begin ( ) const
noexcept

◆ end()

const NamedValueSet::NamedValue * NamedValueSet::end ( ) const
noexcept

◆ size()

int NamedValueSet::size ( ) const
noexcept

Returns the total number of values that the set contains.

◆ isEmpty()

bool NamedValueSet::isEmpty ( ) const
noexcept

Returns true if the set is empty.

◆ operator[]()

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.

◆ getWithDefault()

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.

◆ set() [1/2]

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.

◆ set() [2/2]

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.

◆ contains()

bool NamedValueSet::contains ( const Identifier & name) const
noexcept

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

◆ remove()

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.

◆ getName()

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.

◆ getVarPointer() [1/2]

var * NamedValueSet::getVarPointer ( const Identifier & name)
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(). Also note that the pointer returned may become invalid as soon as any subsequent methods are called on the NamedValueSet.

◆ getVarPointer() [2/2]

const 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(). Also note that the pointer returned may become invalid as soon as any subsequent methods are called on the NamedValueSet.

◆ getValueAt()

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.

◆ getVarPointerAt() [1/2]

var * NamedValueSet::getVarPointerAt ( int index)
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 Also note that the pointer returned may become invalid as soon as any subsequent methods are called on the NamedValueSet.

◆ getVarPointerAt() [2/2]

const 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 Also note that the pointer returned may become invalid as soon as any subsequent methods are called on the NamedValueSet.

◆ indexOf()

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

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

◆ clear()

void NamedValueSet::clear ( )

Removes all values.

◆ setFromXmlAttributes()

void NamedValueSet::setFromXmlAttributes ( const XmlElement & xml)

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

◆ copyToXmlAttributes()

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:
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram