After a lot searching for solutions I've decided to actually ask for some help!
I have a file that consists of a number of blocks, where each block may or may not be compressed. Before each block is an indication of the size of the block and whether the block is compressed. Within each block is a string that identifies the block. Given a block name I would like to get the associated block from the file.
My first thought is to read the compression flag and the size of the block, read just the block into an istringstream, decompress the istringstream if needed, then search for the block name. I can read the compression flag and the size of the block, but I'm at a loss as to how to read the block of file data into the istringstream. I see where people have read entire files into a istringstream but I don't want to do that because each block may or may not need to be decompressed.
Any ideas or a link to a solution that I missed? Or is there a better algorithm? Thanks for any comments.