26NamedValueSet::NamedValue::NamedValue() noexcept {}
27NamedValueSet::NamedValue::~NamedValue() noexcept {}
29NamedValueSet::NamedValue::NamedValue (
const Identifier& n,
const var& v) : name (n), value (v) {}
30NamedValueSet::NamedValue::NamedValue (
const NamedValue& other) : NamedValue (other.name, other.value) {}
32NamedValueSet::NamedValue::NamedValue (NamedValue&& other) noexcept
33 : NamedValue (std::move (other.name),
34 std::move (other.value))
37NamedValueSet::NamedValue::NamedValue (
const Identifier& n, var&& v) noexcept
38 : name (n), value (std::move (v))
42NamedValueSet::NamedValue::NamedValue (Identifier&& n, var&& v) noexcept
43 : name (std::move (n)),
47NamedValueSet::NamedValue& NamedValueSet::NamedValue::operator= (NamedValue&& other)
noexcept
49 name = std::move (other.name);
50 value = std::move (other.value);
54bool NamedValueSet::NamedValue::operator== (
const NamedValue& other)
const noexcept {
return name == other.name && value == other.value; }
55bool NamedValueSet::NamedValue::operator!= (
const NamedValue& other)
const noexcept {
return ! operator== (other); }
64 : values (std::move (other.values)) {}
67 : values (std::move (list))
74 values =
other.values;
78NamedValueSet& NamedValueSet::operator= (NamedValueSet&& other)
noexcept
96 for (
int i = 0; i <
num; ++i)
107 for (
int j = i;
j <
num; ++
j)
109 if (
auto*
otherVal =
other.getVarPointer (values.getReference(
j).name))
110 if (values.getReference(
j).value == *
otherVal)
136 if (
auto*
v = getVarPointer (name))
139 return getNullVarRef();
152 for (
auto& i : values)
163 if (
v->equalsWithSameType (newValue))
166 *
v = std::move (newValue);
170 values.
add ({ name, std::move (newValue) });
178 if (
v->equalsWithSameType (newValue))
185 values.
add ({ name, newValue });
191 return getVarPointer (name) !=
nullptr;
199 if (values.getReference(i).name == name)
223 if (isPositiveAndBelow (index, values.size()))
224 return values.getReference (index).name;
232 if (isPositiveAndBelow (index, values.size()))
236 return getNullVarRef();
241 if (isPositiveAndBelow (index, values.size()))
242 return &(values.getReference (index).value);
251 for (
auto*
att =
xml.attributes.get();
att !=
nullptr;
att =
att->nextListItem)
253 if (
att->name.toString().startsWith (
"base64:"))
257 if (
mb.fromBase64Encoding (
att->value))
259 values.
add ({
att->name.toString().substring (7),
var (
mb) });
270 for (
auto& i : values)
272 if (
auto*
mb = i.value.getBinaryData())
274 xml.setAttribute (
"base64:" + i.name.toString(),
mb->toBase64Encoding());
279 jassert (! i.value.isObject());
280 jassert (! i.value.isMethod());
281 jassert (! i.value.isArray());
283 xml.setAttribute (i.name.toString(),
Holds a resizable array of primitive or copy-by-value objects.
void swapWith(OtherArrayType &otherArray) noexcept
This swaps the contents of this array with those of another array.
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
void clearQuick()
Removes all elements from the array without freeing the array's allocated storage.
int size() const noexcept
Returns the current number of elements in the array.
void remove(int indexToRemove)
Removes an element from the array.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
ElementType & getReference(int index) const noexcept
Returns a direct reference to one of the elements in the array, without checking the index passed in.
void clear()
Removes all elements from the array.
Represents a string identifier, designed for accessing properties by name.
A class to hold a resizable block of raw data.
Holds a set of named var objects.
bool set(const Identifier &name, const 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.
int indexOf(const Identifier &name) const noexcept
Returns the index of the given name, or -1 if it's not found.
const var & getValueAt(int index) const noexcept
Returns the value of the item at a given index.
var * getVarPointerAt(int index) const noexcept
Returns the value of the item at a given index.
void clear()
Removes all values.
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.
bool isEmpty() const noexcept
Returns true if the set is empty.
bool operator==(const NamedValueSet &) const noexcept
Two NamedValueSets are considered equal if they contain all the same key/value pairs,...
NamedValueSet() noexcept
Creates an empty set.
Identifier getName(int index) const noexcept
Returns the name of the value at a given index.
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...
int size() const noexcept
Returns the total number of values that the set contains.
const var & operator[](const Identifier &name) const noexcept
Returns the value of a named item.
void copyToXmlAttributes(XmlElement &xml) const
Sets attributes in an XML element corresponding to each of this object's properties.
void setFromXmlAttributes(const XmlElement &xml)
Sets properties to the values of all of an XML element's attributes.
Used to build a tree of elements representing an XML document.
A variant class, that can be used to hold a range of primitive values.