| | |
string stream
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 7
Reputation:
Solved Threads: 0
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 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
I would be glad if you have any other ideas that can help me improve the speed
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 C++ Syntax (Toggle Plain Text)
ios::out
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
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.
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.
•
•
Join Date: May 2006
Posts: 7
Reputation:
Solved Threads: 0
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
![]() |
Similar Threads
- string input segmentation fault on linux (C++)
- overloaded input stream help (C++)
- String to Bitstream (C++)
- Help with dates (C)
- Is ifs is a member function of ifstream class (C++)
Other Threads in the C++ Forum
- Previous Thread: Access elements of 'struct' using a variable.
- Next Thread: Won't Run
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






