Saturday, 14 September 2013

Binary Buffer Conversion

Binary Buffer Conversion

I am writing binary buffers which are byte aligned for network packets
that can read/write variant types. It must convert these to into an
internal unsigned char (byte) container (STL vector) and then when read
back it must reconstruct a variant type from so many bytes.
I have it partially working so far with the following code...
var test;
test = buffer_create(100, buffer_grow, 1);
show_message(string(buffer_tell(test)));
buffer_write(test, buffer_u32, 214748);
show_message(string(buffer_tell(test)));
buffer_seek(test, buffer_seek_start, 0);
show_message(string(buffer_read(test, buffer_u32)));
And the code that adds these functions in the engine...
http://pastebin.com/PqpCZVD3
Except the 214748 comes back out as 214528 :( Bye alignment is also not
the issue since it is completely ignored for right now, I am just trying
to test reading/writing an integer, string writing/reading already works.

No comments:

Post a Comment