OpenShot Library | libopenshot-audio  0.2.0
juce::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. More...
 
 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. More...
 
 ~NamedValueSet () noexcept
 Destructor. More...
 
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. 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.
 
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.
 

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.

Definition at line 38 of file juce_NamedValueSet.h.

Constructor & Destructor Documentation

◆ NamedValueSet() [1/2]

juce::NamedValueSet::NamedValueSet ( )
noexcept

Creates an empty set.

Definition at line 58 of file juce_NamedValueSet.cpp.

Referenced by ~NamedValueSet().

◆ NamedValueSet() [2/2]

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

Creates a NamedValueSet from a list of names and properties.

Definition at line 66 of file juce_NamedValueSet.cpp.

References clear().

◆ ~NamedValueSet()

juce::NamedValueSet::~NamedValueSet ( )
noexcept

Destructor.

Definition at line 59 of file juce_NamedValueSet.cpp.

References NamedValueSet().

Member Function Documentation

◆ size()

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

Returns the total number of values that the set contains.

Definition at line 125 of file juce_NamedValueSet.cpp.

◆ isEmpty()

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

Returns true if the set is empty.

Definition at line 126 of file juce_NamedValueSet.cpp.

◆ 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

Definition at line 134 of file juce_NamedValueSet.cpp.

References getVarPointer().

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

Definition at line 174 of file juce_NamedValueSet.cpp.

References getVarPointer().

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

Definition at line 159 of file juce_NamedValueSet.cpp.

References getVarPointer().

◆ contains()

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

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

Definition at line 189 of file juce_NamedValueSet.cpp.

References getVarPointer().

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

Definition at line 205 of file juce_NamedValueSet.cpp.

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

Definition at line 221 of file juce_NamedValueSet.cpp.

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

Definition at line 150 of file juce_NamedValueSet.cpp.

Referenced by contains(), getWithDefault(), operator==(), operator[](), and set().

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

Definition at line 230 of file juce_NamedValueSet.cpp.

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

Definition at line 239 of file juce_NamedValueSet.cpp.

◆ indexOf()

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

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

Definition at line 194 of file juce_NamedValueSet.cpp.

◆ clear()

void juce::NamedValueSet::clear ( )

Removes all values.

Definition at line 84 of file juce_NamedValueSet.cpp.

Referenced by NamedValueSet().

◆ setFromXmlAttributes()

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

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

Definition at line 247 of file juce_NamedValueSet.cpp.

References juce::MemoryBlock::fromBase64Encoding(), and juce::LinkedListPointer< ObjectType >::get().


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