|
-
March 24th, 2003, 11:59 AM
#1
new fstream class
I am starting to write my own Non-STL fstream class because it is not supported by the compiler I'm using ( eVC++ 3.0). I looked at STLPort, but it is just too complex for what I really need. I have all the basic functionality working -- e.g. read, write in both binary and text modes. Now I want to start adding some of the more sophicated stuff, like setw() and setfill(). But I'm stuck on how to imnplement them. For example:
stream << setw(8) << setfill('*') << 123.45F << endl;
Can anyone tell me how setw and setfill functions are implemented so that they return the stream object?
Thanks
-
March 24th, 2003, 12:10 PM
#2
I think the best approach would be for you to look at a current
implementation if you don't want to use a library that's already
out there. So, look at STLPort's implementation of fstream and
find out how THEY do it. If you have Visual Studio, see how they
do it as well.
The more you imitate these, however, the stronger the argument
is for you to juse use STLPort [or some other library] to begin
with.
--Paul
-
March 24th, 2003, 01:52 PM
#3
Check out The C++ Programming Language by Bjarne Stroustrup. There's a whole section on how to write your own I/O manipulators (section 21.4.6.3).
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
-- Sutter and Alexandrescu, C++ Coding Standards
Programs must be written for people to read, and only incidentally for machines to execute.
-- Harold Abelson and Gerald Jay Sussman
The cheapest, fastest and most reliable components of a computer system are those that aren't there.
-- Gordon Bell
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|