From 599998bd1ff347ebafdda800b3be511ce6fe7f0e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 5 Jul 2023 09:45:29 -0600 Subject: [PATCH] midisurface: add a vector constructor for MidByteArry plus a few minor code tweaks --- .../midi_surface/midi_byte_array.cc | 16 +++++++++------- .../midi_surface/midi_surface/midi_byte_array.h | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libs/ctrl-interface/midi_surface/midi_byte_array.cc b/libs/ctrl-interface/midi_surface/midi_byte_array.cc index 2ba2265ffe..5798e899e0 100644 --- a/libs/ctrl-interface/midi_surface/midi_byte_array.cc +++ b/libs/ctrl-interface/midi_surface/midi_byte_array.cc @@ -26,11 +26,15 @@ #include #include -MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[]) - : std::vector() +MidiByteArray::MidiByteArray (std::vector const & v) { - for (size_t i = 0; i < size; ++i) - { + insert (end(), v.begin(), v.end()); +} + +MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[]) + : std::vector() +{ + for (size_t i = 0; i < size; ++i) { push_back (array[i]); } } @@ -41,8 +45,7 @@ MidiByteArray::MidiByteArray (size_t count, MIDI::byte first, ...) push_back (first); va_list var_args; va_start (var_args, first); - for (size_t i = 1; i < count; ++i) - { + for (size_t i = 1; i < count; ++i) { MIDI::byte b = va_arg (var_args, int); push_back (b); } @@ -110,4 +113,3 @@ MidiByteArray::compare_n (const MidiByteArray& other, MidiByteArray::size_type n return true; } - diff --git a/libs/ctrl-interface/midi_surface/midi_surface/midi_byte_array.h b/libs/ctrl-interface/midi_surface/midi_surface/midi_byte_array.h index e336399849..7aaa3bb6e1 100644 --- a/libs/ctrl-interface/midi_surface/midi_surface/midi_byte_array.h +++ b/libs/ctrl-interface/midi_surface/midi_surface/midi_byte_array.h @@ -48,9 +48,11 @@ namespace MIDI { class MidiByteArray : public std::vector { public: - MidiByteArray() : std::vector() {} + MidiByteArray () : std::vector() {}; - MidiByteArray( size_t count, MIDI::byte array[] ); + MidiByteArray (std::vector const & vec); + + MidiByteArray (size_t count, MIDI::byte array[]); bool compare_n (const MidiByteArray& other, MidiByteArray::size_type len) const;