home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16132 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.3 KB  |  42 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!att-out!walter!qualcom.qualcomm.com!qualcom.qualcomm.com!greg
  3. From: greg@qualcom.qualcomm.com (Greg Noel)
  4. Subject: Can this be done with iostreams?
  5. Message-ID: <1992Nov12.021415.24889@qualcomm.com>
  6. Sender: news@qualcomm.com
  7. Nntp-Posting-Host: qualcom.qualcomm.com
  8. Organization: Qualcomm, Inc., San Diego, CA
  9. Date: Thu, 12 Nov 1992 02:14:15 GMT
  10. Lines: 30
  11.  
  12. Here's a fragment of code that I would like to convert to use iostreams.
  13. The idea is that it inserts some stuff onto the output stream, copies the
  14. information from the calling location, and then regains control so that
  15. it can finish up.
  16.  
  17.     void
  18.     Class::Err(char *msg, ... )
  19.     {
  20.         va_list ap;
  21.         printf("Line %d of `%s': ", linenumber, filename);
  22.         va_start(ap, msg);
  23.         vprintf(msg, ap);
  24.         putc('\n', stdout);
  25.         va_end(ap);
  26.         ++errorcount;
  27.     }
  28.  
  29. I'd like the result to look more like C++, perhaps something like:
  30.     Class Input; char *str; int i;
  31.     Input.Err() << "found bad input: " << str << " and " << i;
  32.  
  33. Failing that, is there some way using iostreams to simulate the original?
  34.  
  35. There was a thread a bit ago about controlling debugging output that has
  36. a similar flavor.  If this can be done, perhaps a similar technique can
  37. be used for that sort of thing.
  38.  
  39. Tks,
  40. -- 
  41. -- Greg Noel, Unix Guru         greg@qualcomm.com  or  greg@noel.cts.com
  42.