home *** CD-ROM | disk | FTP | other *** search
/ Prima Shareware 3 / DuCom_Prima-Shareware-3_cd1.bin / PROGRAMO / C / GCSTRI / ERROR.CPP next >
Encoding:
C/C++ Source or Header  |  1991-10-25  |  1.5 KB  |  62 lines

  1. /**************************************************************************
  2. These C++ classes are copyright 1989, 1990, 1991 by William Herrera.
  3. I hereby release this source code for free distrubution and use.
  4. If you modify it and distribute it, please indicate any changes you
  5. make as your own and the code as copyrighted above.
  6. **************************************************************************/
  7.  
  8. // file error.cpp error reporting class definitions.
  9.  
  10. #include <iostream.h>
  11. #include <stdlib.h>
  12.  
  13. #include "error.hpp"
  14.  
  15.  
  16. void (* Error::errfunc_i)(const int) = Error::iStateError;
  17.  
  18. void (* Error::errfunc_pcpci)
  19.     (const char *, const char *, const char *, const int)
  20.     = Error::pcpciStateError;
  21.  
  22.  
  23. Error::Error(const int errlevel)
  24. {
  25.     (*errfunc_i)(errlevel);
  26. }
  27.  
  28. Error::Error(const char * p, const char * q,
  29.     const char * r, const int errlevel)
  30. {
  31.     (*errfunc_pcpci)(p, q, r, errlevel);
  32. }
  33.  
  34. void Error::iStateError(const int errlevel)
  35. {
  36.     cerr << "\nError class reporting: runtime error"
  37.         << errlevel << '\n';
  38.     if(errlevel != 0)
  39.         exit(errlevel);
  40. }
  41.  
  42. void Error::pcpciStateError(const char * p, const char * q,
  43.     const char *r, const int errlevel)
  44. {
  45.     cerr << p << q << r;
  46.     if(errlevel != 0)
  47.         exit(errlevel);
  48. }
  49.  
  50. void Error::SetiStateErrorFunc(void (*f)(const int))
  51. {
  52.     errfunc_i = f;
  53. }
  54.  
  55. void Error::SetpcpciStateErrorFunc(void (*f)(const char *,
  56.     const char *, const char *, const int))
  57. {
  58.     errfunc_pcpci = f;
  59. }
  60.  
  61. // end of file error.cpp
  62.