From: Michael Bruschkewitz Date: 2009-04-04T15:44:29+09:00 Subject: Re: BInary Files "Joel VanderWerf" schrieb im Newsbeitrag news:49D64FD7.3000006@path.berkeley.edu... > Michael Bruschkewitz wrote: >> Is any Lib out there which realizes a bit-stream? > what would that do? Writing output bit-wise to a (ex.) string. Read back. Convert to/from char-array. Example: Given: a,b,c,d values of different bit-size a is a flag is 1 bit long, b is 5 bit long, c is 7 bit long. d is 3 bit long. It should be possible: bs << a << (1==a ? b : c) << d bs >> a >> (1==a ? b : c) >> d After insertion, bs should contain following bits (p is padding): 1bbb bbdd dppp pppp or 0ccc cccc dddp pppp. Other example would be var-length array of 5-bit values followed by var-length array of 13-bit structs. Use case: ASN.1 and similar formats.