istream and streambuf problems 
Author Message
 istream and streambuf problems

Hi, I am trying to access simple C char array thorw istream. I derived ne
class from streambuf as following:

class CArrayStreamBuf: public streambuf{

public:

CArrayStreamBuf(char* data, long iLen){

setg(data,data,data + iLen);}};

Now I create the stream:

CArrayStreamBuf buf((char*)data,lDataLen);

stream inFile(&buf);

My problem is that the read function working as designed but I can't use
seekg and tellg function. They simply do nothing. Any suggestion why is it?

Regards, Victor



Fri, 23 Dec 2005 20:38:19 GMT  
 istream and streambuf problems


Quote:
>Hi, I am trying to access simple C char array thorw istream. I derived ne
>class from streambuf as following:

>class CArrayStreamBuf: public streambuf{

>public:

>CArrayStreamBuf(char* data, long iLen){

>setg(data,data,data + iLen);}};

>Now I create the stream:

>CArrayStreamBuf buf((char*)data,lDataLen);

>stream inFile(&buf);

>My problem is that the read function working as designed but I can't use
>seekg and tellg function. They simply do nothing. Any suggestion why is it?

You have to override seekoff and seekpos. However, this is all
pointless, since:

#include <strstream>

istrstream inFile((char const*)data, lDataLen);
//seekg should work fine

Tom



Fri, 23 Dec 2005 21:55:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. streambuf and IStream

2. streambuf problem with non-console program

3. problem with IStream

4. Problem with IStream?

5. BIZARRE problem with istream::tellg()

6. streambuf

7. CArchive and streambuf conversion

8. <streambuf>

9. istream, ostream, we all scream!

10. System.IO.Stream from IStream?

11. RC1 IStream and CString BUG

12. System.IO.Stream from IStream?

 

 
Powered by phpBB® Forum Software