chore: Allow copying Messages

This is ground work for the `map` Thru function
in PR #232.
This commit is contained in:
Francois Best 2021-08-06 09:35:01 +02:00 committed by Eric Sherman
parent 08f6f53d12
commit 2ae9d9e509
No known key found for this signature in database
GPG Key ID: 5FF6E54D61748174
1 changed files with 15 additions and 1 deletions

View File

@ -54,6 +54,20 @@ struct Message
memset(sysexArray, 0, sSysExMaxSize * sizeof(DataByte)); memset(sysexArray, 0, sSysExMaxSize * sizeof(DataByte));
} }
inline Message(const Message& inOther)
: channel(inOther.channel)
, type(inOther.type)
, data1(inOther.data1)
, data2(inOther.data2)
, valid(inOther.valid)
, length(inOther.length)
{
if (type == midi::SystemExclusive)
{
memcpy(sysexArray, inOther.sysexArray, sSysExMaxSize * sizeof(DataByte));
}
}
/*! The maximum size for the System Exclusive array. /*! The maximum size for the System Exclusive array.
*/ */
static const unsigned sSysExMaxSize = SysExMaxSize; static const unsigned sSysExMaxSize = SysExMaxSize;
@ -94,7 +108,7 @@ struct Message
/*! Total Length of the message. /*! Total Length of the message.
*/ */
unsigned length; unsigned length;
inline unsigned getSysExSize() const inline unsigned getSysExSize() const
{ {
const unsigned size = unsigned(data2) << 8 | data1; const unsigned size = unsigned(data2) << 8 | data1;