Loading...
Searching...
No Matches
juce_UMPIterator.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#ifndef DOXYGEN
namespace juce::universal_midi_packets
{
class Iterator
{
public:
Iterator() noexcept = default;
explicit Iterator (const uint32_t* ptr, size_t bytes) noexcept;
using difference_type = std::iterator_traits<const uint32_t*>::difference_type;
using value_type = View;
using reference = const View&;
using pointer = const View*;
using iterator_category = std::forward_iterator_tag;
Iterator& operator++() noexcept
{
const auto increment = view.size();
#if JUCE_DEBUG
// If you hit this, the memory region contained a truncated or otherwise
// malformed Universal MIDI Packet.
// The Iterator can only be used on regions containing complete packets!
jassert (increment <= bytesRemaining);
bytesRemaining -= increment;
#endif
view = View (view.data() + increment);
return *this;
}
Iterator operator++ (int) noexcept
{
auto copy = *this;
++(*this);
return copy;
}
bool operator== (const Iterator& other) const noexcept
{
return view == other.view;
}
bool operator!= (const Iterator& other) const noexcept
{
return ! operator== (other);
}
reference operator*() noexcept { return view; }
pointer operator->() noexcept { return &view; }
private:
View view;
#if JUCE_DEBUG
size_t bytesRemaining = 0;
#endif
};
} // namespace juce::universal_midi_packets
#endif
juce::universal_midi_packets::Iterator::Iterator
Iterator() noexcept=default
juce::universal_midi_packets::Iterator::operator->
pointer operator->() noexcept
Definition juce_UMPIterator.h:108
juce::universal_midi_packets::Iterator::operator++
Iterator & operator++() noexcept
Definition juce_UMPIterator.h:53
juce::universal_midi_packets::Iterator::operator*
reference operator*() noexcept
Definition juce_UMPIterator.h:101
juce::universal_midi_packets::Iterator::operator==
bool operator==(const Iterator &other) const noexcept
Definition juce_UMPIterator.h:83
juce::universal_midi_packets::Iterator::operator!=
bool operator!=(const Iterator &other) const noexcept
Definition juce_UMPIterator.h:91
juce::universal_midi_packets::View
Definition juce_UMPView.h:44