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/ ?
601
Name:
Anonymous
2011-07-04 8:38
OP here.
Stopped reading right there.
602
Name:
Anonymous
2011-07-04 8:38
OP here.
Stopped reading right there.
603
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
604
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
605
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
606
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
607
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
608
Name:
Anonymous
2011-07-04 8:39
>>1
I don't need such class, but the code looks pretty nice. Only thing I don't like is that prog/* dependency, wtf are those...
609
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
610
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
611
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
612
Name:
Anonymous
2011-07-04 8:39
OP here.
Stopped reading right there.
613
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
614
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
615
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
616
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
617
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
618
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
619
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
620
Name:
Anonymous
2011-07-04 8:40
OP here.
Stopped reading right there.
621
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
622
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
623
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
624
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
625
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
626
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
627
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
628
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
629
Name:
Anonymous
2011-07-04 8:41
OP here.
Stopped reading right there.
630
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
631
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
632
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
633
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
634
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
635
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
636
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
637
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
638
Name:
Anonymous
2011-07-04 8:42
OP here.
Stopped reading right there.
639
Name:
Anonymous
2011-07-04 8:43
OP here.
Stopped reading right there.
640
Name:
Anonymous
2011-07-04 8:43
OP here.
Stopped reading right there.
Newer Posts