473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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
Jul 22 '05 #1
2 2200
"Mathieu Malaterre" <ma***@free.fr> wrote in message news:ciAKc.49088
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.


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.
Jul 22 '05 #2
On Sun, 18 Jul 2004 19:35:36 GMT, Mathieu Malaterre <ma***@free.fr> wrote:
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


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

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Johnston | last post by:
Hi, I'm currently trying to create a wrapper that uses C functions but behaves like ifstream (from fstream.h) - this is because the platform I'm using (WinCE) doesn't support streams and this is...
6
by: Herv? LEBAIL | last post by:
Hi everybody, I'm writing a program which use the <string>, <vector> and <ifstream> classes. Given an array of string, i.e vector<string> file_names, example : file_names = "file1.txt"...
6
by: Ram Laxman | last post by:
Iam new bie to C++ programming.. I want to write a program which will read the Comma separated values(CSV) file column wise. For example: In a.txt: "TicketNumber","Phone","CarNumber"...
6
by: csvka | last post by:
Hello, I wonder if I could pick your brains. I'm beginning to learn about C++. I have opened a file in my program and I want to read lines from it. I would like this to be done in a separate...
4
by: hall | last post by:
Hi. I ran across a bug in one of my problems and after spending some time tracking it down i found that the problem arose in a piece of code that essentially did this: ----------- ifstream...
10
by: sam | last post by:
Hi, Can anyone tell me how to print a file name from ifstream? the following cout code does not print the filename I created with ifstream preivous: ifstream is; is.open ("text.txt");
1
by: Xiaozhou.Yin | last post by:
Hi~ In the program,I first used the ifstream variable fin open the file and,open it again after called the fin.close().But the fin is fieled to open the file in the second time.The book I'm...
2
by: mpalomas | last post by:
Hi C++ folks, I have trouble to open files whose path contains non-ascii characters with std::ifstream. For instance let's say i just have a file which has Japanese characters either in the...
11
by: adramolek | last post by:
So... I'm trying to get used to using C++ ifstream (or ofstream) instead of stdio (although I'm having second thoughts). Anyways, I want to be able to display a meaningful error message if ifstream...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.