SmartOS/Message/Message.cpp

37 lines
666 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;
}
/*Message::Message(Message& msg)
{
Code = msg.Code;
Length = msg.Length;
Reply = msg.Reply;
// 基类构造函数先执行子类来不及赋值Data所以这里不要拷贝
//assert_ptr(Data);
//if(Length) memcpy(Data, msg.Data, Length);
}*/
// 设置数据。
void Message::SetData(byte* buf, uint len)
{
//assert_param(len <= ArrayLength(Data));
Length = len;
if(len > 0)
{
assert_ptr(buf);
assert_ptr(Data);
memcpy(Data, buf, len);
}
}