string stream

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2006
Posts: 7
Reputation: bibo1978 is an unknown quantity at this point 
Solved Threads: 0
bibo1978 bibo1978 is offline Offline
Newbie Poster

string stream

 
0
  #1
Jun 17th, 2006
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
  1. 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
Last edited by WolfPack; Jun 17th, 2006 at 3:50 am. Reason: Inline code tags
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 7
Reputation: bibo1978 is an unknown quantity at this point 
Solved Threads: 0
bibo1978 bibo1978 is offline Offline
Newbie Poster

Re: string stream

 
0
  #2
Jun 17th, 2006
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;
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,362
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: string stream

 
0
  #3
Jun 17th, 2006
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.
Last edited by Ancient Dragon; Jun 17th, 2006 at 8:55 am.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 7
Reputation: bibo1978 is an unknown quantity at this point 
Solved Threads: 0
bibo1978 bibo1978 is offline Offline
Newbie Poster

Re: string stream

 
0
  #4
Jun 17th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: string stream

 
0
  #5
Jun 17th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 7
Reputation: bibo1978 is an unknown quantity at this point 
Solved Threads: 0
bibo1978 bibo1978 is offline Offline
Newbie Poster

Re: string stream

 
0
  #6
Jun 17th, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC