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/ ?
121
Name:
Anonymous
2011-07-04 7:41
OP here.
Stopped reading right there.
122
Name:
Anonymous
2011-07-04 7:41
OP here.
Stopped reading right there.
123
Name:
Anonymous
2011-07-04 7:41
OP here.
Stopped reading right there.
124
Name:
Anonymous
2011-07-04 7:41
OP here.
Stopped reading right there.
125
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
126
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
127
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
128
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
129
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
130
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
131
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
132
Name:
Anonymous
2011-07-04 7:42
OP here.
Stopped reading right there.
133
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
134
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
135
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
136
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
137
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
138
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
139
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
140
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
141
Name:
Anonymous
2011-07-04 7:43
OP here.
Stopped reading right there.
142
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
143
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
144
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
145
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
146
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
147
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
148
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
149
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
150
Name:
Anonymous
2011-07-04 7:44
OP here.
Stopped reading right there.
151
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
152
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
153
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
154
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
155
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
156
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
157
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
158
Name:
Anonymous
2011-07-04 7:45
OP here.
Stopped reading right there.
159
Name:
Anonymous
2011-07-04 7:46
OP here.
Stopped reading right there.
160
Name:
Anonymous
2011-07-04 7:46
OP here.
Stopped reading right there.
Newer Posts