Holds a set of named var objects. More...
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 | |
NamedValueSet & | operator= (const NamedValueSet &) |
NamedValueSet & | operator= (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::NamedValue * | begin () const noexcept |
const NamedValueSet::NamedValue * | end () 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 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. | |
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.
|
noexcept |
Creates an empty set.
References NamedValueSet().
Referenced by begin(), NamedValueSet(), NamedValueSet(), NamedValueSet(), NamedValueSet(), operator!=(), operator=(), operator=(), operator==(), and ~NamedValueSet().
NamedValueSet::NamedValueSet | ( | const NamedValueSet & | ) |
References NamedValueSet().
|
noexcept |
References NamedValueSet().
NamedValueSet::NamedValueSet | ( | std::initializer_list< NamedValue > | ) |
Creates a NamedValueSet from a list of names and properties.
References NamedValueSet().
|
noexcept |
Destructor.
References NamedValueSet().
NamedValueSet & NamedValueSet::operator= | ( | const NamedValueSet & | ) |
References NamedValueSet().
|
noexcept |
References NamedValueSet().
|
noexcept |
Two NamedValueSets are considered equal if they contain all the same key/value pairs, regardless of the order.
References NamedValueSet().
|
noexcept |
References NamedValueSet().
|
noexcept |
References begin(), and NamedValueSet().
Referenced by begin().
|
noexcept |
|
noexcept |
Returns the total number of values that the set contains.
|
noexcept |
|
noexcept |
Returns the value of a named item.
If the name isn't found, this will return a void variant.
References name.
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.
References getWithDefault(), and name.
Referenced by getWithDefault().
bool NamedValueSet::set | ( | const Identifier & | name, |
const var & | newValue ) |
bool NamedValueSet::set | ( | const Identifier & | name, |
var && | newValue ) |
|
noexcept |
Returns true if the set contains an item with the specified name.
References contains(), and name.
Referenced by contains().
bool NamedValueSet::remove | ( | const Identifier & | name | ) |
|
noexcept |
|
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().
|
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.
|
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().
|
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().
|
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().
|
noexcept |
void NamedValueSet::setFromXmlAttributes | ( | const XmlElement & | xml | ) |
Sets properties to the values of all of an XML element's attributes.
References setFromXmlAttributes().
Referenced by setFromXmlAttributes().
void NamedValueSet::copyToXmlAttributes | ( | XmlElement & | xml | ) | const |
Sets attributes in an XML element corresponding to each of this object's properties.
References copyToXmlAttributes().
Referenced by copyToXmlAttributes().