7 #include <google/protobuf/message.h> 9 #include "mr/do_context.h" 14 using Message = google::protobuf::Message;
16 static std::string To(
bool is_binary,
const Message* msg);
19 static bool From(
bool is_binary, std::string tmp, Message* res);
22 template <
typename PB>
23 class RecordTraits<PB, std::enable_if_t<std::is_base_of<google::protobuf::Message, PB>::value>>
26 static std::string Serialize(
bool is_binary,
const PB& doc) {
27 return PB_Serializer::To(is_binary, &doc);
30 static bool Parse(
bool is_binary, std::string tmp, PB* res) {
31 return PB_Serializer::From(is_binary, std::move(tmp), res);
34 static std::string TypeName() {
36 return msg.GetTypeName();