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