- 浏览: 258790 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (263)
- mysql (5)
- boost (6)
- 工具 (10)
- IT生活 (7)
- 多线程 (3)
- Ruby (15)
- php (2)
- MongoDB (39)
- 移动互联网 (2)
- 测试 (8)
- c++ (28)
- 书 (1)
- 网站 (3)
- 网络编程 (14)
- 开源软件 (1)
- 分布式计算 (1)
- 得得得 (1)
- php,wordpress (1)
- error (5)
- 编译 (2)
- 学习 (1)
- 杀毒软件 (1)
- dd (0)
- linux (21)
- 数据库 (1)
- STL (1)
- c++/c (5)
- 软件设计 (1)
- 操作系统 (4)
- 库 (2)
- win32 (1)
- s (0)
- openssl (1)
- perl (2)
- debug (1)
- windows (4)
- python (12)
- windows 防火墙 (1)
- vs (1)
- vim (2)
- vc (1)
- 浏览器插件的危害 (1)
- curl (0)
- 判断手机号码合法性的库 (0)
- 地址备注 (0)
- 安装 File::Slurp (1)
- cenos (2)
- shell (1)
- linunx (1)
- internet (1)
- software (1)
- widows (1)
- linux io (1)
- nginx (2)
- 算法 (2)
- google (1)
- protobuf (2)
- tengine (1)
- tools (1)
- lua (2)
- liunx (1)
- vcard (1)
- lua-iconv (1)
- 网络 (2)
- teat (0)
- ldconfig linux (0)
- awk (0)
- grep (0)
- windws (2)
- linux 命令 (1)
- tcp dump (1)
- vmware (1)
- question2answer (2)
- mongdb (1)
- 正则 (1)
- OCR (2)
- Windows Server (1)
最新评论
在用boost 二进制序列化类的时候,需要注意动态调用文件打开标志std::ios::binary:
The flag std::ios::binary is required only in Windows, where the default mode (ascii) would translate \n\r to \n (and vice versa), thus corrupting any data that is not textual.
The flag std::ios::binary is required only in Windows, where the default mode (ascii) would translate \n\r to \n (and vice versa), thus corrupting any data that is not textual.
#include <boost/serialization/string.hpp> #include "boost/archive/binary_oarchive.hpp" #include "boost/archive/binary_iarchive.hpp" #include "boost/iostreams/stream.hpp" #include <boost/serialization/version.hpp> typedef struct tagWorkStruct { string groundTruthFile; string jpegFile; int workId; }WorkStruct; template<class Archive> void serialize(Archive &ar, AddNewCardWorkStruct &g, const unsigned int version) { ar & g.groundTruthFile; ar & g.jpegFile; ar & g.workId; } //写入文件 string fileName = "test.dat"; ofstream os(fileName.c_str(), std::ios::binary); if (!os.fail()) { try { WorkStruct tempStruct; boost::archive::binary_oarchive oa(os); oa << tempSturct; } catch(...) { } } //读取文件 ifstream is(dataFileName.c_str(), std::ios::binary); if (!is.fail()) { try { WorkStruct tempStruct; boost::archive::binary_iarchive ia(is); ia >> tempStruct; } catch (...)//boost::archive::archive_exception { } }
发表评论
-
c++ 读取unicode文档
2015-02-09 16:12 915int ReadOneNameFile(char *fil ... -
http://curl.haxx.se/
2013-06-13 17:41 0http://curl.haxx.se/ -
[转]线程本地存储(Thread Local Storage, TLS)分析与使用
2013-05-03 16:53 770线程本地存储(Thread Local Storage, TL ... -
C/C++获得windows版本
2012-12-01 11:05 1397MSDN上有详细介绍,做个标记: #include & ... -
[转]异常处理与MiniDump详解(4) MiniDump
2012-10-24 14:46 928异常处理与MiniDump详解(4) MiniDump wri ... -
禁用系统硬错误消息对话框
2012-08-31 19:14 689http://support.microsoft.com/kb ... -
Application Crash Dump Analysis (Windows 7)
2012-08-28 09:39 0Application Crash Dump Analysis ... -
如何成为一个windows程序debug高手
2012-08-18 14:40 0minidump: http://blog.csdn.ne ... -
Boost库编译后命名方式
2012-05-17 10:29 1281Boost官网的《Geting Started ... -
geoIP
2012-05-14 12:38 0http://www.oschina.net/code/sni ... -
vs2010 断点 无法命中
2012-05-07 16:13 1316这种情况不解决办法有 很多。你这个方法我没用过。最简单的方法就 ... -
$err,hr
2012-05-04 20:43 848在Visual C++ 中,可以在监视窗口添加 $err,hr ... -
WINDOWS下线程同步探讨
2012-04-11 15:04 919概述 线程同步可 ... -
undefined reference to 'pthread_create'问题解决
2012-03-30 11:43 0由于是Linux新手,所以现在才开始接触线程编程,照着GUN/ ... -
linux 下 遍历文件夹下的内容
2012-03-29 19:43 0// only works in cpp #ifdef __c ... -
浅谈ReadDirectoryChangesW函数的作用和问题所在
2012-03-23 10:32 4245转自:http://www.cnblogs.com ... -
用 _findfirst 和 _findnext 查找文件,遍历文件夹
2012-03-30 11:39 1983标签: _findfirst _findnext 杂谈 分类: ... -
我的广告
2012-03-19 10:57 0http://www.webweb.com/signup.as ... -
服务器多服务器设置
2012-03-12 18:01 722当服务器功能比较多时,可以抽象出一个代理,将不同的服务 ... -
记录个函数 strstr
2012-03-10 11:30 986包含文件:string.h 函数名: strstr 函 ...
相关推荐
一个支持状态存储的库。常用于乐观时间仿真及状态的回退与保存。
boost类序列化
Boost序列化.C++对象到磁盘,已解决内存不足的问题
1、包含文件和二进制两种序列化的方式 2、支持类的序列化和STL容器的序列化 3、支持序列化的流自定义(示例中使用的是std::stringstream,也可以使用其他的流)
C++11 下使用 Boost.Serialization 库实现智能指针的序列化
解决socket网络中通信的序列化和反序列化问题,很好的实例
由于项目需要,要使用boost,所以在网上找了一些例子帮助理解,其中遇到很多问题,再次总结记录一下。 #include <boost> #include <boost> #include <boost> #include #include std::stringstream ss; void...
如果服务器和客户端都是用C++语言写的就可以用序列化方法将数据存放到流...以下是用boost序列化库写的一个例子: 可以用boost自带的serialization::access来使用序列化C++ 序列化处理类: //SerilizationObject.cpp cl
如果你想实现你序列化alothgrim,请参考和 其他序列化的区别 方法 跨语言 需要修改代码 容器支持 记忆 特洛伊 通过你的alothgrim 不 是的 低的 原型/节俭 是的 需要写原型 只有矢量和地图(适用于 proto3) 高的
Boost序列化示例 简而言之,序列化就是将任何数据结构转换为一种格式,该格式允许将数据写入支持文件(文件,套接字等)。 Boost提供了一个序列化库,该库带有针对POD和stl类型的开箱即用的序列化,但是它易于使用...
kapok是一个高性能跨平台的对象-json序列化的库,对象序列化后是标准的json格式,json格式的字符串可以直接反序列化为对象。简单,易用,header-only,只需要引用Kapok.hpp即可。它由c 14实现,因此需要支持C 14的...
此压缩包包含12个项目,每个项目都着重讲解Boost::Serialization一个方面的使用技巧,有详细的代码介绍具体使用方法。
造访 建立程序 ... 可以在较新版本的boost,打开由旧版本的boost序列化的文件boost,但是没有反向兼容性。 要检查boost_serialization的版本,请参阅文件boost-source-dir/libs/serialization/src/b
闲来无事发现了一个基于C++实现的序列化工具,相比于其他(比如Boost serialization或Google protobuf,恰巧都用过,以后再介绍),使用简单,感觉不错,下面做个摸索。 cereal介绍 cereal是一个开源的(BSD ...
它需要使用 boost 序列化支持进行编译(有关更多信息,请参阅 libleeloo 的 README) 升压Python 随机提升 升压日志 在基于 debian 的系统下,您可以执行以下操作: # apt-get install boost-{python,random,log...
深度解析C++准标准库(第2版)》基于Boost 1.54版,深入探讨了其中的许多重要组件,包括迭代器、函数对象、容器、流处理、序列化以及C++语言中最复杂最具威力的模板元编程,并专辟一章详细阐述Boost的开发实例,具有...
1.Python实现CatBoost时间序列预测(完整源码和数据) anaconda + pycharm + python +Tensorflow 注意事项:保姆级注释,几乎一行一注释,方便小白入门学习! 2.代码特点:参数化编程、参数可方便更改、代码编程思路...
Monero Python序列化库 该库为Monero类型提供了基本的序列化逻辑,用于事务处理和事务签名中。 主要支持与Monero BEGIN_SERIALIZE_OBJECT()等效的二进制序列化。 该序列化机制用于区块链实体序列化。 增加了可移植...
febird 实现了一个序列化框架(对比boost.serializaiton/google.protocolbuffer),可以用在协议解析,大/小数据的序列化,有极高的性能(比boost.binary_archive快30~80倍),甚至对于非常小的对象,例如只有几个...