SmartOS/Message/Message.cpp

38 lines
625 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "Message.h"
// 初始化消息各字段为0
Message::Message(byte code)
{
Code = code;
Length = 0;
Data = NULL;
Reply = false;
Error = false;
}
// 设置数据。
void Message::SetData(const byte* buf, uint len)
{
//assert_param(len <= ArrayLength(Data));
Length = len;
if(len > 0 && buf != Data)
{
assert_ptr(buf);
assert_ptr(Data);
memcpy(Data, buf, len);
}
}
/*// 负载数据转数据流
Stream Message::ToStream()
{
return Stream(Data, Length);
}
// 负载数据转字节数组
ByteArray Message::ToArray()
{
return ByteArray(Data, Length);
}*/