Connecting Tech Pros Worldwide Help | Site Map

ifstream / filebug / FILE*

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 04:36 PM
Mathieu Malaterre
Guest
 
Posts: n/a
Default ifstream / filebug / FILE*

Hi,

I am tryig to convert part of a c++ IO library. Right now I am removing
all 'FILE*' and replace them with ifstream.

But I have a problem, after seeking through a stream I have to call the
ijg (jpeg library). Since this is a C library it uses FILE*. My question
is then is there a compatibility layer for ifstream <-> FILE* ?
It should work on non-GNU compiler.

Thanks,
Mathieu
Ps: All I found was:
http://gcc.gnu.org/onlinedocs/libstd...__filebuf.html

  #2  
Old July 22nd, 2005, 04:36 PM
Siemel Naran
Guest
 
Posts: n/a
Default Re: ifstream / filebug / FILE*

"Mathieu Malaterre" <malat@free.fr> wrote in message news:ciAKc.49088
[color=blue]
> I am tryig to convert part of a c++ IO library. Right now I am removing
> all 'FILE*' and replace them with ifstream.
>
> But I have a problem, after seeking through a stream I have to call the
> ijg (jpeg library). Since this is a C library it uses FILE*. My question
> is then is there a compatibility layer for ifstream <-> FILE* ?
> It should work on non-GNU compiler.[/color]

I don't think there is a portable way to convert an fstream info a FILE. In
practice, I imagine the std::filebuf class contains within it a priviate
member FILE *, but it's not required by the standard nor is the a public
function to get it.


  #3  
Old July 22nd, 2005, 04:36 PM
John Harrison
Guest
 
Posts: n/a
Default Re: ifstream / filebug / FILE*

On Sun, 18 Jul 2004 19:35:36 GMT, Mathieu Malaterre <malat@free.fr> wrote:
[color=blue]
> Hi,
>
> I am tryig to convert part of a c++ IO library. Right now I am removing
> all 'FILE*' and replace them with ifstream.
>
> But I have a problem, after seeking through a stream I have to call the
> ijg (jpeg library). Since this is a C library it uses FILE*. My question
> is then is there a compatibility layer for ifstream <-> FILE* ?
> It should work on non-GNU compiler.
>
> Thanks,
> Mathieu
> Ps: All I found was:
> http://gcc.gnu.org/onlinedocs/libstd...__filebuf.html[/color]

There is no standard way to convert ifstream to FILE*.

The only way to get the compatibility you want is to write your own stream
classes. These classes would extend the iostream library but also use a
FILE* internally which you can then make accessible.

Extending the iostream library is not too difficult and is a useful
technique to learn. You could find the technique explained in The
C++ Standard Library by Josuttis for instance.

john

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.