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/ ?
761
Name:
Anonymous
2011-07-04 8:57
OP here.
Stopped reading right there.
762
Name:
Anonymous
2011-07-04 8:57
OP here.
Stopped reading right there.
763
Name:
Anonymous
2011-07-04 8:57
OP here.
Stopped reading right there.
764
Name:
Anonymous
2011-07-04 8:57
OP here.
Stopped reading right there.
765
Name:
Anonymous
2011-07-04 8:57
OP here.
Stopped reading right there.
766
Name:
Anonymous
2011-07-04 8:57
OP here.
Stopped reading right there.
767
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
768
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
769
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
770
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
771
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
772
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
773
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
774
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
775
Name:
Anonymous
2011-07-04 8:58
OP here.
Stopped reading right there.
776
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
777
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
778
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
779
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
780
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
781
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
782
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
783
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
784
Name:
Anonymous
2011-07-04 8:59
OP here.
Stopped reading right there.
785
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
786
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
787
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
788
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
789
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
790
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
791
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
792
Name:
Anonymous
2011-07-04 9:00
OP here.
Stopped reading right there.
793
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
794
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
795
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
796
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
797
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
798
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
799
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
800
Name:
Anonymous
2011-07-04 9:01
OP here.
Stopped reading right there.
Newer Posts