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/

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM