473,396 Members | 2,011 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,396 software developers and data experts.

iostream trouble (accessing basic_ios)

Hello,
I'm somehow annoyed.

This works:
using namespace std; // <-- Don't like this
std::basic_filebuf<char> fb;
fb.open("out.txt",std::ios_base::out);
std::basic_ofstream<char> ofs;
ofs.basic_ios<char>::rdbuf(&fb);
This too:
typedef basic_ios<char> bioschar; // Don't like this
ofs.bioschar::rdbuf(&fb);
This not:
// Would like this
std::basic_filebuf<char> fb;
fb.open("out.txt",std::ios_base::out);
std::basic_ofstream<char> ofs;
ofs.std::basic_ios<char>::rdbuf(&fb); // <-- but Error here

Generally, I don't like using using. I don't like the typedef version
either. Is there an easy way to make the last version working? (MSVC6)

TIA,
Michael B.
Jul 22 '05 #1
5 1377
Michael Bruschkewitz wrote:
Generally, I don't like using using. I don't like the typedef version
either. Is there an easy way to make the last version working? (MSVC6)

I think it is a compiler problem because on MSVC++ .NET2k3 it compiles
without problems.

SirMike
Jul 22 '05 #2
In article <cl**********@flis.man.torun.pl>, si*****@poczta.onet.pl
says...
Michael Bruschkewitz wrote:
Generally, I don't like using using. I don't like the typedef version
either. Is there an easy way to make the last version working? (MSVC6)

I think it is a compiler problem because on MSVC++ .NET2k3 it compiles
without problems.

SirMike

So I'll have to deal with it. Thank you for the fast response.

Michael B.
Jul 22 '05 #3
Michael Bruschkewitz wrote:

Generally, I don't like using using. I don't like the typedef version
either. Is there an easy way to make the last version working? (MSVC6)

I know VC 6 has som problems with name qualification (for example
using std::vector; vector<int>::iterator x;
yeilds errors as well.

If you don't mind, can I ask what you are atrying to accomplish?
If you're going to manage the stream buffers yourself, why not
use a basic_ostream instead (which doesn't overload the stream
buffer). fstream is unprepared for you to replace the buffer
it created (it assumes that the one it fed to the basic_ios is
the same one that will be there at destruction time).

Jul 22 '05 #4

"Michael Bruschkewitz" <br*******************************************@gmx .net> wrote in
message news:MP************************@news.compuserve.de ...
| In article <cl**********@flis.man.torun.pl>, si*****@poczta.onet.pl
| says...
| > Michael Bruschkewitz wrote:
| > > Generally, I don't like using using. I don't like the typedef version
| > > either. Is there an easy way to make the last version working? (MSVC6)
| > I think it is a compiler problem because on MSVC++ .NET2k3 it compiles
| > without problems.
| >
| > SirMike
| >
| So I'll have to deal with it. Thank you for the fast response.

It also compiles just fine with 'Borland C++ Builder 5.0 UP-1'.

Cheers.
Chris Val
Jul 22 '05 #5
In article <41***********************@news.newshosting.com> ,
ro*@sensor.com says...
If you don't mind, can I ask what you are atrying to accomplish?
If you're going to manage the stream buffers yourself, why not
use a basic_ostream instead (which doesn't overload the stream
buffer). fstream is unprepared for you to replace the buffer
it created (it assumes that the one it fed to the basic_ios is
the same one that will be there at destruction time).

That's an example from Langner/Kreft: Standard C++ IOStreams and
Locales.

I create a outstream which is used for logfiles. These logfiles should
not exceed a certain size. This is done by :
class CLogFileBuf : public std::basic_filebuf<char> ...

CLogFileBuf::int_type CLogFileBuf::overflow(int_type _C)
{ int_type rc = inherited::overflow(_C);
++m_counter;
if(m_counter>=m_maxSize && _C=='\n') opennext();
return rc;
}
void CLogFileBuf::opennext()
{ inherited::close();
m_counter=0;
createNextFn(m_fnTempl,m_fn); // template-name, current name
inherited::open(m_fn.c_str(),std::ios_base::out);
}

Maybe I need some cleanup, but until now, it works.

Michael B.
Jul 22 '05 #6

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

Similar topics

2
by: qazmlp | last post by:
When I compile my C++ source code, I am getting hundreds of following warning. "/opt/SUNWspro/WS6U1/include/CC/Cstd/./ios", line 148: Warning: std::basic_ios<char, std::char_traits<char>>::copyfmt...
7
by: S. Nurbe | last post by:
Hi, probably this is a common problem but I couldn't find yet a proper solution (and I hope there is one). I have two relative complex frameworks: one uses only iostream.h the other one only...
4
by: goberle | last post by:
I have installed the Cygwin package under WinXP. I am trying to insure that I have a reasonable development environment, and that things are working properly, by trying to compile and run the...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
8
by: mmu2643 | last post by:
Hi, I was trying to compile the following bit of code: #include <iostream.h> main(){ cout<<"Hello World!";
2
by: NewToCPP | last post by:
I am having some trouble including "iostream" "fstream" to my code. I tried the following ways and base times it did not work. What is the problem? test.cc: ======= ..... #include...
4
by: Alan | last post by:
I`m having trouble figuring out the correct syntax for accessing an element of a struct variable (t_list) passed by reference to a function. The compiler does not like the code below when I added...
8
by: Claudia Fong | last post by:
Hi, I'm trying to connect to a sql db with my C# applciation but I'm having trouble to connect.. It said - Error accessing the database: Cannot open database "LibDB" requested by the login. The...
8
by: jean.daniel.michaud | last post by:
Hi all, Something I don't get. The code is: // snippet on #include <list> #include <iostream> int main()
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.