home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-1.ZIP / CLASSSRC.ZIP / OBJECT.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  3KB  |  94 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  OBJECT.CPP                                                            */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991                                  */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( TEMPLATES )
  11. #define TEMPLATES
  12. #endif
  13.  
  14. #if !defined( __CLSDEFS_H )
  15. #include <ClsDefs.h>
  16. #endif  // __CLSDEFS_H
  17.  
  18. #if !defined( __OBJECT_H )
  19. #include <Object.h>
  20. #endif  // __OBJECT_H
  21.  
  22. #if !defined( __STDLIB_H )
  23. #include <StdLib.h>
  24. #endif  // __STDLIB_H
  25.  
  26. #if !defined( __STRSTREA_H )
  27. #include <StrStrea.h>
  28. #endif  // __STRSTREA_H
  29.  
  30. #if !defined( __MALLOC_H )
  31. #include <Malloc.h>
  32. #endif  // __MALLOC_H
  33.  
  34. void *Object::operator new( size_t s )
  35. {
  36.     void *allocated = ::operator new( s );
  37.     if( allocated == 0 )
  38.         return ZERO;
  39.     else
  40.         return allocated;
  41. }
  42.  
  43. Error theErrorObject;
  44.  
  45. Object *Object::ZERO = &theErrorObject;
  46.  
  47. // Error reporting
  48.  
  49. static char *errstring[__ElastError] =
  50. {
  51.     "firstError: [[ Error in error reporting???? ]]",
  52.     "EDELERROR: Attemping to delete the ERROR object",
  53.     "EXPANDFS: Attempting to expand a fixed size array.",
  54.     "EXPANDLB: Attempt to expand lower bound of array.",
  55.     "NOMEM: Out of Memory",
  56.     "NOTSORT: Object must be sortable.",
  57.     "NOTASSOC: Object must be association type.",
  58.     "ORDER3: B-trees must be at least of order 3.",
  59.     "NOMEMIA: No room for the item array for an InnerNode",
  60.     "NOMEMLN: No room for item array for a LeafNode.",
  61.     "PRBADCLASS: PersistRegister called with bad class id.",
  62.     "PRINCONS: PersistRegister called with inconsistent values.",
  63.     "BNZERODIV: Attempt to divide by zero.",
  64.     "BNILLLOG: Attempt to take log of zero or negative number.",
  65.     "BNNOMEM: No memory for a bignum.",
  66.     "RANDOM2SMALL: Bignum RNG must be bigger than 32 bits (> 2 words).",
  67.     "BNTEMPSTKOVFL: Too many markTempRing invocations,",
  68.     "BNTEMPSTKUNFL: Too many releaseTempRing invocations,",
  69.     "BN2MANYTEMPS: Ran out of temporaries on the Temp ring.",
  70.     "BN2BIG2PRINT: Bignum has too many digits in current output base.",
  71.     "BNNOMEM4PRINT: No memory for temporaries for printing.",
  72.     "BNRESULT2BIG: An operation would have resulted in too large of a number.",
  73.     "RNG2BIG: Sorry.  RNGs are limited to 32767 `digits' in size.",
  74.     "BNSQRTILLEGAL: Trying to take sqrt of negative bignum.",
  75. };
  76.  
  77. extern "C" void __ErrorMessage( const char _FAR * );
  78.  
  79. void _FARFUNC ClassLib_error( ClassLib_errors errnum, char _FAR *addstr )
  80. {
  81.     ostrstream os;
  82.     os << endl << "Fatal error from class library:" << endl;
  83.     os << "__E" << errstring[errnum] << endl;
  84.     if( addstr != 0 )
  85.         os << addstr << endl;
  86.     os << ends;
  87.  
  88.     char *buf = os.str();
  89.     __ErrorMessage( buf );
  90.     delete [] buf;
  91.  
  92.     exit( errnum );
  93. }
  94.