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 #ifndef midi_byte_array_h
19 #define midi_byte_array_h
24 #include <boost/shared_array.hpp>
26 //#include <midi++/types.h>
28 typedef unsigned char byte;
32 To make building arrays of bytes easier. Thusly:
35 mba << 0xf0 << 0x00 << 0xf7;
40 MidiByteArray direct( 3, 0xf0, 0x00, 0xf7 );
44 cout << direct << endl;
46 will all result in "f0 00 f7" being output to stdout
48 class MidiByteArray : public std::vector<MIDI::byte>
51 MidiByteArray() : std::vector<MIDI::byte>() {}
53 MidiByteArray( size_t count, MIDI::byte array[] );
56 Accepts a preceding count, and then a list of bytes
58 MidiByteArray( size_t count, MIDI::byte first, ... );
60 /// return smart pointer to a copy of the bytes
61 boost::shared_array<MIDI::byte> bytes() const;
63 /// copy the given number of bytes from the given array
64 void copy( size_t count, MIDI::byte arr[] );
67 /// append the given byte to the end of the array
68 MidiByteArray & operator << ( MidiByteArray & mba, const MIDI::byte & b );
70 /// append the given string to the end of the array
71 MidiByteArray & operator << ( MidiByteArray & mba, const std::string & );
73 /// append the given array to the end of this array
74 MidiByteArray & operator << ( MidiByteArray & mba, const MidiByteArray & barr );
76 /// output the bytes as hex to the given stream
77 std::ostream & operator << ( std::ostream & os, const MidiByteArray & mba );