17 lines
518 B
C++
17 lines
518 B
C++
#pragma once
|
|
#include <google/protobuf/message.h>
|
|
#include <map>
|
|
|
|
typedef ::google::protobuf::Message ProtoMessage;
|
|
typedef ::google::protobuf::Descriptor ProtoDescriptor;
|
|
|
|
struct ProtoMsgCodec {
|
|
static unsigned char* encode(ProtoMessage* msg, size_t& msgSize);
|
|
static ProtoMessage* decode(unsigned char* buf, size_t size);
|
|
static bool msgComplete(unsigned char* buf, size_t size);
|
|
};
|
|
|
|
inline bool ProtoMsgCodec::msgComplete(unsigned char* buf, size_t size) {
|
|
return size >= 4 && size >= *(uint32_t *)buf;
|
|
}
|