home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!att-out!walter!qualcom.qualcomm.com!qualcom.qualcomm.com!greg
- From: greg@qualcom.qualcomm.com (Greg Noel)
- Subject: Can this be done with iostreams?
- Message-ID: <1992Nov12.021415.24889@qualcomm.com>
- Sender: news@qualcomm.com
- Nntp-Posting-Host: qualcom.qualcomm.com
- Organization: Qualcomm, Inc., San Diego, CA
- Date: Thu, 12 Nov 1992 02:14:15 GMT
- Lines: 30
-
- Here's a fragment of code that I would like to convert to use iostreams.
- The idea is that it inserts some stuff onto the output stream, copies the
- information from the calling location, and then regains control so that
- it can finish up.
-
- void
- Class::Err(char *msg, ... )
- {
- va_list ap;
- printf("Line %d of `%s': ", linenumber, filename);
- va_start(ap, msg);
- vprintf(msg, ap);
- putc('\n', stdout);
- va_end(ap);
- ++errorcount;
- }
-
- I'd like the result to look more like C++, perhaps something like:
- Class Input; char *str; int i;
- Input.Err() << "found bad input: " << str << " and " << i;
-
- Failing that, is there some way using iostreams to simulate the original?
-
- There was a thread a bit ago about controlling debugging output that has
- a similar flavor. If this can be done, perhaps a similar technique can
- be used for that sort of thing.
-
- Tks,
- --
- -- Greg Noel, Unix Guru greg@qualcomm.com or greg@noel.cts.com
-