c++中pb的使用案例

    IM::File::IMLoginReq login_req;
    login_req.set_username("测试");
    login_req.set_password("123456");
 
    int length =  login_req.ByteSize();
    char* buf = new char[length];
    login_req.SerializeToArray(buf,length);
 
    std::string pbBody=buf;
    IM::File::IMLoginReq req;
    if (!req.ParseFromString(pbBody))
    {
    }
    QString username = QString::fromLocal8Bit(req.username().c_str());
    qDebug()<<"username is:"<<username;
    delete [] buf;

猜你喜欢

转载自blog.csdn.net/fanhenghui/article/details/82702238
今日推荐