controller

git-svn-id: svn://elaine/murooma/trunk@242 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-09-09 20:31:03 +00:00
parent e342a4108e
commit 00fac3eccb
15 changed files with 126 additions and 116 deletions

View file

@ -17,6 +17,13 @@ public:
};
struct membuf : public std::basic_streambuf<char>
{
membuf(char* begin, char* end) {
this->setg(begin, begin, end);
}
};
enum message_type
{
@ -48,9 +55,18 @@ struct BaseMessage
stream.read(reinterpret_cast<char*>(&size), sizeof(uint32_t));
}
virtual void readVec(std::vector<char>& stream)
void deserialize(char* payload)
{
vectorwrapbuf<char> databuf(stream);
membuf databuf(payload, payload + sizeof(size));
std::istream is(&databuf);
read(is);
}
void deserialize(const BaseMessage& baseMessage, char* payload)
{
type = baseMessage.type;
size = baseMessage.size;
membuf databuf(payload, payload + size);
std::istream is(&databuf);
read(is);
}