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/ ?
361
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
362
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
363
Name:
Anonymous
2011-07-04 8:10
OP here.
Stopped reading right there.
364
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
365
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
366
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
367
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
368
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
369
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
370
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
371
Name:
Anonymous
2011-07-04 8:11
OP here.
Stopped reading right there.
372
Name:
Anonymous
2011-07-04 8:12
OP here.
Stopped reading right there.
373
Name:
Anonymous
2011-07-04 8:12
OP here.
Stopped reading right there.
374
Name:
Anonymous
2011-07-04 8:12
OP here.
Stopped reading right there.
375
Name:
Anonymous
2011-07-04 8:12
OP here.
Stopped reading right there.
376
Name:
Anonymous
2011-07-04 8:12
OP here.
Stopped reading right there.
377
Name:
Anonymous
2011-07-04 8:12
OP here.
Stopped reading right there.
378
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
379
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
380
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
381
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
382
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
383
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
384
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
385
Name:
Anonymous
2011-07-04 8:13
OP here.
Stopped reading right there.
386
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
387
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
388
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
389
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
390
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
391
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
392
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
393
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
394
Name:
Anonymous
2011-07-04 8:14
OP here.
Stopped reading right there.
395
Name:
Anonymous
2011-07-04 8:15
OP here.
Stopped reading right there.
396
Name:
Anonymous
2011-07-04 8:15
OP here.
Stopped reading right there.
397
Name:
Anonymous
2011-07-04 8:15
OP here.
Stopped reading right there.
398
Name:
Anonymous
2011-07-04 8:15
OP here.
Stopped reading right there.
399
Name:
Anonymous
2011-07-04 8:15
OP here.
Stopped reading right there.
400
Name:
Anonymous
2011-07-04 8:15
OP here.
Stopped reading right there.
Newer Posts