I wanted a simple stream like class that was very light-weight and easy to use for binary serialization of variable-length structures. I didn't want it to be much more expensive than just dereferencing values with a pointer, but I wanted it to provide somewhat better type safety and endian byte-order independence for working with different file formats in a portable manner.
Furthermore, I wanted it to be usable on top of asynchronous file and network I/O, so you just serialize your stuff into a big block of memory that you specify, and then when you're done you asynchronously stream it to a file or socket. Same process in reverse for deserialization.
I've added it to my libprog++ library, so it has some header dependencies, namely the stuff in byte_swap.hpp which maps to compiler intrinsics or inline assembly using the CPU's byte swapping instructions. I've also removed some ugly preprocessor macros for proper shared library/dll symbol exporting for sake of brevity.
OP here. I just noticed all of my pointer casts were using volatile pointers, that was carry over from some older heavier-weight code that was tied into a file_stream class. I was having problems with GCC 4.2's half-broken type-punning and strict aliasing implementation, it was optimizing out a lot of my stores. Of course, in GCC 4.6 reinterpret_cast now works more like a union cast, but the solution on older versions of GCC was to use char* or union casting, so I just switched the base pointer type to char* and got rid of the volatile qualification.
>>5
Nice duplicate post bro. We're two posts closer now to the dubs guy posting check em thanks to you, seeing as how you also forced my hand into posting this response.