Fast and simple C++ byte stream abstraction
1
Name:
Anonymous
2011-07-04 6:04
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.
This is what I came up with:
byte_stream.hpp -
http://codepad.org/4IaQJwpi
byte_stream.cpp -
http://codepad.org/8iJiYraM
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.
So, what do you think
/prog/ ?
321
Name:
Anonymous
2011-07-04 8:05
OP here.
Stopped reading right there.
322
Name:
Anonymous
2011-07-04 8:06
OP here.
Stopped reading right there.
323
Name:
Anonymous
2011-07-04 8:06
OP here.
Stopped reading right there.
324
Name:
Anonymous
2011-07-04 8:06
OP here.
Stopped reading right there.
325
Name:
Anonymous
2011-07-04 8:06
OP here.
Stopped reading right there.
326
Name:
Anonymous
2011-07-04 8:06
OP here.
Stopped reading right there.
327
Name:
Anonymous
2011-07-04 8:06
OP here.
Stopped reading right there.
328
Name:
Anonymous
2011-07-04 8:06
OP here.
Stopped reading right there.
329
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
330
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
331
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
332
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
333
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
334
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
335
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
336
Name:
Anonymous
2011-07-04 8:07
OP here.
Stopped reading right there.
337
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
338
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
339
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
340
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
341
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
342
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
343
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
344
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
345
Name:
Anonymous
2011-07-04 8:08
OP here.
Stopped reading right there.
346
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
347
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
348
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
349
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
350
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
351
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
352
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
353
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
354
Name:
Anonymous
2011-07-04 8:09
OP here.
Stopped reading right there.
355
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
356
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
357
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
358
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
359
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
360
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
Newer Posts