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/ ?
521
Name:
Anonymous
2011-07-04 8:29
OP here.
Stopped reading right there.
522
Name:
Anonymous
2011-07-04 8:29
OP here.
Stopped reading right there.
523
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
524
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
525
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
526
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
527
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
528
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
529
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
530
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
531
Name:
Anonymous
2011-07-04 8:30
OP here.
Stopped reading right there.
532
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
533
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
534
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
535
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
536
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
537
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
538
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
539
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
540
Name:
Anonymous
2011-07-04 8:31
OP here.
Stopped reading right there.
541
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
542
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
543
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
544
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
545
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
546
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
547
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
548
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
549
Name:
Anonymous
2011-07-04 8:32
OP here.
Stopped reading right there.
550
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
551
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
552
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
553
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
554
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
555
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
556
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
557
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
558
Name:
Anonymous
2011-07-04 8:33
OP here.
Stopped reading right there.
559
Name:
Anonymous
2011-07-04 8:34
OP here.
Stopped reading right there.
560
Name:
Anonymous
2011-07-04 8:34
OP here.
Stopped reading right there.
Newer Posts