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/ ?
841
Name:
Anonymous
2011-07-04 9:06
OP here.
Stopped reading right there.
842
Name:
Anonymous
2011-07-04 9:06
OP here.
Stopped reading right there.
843
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
844
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
845
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
846
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
847
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
848
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
849
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
850
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
851
Name:
Anonymous
2011-07-04 9:07
OP here.
Stopped reading right there.
852
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
853
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
854
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
855
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
856
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
857
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
858
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
859
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
860
Name:
Anonymous
2011-07-04 9:08
OP here.
Stopped reading right there.
861
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
862
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
863
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
864
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
865
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
866
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
867
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
868
Name:
Anonymous
2011-07-04 9:09
OP here.
Stopped reading right there.
869
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
870
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
871
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
872
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
873
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
874
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
875
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
876
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
877
Name:
Anonymous
2011-07-04 9:10
OP here.
Stopped reading right there.
878
Name:
Anonymous
2011-07-04 9:11
OP here.
Stopped reading right there.
879
Name:
Anonymous
2011-07-04 9:11
OP here.
Stopped reading right there.
880
Name:
Anonymous
2011-07-04 9:11
OP here.
Stopped reading right there.
Newer Posts