1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-07 04:10:08 +00:00

Added a standard iterator to NamedValueSet

This commit is contained in:
hogliux 2016-09-14 09:26:48 +01:00
parent 2fd331fac7
commit e35aba3444
2 changed files with 39 additions and 35 deletions

View file

@ -26,40 +26,6 @@
==============================================================================
*/
struct NamedValueSet::NamedValue
{
NamedValue() noexcept {}
NamedValue (const Identifier& n, const var& v) : name (n), value (v) {}
NamedValue (const NamedValue& other) : name (other.name), value (other.value) {}
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
NamedValue (NamedValue&& other) noexcept
: name (static_cast<Identifier&&> (other.name)),
value (static_cast<var&&> (other.value))
{
}
NamedValue (Identifier&& n, var&& v) noexcept
: name (static_cast<Identifier&&> (n)),
value (static_cast<var&&> (v))
{
}
NamedValue& operator= (NamedValue&& other) noexcept
{
name = static_cast<Identifier&&> (other.name);
value = static_cast<var&&> (other.value);
return *this;
}
#endif
bool operator== (const NamedValue& other) const noexcept { return name == other.name && value == other.value; }
bool operator!= (const NamedValue& other) const noexcept { return ! operator== (other); }
Identifier name;
var value;
};
//==============================================================================
NamedValueSet::NamedValueSet() noexcept
{

View file

@ -60,6 +60,45 @@ public:
bool operator!= (const NamedValueSet&) const;
//==============================================================================
struct NamedValue
{
NamedValue() noexcept {}
NamedValue (const Identifier& n, const var& v) : name (n), value (v) {}
NamedValue (const NamedValue& other) : name (other.name), value (other.value) {}
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
NamedValue (NamedValue&& other) noexcept
: name (static_cast<Identifier&&> (other.name)),
value (static_cast<var&&> (other.value))
{
}
NamedValue (Identifier&& n, var&& v) noexcept
: name (static_cast<Identifier&&> (n)),
value (static_cast<var&&> (v))
{
}
NamedValue& operator= (NamedValue&& other) noexcept
{
name = static_cast<Identifier&&> (other.name);
value = static_cast<var&&> (other.value);
return *this;
}
#endif
bool operator== (const NamedValue& other) const noexcept { return name == other.name && value == other.value; }
bool operator!= (const NamedValue& other) const noexcept { return ! operator== (other); }
Identifier name;
var value;
};
NamedValueSet::NamedValue* begin() { return values.begin(); }
NamedValueSet::NamedValue* end() { return values.end(); }
//==============================================================================
/** Returns the total number of values that the set contains. */
int size() const noexcept;
@ -140,7 +179,6 @@ public:
private:
//==============================================================================
struct NamedValue;
Array<NamedValue> values;
};