GrpcPrint/PrintS/Remote/bak/proto_msg.h

17 lines
518 B
C
Raw Normal View History

2024-03-26 10:33:00 +08:00
#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;
}