zoukankan      html  css  js  c++  java
  • boost::archive::binary_iarchive

    #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;
    }
  • 相关阅读:
    react 学习
    swiper
    日历插件
    插件 uploadify
    前端 websocket用法
    jQuery插件Highcharts
    可用于nodejs的SuperAgent(ajax API)
    git的基本命令
    自己对javascript闭包的了解
    函数中的this的四种绑定形式
  • 原文地址:https://www.cnblogs.com/zzyoucan/p/3722076.html
Copyright © 2011-2022 走看看