Browse Source

Added a standard iterator to NamedValueSet

tags/2021-05-28
hogliux 9 years ago
parent
commit
e35aba3444
2 changed files with 39 additions and 35 deletions
  1. +0
    -34
      modules/juce_core/containers/juce_NamedValueSet.cpp
  2. +39
    -1
      modules/juce_core/containers/juce_NamedValueSet.h

+ 0
- 34
modules/juce_core/containers/juce_NamedValueSet.cpp 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
{


+ 39
- 1
modules/juce_core/containers/juce_NamedValueSet.h 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;
};


Loading…
Cancel
Save