Archived

This topic is now archived and is closed to further replies.

'BitBuffer' type class

This topic is 4943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(C++) I am thinking of writing a bit-buffer like class that allows me to stream data into it, but have it automatically squish bools into bits. So it will be something like BitBuffer bb(64) // 64 bytes max storage (space allocated) bb << false; bb << true; bb << false; bb << (int) 9; mysend(bb, bb.length(), etc..); // bb.length() should return 5 (the int plus 3 bits) // then once data is received bool mybool1 = bb.readBool(); bool mybool2 = bb.readBool(); bool mybool3 = bb.readBool(); int number = bb.readInt(); Is there a library (open source) that contains something like this? If not, then can anyone tell me as to how i could achieve this bool squishing? Coz like in the above example, the last integer that is passed in would not be byte aligned, so i would need to have some kind of bit position marker, and then be able to read in data from that bit position, which i am not too sure how i could implement... Thanks for any help.

Share this post


Link to post
Share on other sites
The BitStream class in the Torque Network Library has this functionality and much more, including huffman compressed strings, compressed 3D vectors, and bit-compressed integers and floats. TNL can be downloaded from http://www.opentnl.org.

Share this post


Link to post
Share on other sites