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/ ?
41
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
42
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
43
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
44
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
45
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
46
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
47
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
48
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
49
Name:
Anonymous
2011-07-04 7:32
OP here.
Stopped reading right there.
50
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
51
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
52
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
53
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
54
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
55
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
56
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
57
Name:
Anonymous
2011-07-04 7:33
OP here.
Stopped reading right there.
58
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
59
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
60
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
61
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
62
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
63
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
64
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
65
Name:
Anonymous
2011-07-04 7:34
OP here.
Stopped reading right there.
66
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
67
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
68
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
69
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
70
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
71
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
72
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
73
Name:
Anonymous
2011-07-04 7:35
OP here.
Stopped reading right there.
74
Name:
Anonymous
2011-07-04 7:36
OP here.
Stopped reading right there.
75
Name:
Anonymous
2011-07-04 7:36
OP here.
Stopped reading right there.
76
Name:
Anonymous
2011-07-04 7:36
OP here.
Stopped reading right there.
77
Name:
Anonymous
2011-07-04 7:36
OP here.
Stopped reading right there.
78
Name:
Anonymous
2011-07-04 7:36
OP here.
Stopped reading right there.
79
Name:
Anonymous
2011-07-04 7:36
OP here.
Stopped reading right there.
80
Name:
Anonymous
2011-07-04 7:36
OP here.
Stopped reading right there.
Newer Posts