c++中PROTOBUF遍历所有属性及值

假设以下是定义的test.proto文件

package T;
message Test
{
    optional int32 id = 1;
}

获取属性及值,并打印

#include "cpp/test.pb.h"
#include <iostream>
#include <string>

int main()
{
    T::Test config;
    std::string message;

    /* 加载×××.pb.h文件代码 */
    
    message = config.Utf8DebugString();
    std::cout << message << std::endl;
    return 0;
}

参考:https://www.p-chao.com/2017-09-04/protobuf%E5%8F%8D%E5%B0%84%E8%AF%A6%E8%A7%A3/

原文地址:https://www.cnblogs.com/didada/p/14432647.html