JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::NamedValueSet Class Reference

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

#include <juce_NamedValueSet.h>

Collaboration diagram for juce::NamedValueSet:

Classes

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

Public Member Functions

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

Private Attributes

Array< NamedValuevalues
 

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.

{Core}

Constructor & Destructor Documentation

◆ NamedValueSet() [1/4]

juce::NamedValueSet::NamedValueSet ( )
noexcept

Creates an empty set.

◆ NamedValueSet() [2/4]

juce::NamedValueSet::NamedValueSet ( const NamedValueSet )

◆ NamedValueSet() [3/4]

juce::NamedValueSet::NamedValueSet ( NamedValueSet &&  )
noexcept

◆ NamedValueSet() [4/4]

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

Creates a NamedValueSet from a list of names and properties.

◆ ~NamedValueSet()

juce::NamedValueSet::~NamedValueSet ( )
noexcept

Destructor.

Member Function Documentation

◆ begin()

const NamedValueSet::NamedValue* juce::NamedValueSet::begin ( ) const
inlinenoexcept

References begin().

Referenced by begin().

◆ clear()

void juce::NamedValueSet::clear ( )

Removes all values.

◆ contains()

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

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

◆ copyToXmlAttributes()

void juce::NamedValueSet::copyToXmlAttributes ( XmlElement xml) const

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

◆ end()

const NamedValueSet::NamedValue* juce::NamedValueSet::end ( ) const
inlinenoexcept

◆ getName()

Identifier juce::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.

◆ getValueAt()

const var& juce::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.

◆ getVarPointer()

var* juce::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.

◆ getVarPointerAt()

var* juce::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.

◆ getWithDefault()

var juce::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.

◆ indexOf()

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

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

◆ isEmpty()

bool juce::NamedValueSet::isEmpty ( ) const
noexcept

Returns true if the set is empty.

◆ operator!=()

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

bool juce::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[]()

const var& juce::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

◆ remove()

bool juce::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.

◆ set() [1/2]

bool juce::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 juce::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.

◆ setFromXmlAttributes()

void juce::NamedValueSet::setFromXmlAttributes ( const XmlElement xml)

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

◆ size()

int juce::NamedValueSet::size ( ) const
noexcept

Returns the total number of values that the set contains.

Member Data Documentation

◆ values

Array<NamedValue> juce::NamedValueSet::values
private

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