2 Copyright (C) 2006,2007 John Anderson
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #include "midi_byte_array.h"
31 MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[])
32 : std::vector<MIDI::byte>()
34 for (size_t i = 0; i < size; ++i)
40 MidiByteArray::MidiByteArray (size_t count, MIDI::byte first, ...)
41 : vector<MIDI::byte>()
45 va_start (var_args, first);
46 for (size_t i = 1; i < count; ++i)
48 MIDI::byte b = va_arg (var_args, int);
55 void MidiByteArray::copy (size_t count, MIDI::byte * arr)
57 for (size_t i = 0; i < count; ++i) {
62 MidiByteArray & operator << (MidiByteArray & mba, const MIDI::byte & b)
68 MidiByteArray & operator << (MidiByteArray & mba, const MidiByteArray & barr)
70 back_insert_iterator<MidiByteArray> bit (mba);
71 copy (barr.begin(), barr.end(), bit);
75 ostream & operator << (ostream & os, const MidiByteArray & mba)
78 char fill = os.fill('0');
79 for (MidiByteArray::const_iterator it = mba.begin(); it != mba.end(); ++it) {
80 if (it != mba.begin()) os << " ";
81 os << hex << setw(2) << (int)*it;
89 MidiByteArray & operator << (MidiByteArray & mba, const std::string & st)
91 /* note that this assumes that "st" is ASCII encoded
94 mba.insert (mba.end(), st.begin(), st.end());