hi,

well my question may be very basic but can u help me
I have a buffer that including my data which is binary data and I want to use the iostream to handle the buffer read/write, seek ... etc,

I am using the strstream to do this, by setting the ios::binary and ios::in and

ios::out

flag I have no problem and the code works fine,
yet my code is very slow because each time I want to access a line from my data I have to use the strstream.write and .read although I have a buffer that already contains my data, I tried to get around this by using the strstream constructor identifying the pointer to the existing buffer, the buffer width and approbriat ios::flags , although that this actually make the base pointer points at my buffer but the problem that internal pointers are not updated with the width so when I try to read from the buffer it is assumed to be empty and no read operation can happen .. I want to know if there is a way around this by accessing the internal registers through which I can update the flags with the width so I can easily read from the buffer.
I would be glad if you have any other ideas that can help me improve the speed

I have tried to overload the strstream constructor and add the line below but I have a problem I couldn't access the bp or the _pptr provate members of streambuf

(((*(ios*)(&(*(istream*)(&(*(iostream*)(this))))))).bp))._pptr = in;

dev-c++ doesn't like strstream header file and claims it is deprecated. you should consider tossing it out of your program and using either iostream to display stuff on the console window or fstream to read/write to a disk file.

I don't want to output data to file I want to handle some buffered operation stsstream actually is IOstream and it works with binary data .. most of the job is done in the ststream but the problem is that I can't access the streambuf "bp member" of my strstream.

Start by stating what the problem is you're trying to solve rather than imagining using strstream is the answer. Tell us the problem you're trying to solve, not how to fix your solution.

Have you considered for example a vector of unsigned chars for storing your binary data?

> but the problem is that I can't access the streambuf "bp member" of my strstream.
The whole point of C++ is that internal representation is guarded by the class interface. If you're always smashing away the interface to get to the internals then you're really doing something wrong.

well actually I have an input buffered data more like 2-8 MB of data and I am doing some processing on it, I have done it with file IO so I am doing the processing on files, I need to seek data, read for the input buffered data, and for the output I need to write reallocate seek .. check integrity .. I used the iofstream and the program worked fine, the problem is that I wanted to do the processing all on buffers without putting it on files .. that's it is this good enough can you help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.