码迷,mamicode.com
首页 > 其他好文 > 详细

boost::archive::binary_iarchive

时间:2014-05-12 21:51:09      阅读:572      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   c   

bubuko.com,布布扣
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <queue>
#include <boost/serialization/vector.hpp>
using namespace std;
struct MyStruct
{
    string stru;
    int len;
};
queue<MyStruct> q_stu;

void funa()
{
    MyStruct ms;
    int ret = 1;
    vector<int> vc;
    vc.push_back(1);
    vc.push_back(2);
    stringstream ss;
    boost::archive::binary_oarchive oa(ss);
    oa << ret << vc;
    ms.stru = ss.str();
    ms.len = ss.str().size();
    q_stu.push(ms);
}

void funb(const char* arg, int len)
{
    std::stringstream r_ss;
    r_ss.write(arg, len);
    boost::archive::binary_iarchive ia(r_ss);
    q_stu.pop();
    int ret;
    vector<int> vct;
    ia >> ret >> vct;
}


int main()
{
    funa();
    funb(q_stu.front().stru.c_str(), q_stu.front().len);
    getchar();
    return 0;
}
bubuko.com,布布扣

boost::archive::binary_iarchive,布布扣,bubuko.com

boost::archive::binary_iarchive

标签:style   blog   class   code   java   c   

原文地址:http://www.cnblogs.com/zzyoucan/p/3722076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!