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

## 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.

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

- juce_core/containers/juce_NamedValueSet.h

## Public Types

using | NamedValue = juce::NamedValue

## Public Member Functions

| NamedValueSet () noexcept=default
| Creates an empty set.
| NamedValueSet (std::initializer_list< NamedValue >)
| Creates a NamedValueSet from a list of names and properties.
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 NamedValue * | begin () const noexcept
const NamedValue * | end () const noexcept
Span< NamedValue > | asSpan () &
Span< const NamedValue > | asSpan () const &
Span< NamedValue > | asSpan () &&=delete
Span< const NamedValue > | asSpan () const &&=delete
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 var & | operator[] (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.
var * | 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.
const var * | 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.
const var & | getValueAt (int index) const noexcept
| Returns the value of the item at a given index.
var * | getVarPointerAt (int index) noexcept
| Returns the value of the item at a given index.
const var * | getVarPointerAt (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.

## Member Typedef Documentation

## NamedValue

using juce::NamedValueSet::NamedValue = juce::NamedValue

## Constructors and Destructors

## NamedValueSet() [1/2]

juce::NamedValueSet::NamedValueSet | ( |  | ) |

default noexcept

Creates an empty set.

Referenced by NamedValueSet(), operator!=(), and operator==().

## NamedValueSet() [2/2]

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

Creates a NamedValueSet from a list of names and properties.

References NamedValueSet().

## Member Functions

## 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.

References NamedValueSet().

## operator!=()

bool juce::NamedValueSet::operator!= | ( | const NamedValueSet & |  | ) | const

noexcept

References NamedValueSet().

## begin()

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

inline noexcept

References begin().

Referenced by begin().

## end()

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

inline noexcept

## asSpan() [1/4]

Span< NamedValue > juce::NamedValueSet::asSpan | ( |  | ) | &

inline

## asSpan() [2/4]

Span< const NamedValue > juce::NamedValueSet::asSpan | ( |  | ) | const &

inline

## asSpan() [3/4]

Span< NamedValue > juce::NamedValueSet::asSpan | ( |  | ) | &&

delete

## asSpan() [4/4]

Span< const NamedValue > juce::NamedValueSet::asSpan | ( |  | ) | const &&

delete

## size()

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

noexcept

Returns the total number of values that the set contains.

References size().

Referenced by size().

## isEmpty()

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

noexcept

Returns true if the set is empty.

References isEmpty().

Referenced by isEmpty().

## 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.

References name.

## 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.

References getWithDefault(), and name.

Referenced by getWithDefault().

## 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.

References name, and set().

Referenced by set(), and set().

## 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.

References name, and set().

## contains()

bool juce::NamedValueSet::contains | ( | const Identifier & | name | ) | const

noexcept

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

References contains(), and name.

Referenced by contains().

## 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.

References name, and remove().

Referenced by remove().

## 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.

References getName().

Referenced by getName().

## getVarPointer() [1/2]

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

References getVarPointer(), and name.

Referenced by getVarPointer(), and getVarPointer().

## getVarPointer() [2/2]

const 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.

References getVarPointer(), and name.

## 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.

References getValueAt().

Referenced by getValueAt().

## getVarPointerAt() [1/2]

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

References getVarPointerAt().

Referenced by getVarPointerAt(), and getVarPointerAt().

## getVarPointerAt() [2/2]

const 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.

References getVarPointerAt().

## indexOf()

int juce::NamedValueSet::indexOf | ( | const Identifier & | name | ) | const

noexcept

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

References indexOf(), and name.

Referenced by indexOf().

## clear()

void juce::NamedValueSet::clear | ( |  | ) |

Removes all values.

References clear().

Referenced by clear().

## setFromXmlAttributes()

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

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

References setFromXmlAttributes().

Referenced by setFromXmlAttributes().

## copyToXmlAttributes()

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

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

References copyToXmlAttributes().

Referenced by copyToXmlAttributes().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited