protobuff 不知道的几个函数

1、protobuff消息拷贝函数CopyFrom

void CopyFrom(const Message& from)项目需求里,需要保存上一次的protobuff消息,刚开始竟然使用memcpy函数,后来发现repeated项大小不定,问同事,才知道有CopyFrom函数,于是:

latest_obstacles_.Clear();
latest_obstacles_.CopyFrom(*message);
注:message与latest_obstacles_必须是同一个类型的;

2、在我还一个个元素打印出来时,同事告诉说,可以使用ShortDebufString或者DebugString,可将整个完成的message输出,有点像protobuff定义的样子:
AERROR << (*message).DebugString();

Guess you like

Origin blog.csdn.net/zhiyijue7762/article/details/106078632