c++ - Binary Serialization Using Boost and uint8_t -


When I work with binary data, I use uint8_t . I think that just looks like the type of a byte though, I can not understand how to promote binary serialization to work with that type. Is I impossible or just a few simple missing?

This example program does not compile VS 2013 with some complaints that the streams are not being converted to std :: ostream or std :: istream .

This program works properly with char instead of uint8_t , but this bug is me :)

  #include & lt; Cstdlib & gt; // EXIT_SUCCESS #include & lt; Vector & gt; #include "boost / archive / binary_oarchive.hpp" #include "boost / iostreams / device / array.hpp" # include "boost / iostreams / device / back_inserter.hpp" #include "boost / iostreams / stream_buffer.hpp" ant Main (Int arc, four ** argv) {typedef std :: vector & lt; Uint8_t & gt; Buffer; Buffer buffer; // serialization {int foo = 1; Typedef boost :: iostreams :: back_insert_device & lt; Buffer & gt; Device; Device device (buffer); Typedef boost :: iostreams :: stream_buffer & lt; Tools & gt; Stream; Stream stream (device); {Boost :: archive :: binary_oarchive archive (stream); Collection & lt; & Lt; Foo; }} / Deserialization {int foo; Typedef boost :: iostreams :: basic_array_source & lt; Uint8_t & gt; Device; Device device (buffer data (), buffer (.)); Typedef boost :: iostreams :: stream_buffer & lt; Tools & gt; Stream; Stream stream (device); {Boost :: archive :: binary_iarchive archive (stream); Collections & gt; & Gt; Foo; }} Return EXIT_SUCCESS; }    

Binary archives std :: istream / Std :: ostream argument, then you std :: basic_istream & lt; Char & gt; / std :: basic_ostream & lt; Char & gt; are trapped using. Incidentally, there is no guarantee that the implementation currents (or std :: char_traits & lt; unsigned char & gt; / uint8_t / Code>).

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -