Skip to content

Commit

Permalink
Remove tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
FigBug committed Nov 18, 2024
1 parent 01ba3ca commit 6e20e3f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 66 deletions.
82 changes: 41 additions & 41 deletions modules/juce_core/containers/juce_Variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,71 +910,71 @@ var::NativeFunctionArgs::NativeFunctionArgs (const var& t, const var* args, int

//==============================================================================
VarIterator::VarIterator (const var& v_, bool isEnd)
: v (v_)
{
if (isEnd)
{
if (v.isArray())
index = v.getArray()->size();
else if (auto o = v.getDynamicObject())
itr = o->getProperties().end();
}
else
{
if (v.isArray())
index = 0;
else if (auto o = v.getDynamicObject())
itr = o->getProperties().begin();
}
: v (v_)
{
if (isEnd)
{
if (v.isArray())
index = v.getArray()->size();
else if (auto o = v.getDynamicObject())
itr = o->getProperties().end();
}
else
{
if (v.isArray())
index = 0;
else if (auto o = v.getDynamicObject())
itr = o->getProperties().begin();
}
}

VarIterator& VarIterator::operator++()
{
if (v.isArray())
{
index++;
}
else if (v.getDynamicObject())
{
auto i = (const NamedValueSet::NamedValue*)itr;
i++;
itr = i;
}
return *this;
if (v.isArray())
{
index++;
}
else if (v.getDynamicObject())
{
auto i = (const NamedValueSet::NamedValue*)itr;
i++;
itr = i;
}
return *this;
}

bool VarIterator::operator== (const VarIterator& other) const
{
return index == other.index && itr == other.itr;
return index == other.index && itr == other.itr;
}

bool VarIterator::operator!= (const VarIterator& other) const
{
return ! (*this == other);
return ! (*this == other);
}

VarIterator::NamedValue VarIterator::operator*() const
{
if (v.isArray())
{
return { index, (*v.getArray())[index] };
}
else if (v.getDynamicObject())
{
auto i = (const NamedValueSet::NamedValue*)itr;
return { i->name.toString(), i->value };
}
return {};
if (v.isArray())
{
return { index, (*v.getArray())[index] };
}
else if (v.getDynamicObject())
{
auto i = (const NamedValueSet::NamedValue*)itr;
return { i->name.toString(), i->value };
}
return {};
}

VarIterator begin (const var& v)
{
return VarIterator (v, false);
return VarIterator (v, false);
}

VarIterator end (const var& v)
{
return VarIterator (v, true);
return VarIterator (v, true);
}

//==============================================================================
Expand Down
40 changes: 20 additions & 20 deletions modules/juce_core/containers/juce_Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,34 +358,34 @@ JUCE_API bool operator!= (const var&, const char*);

//==============================================================================
/** Iterator for a var.
You shouldn't ever need to use this class directly - it's used internally by begin()
and end() to allow range-based-for loops on a var.
You shouldn't ever need to use this class directly - it's used internally by begin()
and end() to allow range-based-for loops on a var.
*/
struct VarIterator
{
struct NamedValue
{
var name;
var value;
};
struct NamedValue
{
var name;
var value;
};

VarIterator (const var&, bool isEnd);
VarIterator& operator++();
VarIterator (const var&, bool isEnd);
VarIterator& operator++();

bool operator== (const VarIterator&) const;
bool operator!= (const VarIterator&) const;
NamedValue operator*() const;
bool operator== (const VarIterator&) const;
bool operator!= (const VarIterator&) const;
NamedValue operator*() const;

using difference_type = std::ptrdiff_t;
using value_type = NamedValue;
using reference = NamedValue&;
using pointer = NamedValue*;
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = NamedValue;
using reference = NamedValue&;
using pointer = NamedValue*;
using iterator_category = std::forward_iterator_tag;

private:
const var& v;
int index = 0;
const void* itr = nullptr;
const var& v;
int index = 0;
const void* itr = nullptr;
};

VarIterator begin (const var&);
Expand Down
10 changes: 5 additions & 5 deletions modules/juce_core/json/juce_JSONUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ class JSONUtilsTests final : public UnitTest
, "pitchEnvelope": { "rates": [94,67,95,60], "levels": [50,50,50,50] }
})");

expect (JSONUtils::getPointer (obj, "/name", {}) == "PIANO 4");
expect (JSONUtils::getPointer (obj, "/lfoSpeed", {}) == var (30));
expect (JSONUtils::getPointer (obj, "/pitchEnvelope/rates/1", {}) == var (67));
expect (JSONUtils::getPointer (obj, "/pitchEnvelope/levels/2", {}) == var (50));
expect (JSONUtils::getPointer (obj, "/pitchEnvelope/levels/10", {}) == var());
expect (JSONUtils::getPointer (obj, "/name", {}) == "PIANO 4");
expect (JSONUtils::getPointer (obj, "/lfoSpeed", {}) == var (30));
expect (JSONUtils::getPointer (obj, "/pitchEnvelope/rates/1", {}) == var (67));
expect (JSONUtils::getPointer (obj, "/pitchEnvelope/levels/2", {}) == var (50));
expect (JSONUtils::getPointer (obj, "/pitchEnvelope/levels/10", {}) == var());

expectDeepEqual (JSONUtils::setPointer (obj, "", "hello world"), var ("hello world"));
expectDeepEqual (JSONUtils::setPointer (obj, "/lfoWaveform/foobar", "str"), std::nullopt);
Expand Down

0 comments on commit 6e20e3f

Please sign in to comment.