I have a stringstream that contains encoded (hex) text in the following order (breaks are for clarity only):
First 8 characters: 00000007 (representing a number of columns)
Second 8 characters: 0000005d (representing an integer number of rows)
Remaining characters: 0a5b....6c2d (this can be any number of characters, it was encoded from a set of data)
In other words, the stream contains 000000070000005d0a5b....6c2d
I want to pass the stream contents into a library function "decode(&istream)" that will decode it. Assume for this example there are 4000 characters of actual data (i.e. ignoring the first 16). The decode function expects a stream that specifies the length of the data stream, then 'x' as a separator, and finally the data, i.e. it must be in the following format:
4000x0a5b....6c2d
Could someone please tell me how I can modify the stream and then pass it to the decode function? The stream could be large, potentially megabytes of data, so duplicating it could cause the process to run out of memory. The original number of columns and rows can be discarded, they are no longer relevant. I would guess this could be easily done with pointers, but I have not been able to figure out how.