home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IBEXCTXT.H < prev    next >
Text File  |  1993-09-22  |  4KB  |  88 lines

  1. /*******************************************************************************
  2. *                                                                              *
  3. * COPYRIGHT:                                                                   *
  4. *   IBM C/C++ Tools Version 2.01 - Collection Class Library                    *
  5. *   Licensed Materials - Property of IBM                                       *
  6. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  7. *   All Rights Reserved                                                        *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  10. *                                                                              *
  11. *******************************************************************************/
  12. #ifndef _IBEXCTXT_H
  13. #define _IBEXCTXT_H
  14.  
  15. #include <ibexcdef.h>
  16. #include <imsgtext.hpp>
  17.  
  18. /* The following is the ExceptionText class used to load a text
  19.  * string from the resource file.
  20.  */
  21.  
  22. class IBExceptionText  {
  23. /*******************************************************************************
  24. *  This class loads exception text from a resource file.                       *
  25. *                                                                              *
  26. *  Typically an instance of this class is created when an error condition has  *
  27. *  been detected, and an exception is going to be thrown.  The exception text  *
  28. *  can be used to construct an IException subclass instance.                   *
  29. *                                                                              *
  30. * EXAMPLE:                                                                     *
  31. *                                                                              *
  32. *    int  bSuccess = someFunction();                                           *
  33. *    if (!bSuccess)                                                            *
  34. *    {                                                                         *
  35. *       IBExceptionText myTxt(IC_PARTICULAR_ERROR);                            *
  36. *       IInvalidRequest exc(myTxt, IC_SOMEFUNCTIONFAIL, 0);                    *
  37. *       ITHROW(exc);                                                           *
  38. *    }                                                                         *
  39. *                                                                              *
  40. *******************************************************************************/
  41. public:
  42.   IBExceptionText  ( unsigned long resourceId );
  43.  
  44.   ~IBExceptionText ( );
  45.  
  46. /*-------------------------------- ACCESSORS -----------------------------------
  47. | The following conversion operator and function provide means of getting the  |
  48. | exception text from instances of this class:                                 |
  49. |   const char* - Returns the exception text.                                  |
  50. |   text        - Returns the exception text.                                  |
  51. ------------------------------------------------------------------------------*/
  52.   operator const char*  () const;
  53.  
  54. const char*
  55.   text ( ) const;
  56.  
  57. private:
  58. /*--------------------------------- PRIVATE ----------------------------------*/
  59. IMessageText  * ivMsgTxt;
  60.  
  61. };
  62.  
  63. inline IBExceptionText::~IBExceptionText ( )
  64. /****************************************************************/
  65. /*                                                              */
  66. /****************************************************************/
  67. {
  68.   delete ivMsgTxt;
  69. }
  70.  
  71. inline IBExceptionText::operator const char* () const
  72. /****************************************************************/
  73. /*                                                              */
  74. /****************************************************************/
  75. {
  76.  return ivMsgTxt->text();
  77. }
  78.  
  79. inline const char* IBExceptionText::text ( ) const
  80. /****************************************************************/
  81. /*                                                              */
  82. /****************************************************************/
  83. {
  84.  return ivMsgTxt->text();
  85. }
  86.  
  87. #endif
  88.