开发者

C/C++ library for platform-independent binary file I/O

I've been trying for months to find a small C or C++ library for platform-independent binary 开发者_Go百科file I/O, that means endian swapping and with fixed size types.

I know that huge libraries like wxWidgets and Qt have them, and that languages like Java and C# also have them, but I'd prefer to use a small library instead of a huge framework.


How about Google Protocol Buffers?

The library includes bindings for C++, Java and Python.


Have a look at Boost.Serialization

One of it's goals is "Data Portability - Streams of bytes created on one platform should be readable on any other."

There are also links to other libraries providing similar functionality.


Why not just use fstream that comes packaged in with all C++ compilers. You just set the ios::binary flag and make plentiful use of sizeof to make it OS independent. E.g.: http://courses.cs.vt.edu/~cs2604/fall02/binio.html and http://www.codersource.net/c/c-tutorial-on-file-operations/c-file-i-o-binary-files-using-fstream.aspx


For most file format work I prefer to use sqlite : http://www.sqlite.org/ the cool thing is you can access the same data file across operating systems and programming languages and devices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜