home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tlx501.zip / SRC / XIOS.CPP < prev    next >
C/C++ Source or Header  |  1996-07-08  |  2KB  |  69 lines

  1. /****************************************************************************
  2.     $Id: xios.cpp 501.0 1995/03/07 12:26:30 RON Exp $
  3.  
  4.     Copyright (c) 1991-95 Tarma Software Research. All rights reserved.
  5.  
  6.     Project:    Tarma Library for C++ V5.0
  7.     Author:     Ron van der Wal
  8.  
  9.     Implementation of class TLXIos.
  10.  
  11.     $Log: xios.cpp $
  12.     Revision 501.0  1995/03/07 12:26:30  RON
  13.     Updated for TLX 5.01
  14.     Revision 1.3  1995/01/31 16:30:38  RON
  15.     Update for release 012
  16.     Added partial support for SunPro C++ compiler
  17.     Revision 1.2  1995/01/06  15:59:07  ron
  18.     Corrected Revision keyword
  19.  
  20.     Revision 1.1  1994/11/16  15:47:07  ron
  21.     Initial revision
  22.  
  23. ****************************************************************************/
  24.  
  25. #include <tlx\501\_build.h>
  26.  
  27. TLX_MODULE_INFO("$Revision: 501.0 $");
  28.  
  29. #include <iostream.h>
  30. #include <stdio.h>              // For sprintf()
  31. #include <tlx\501\except.h>
  32.  
  33. /*-------------------------------------------------------------------------*/
  34.     TLXIos::TLXIos(const TLXLocus &aLocus, const ios &s)
  35.  
  36. /*  Constructor. Initializes the data members and base class.
  37. ---------------------------------------------------------------------------*/
  38. : TLException(aLocus), mErrState(CONSTCAST(ios &,s).rdstate())
  39. {
  40.     // Note: the previous CONSTCAST should not have been necessary if all
  41.     // implementations would have declared ios::rdstate() as const, which it
  42.     // really is...
  43. }
  44.  
  45. /*-------------------------------------------------------------------------*/
  46.     const char *TLXIos::Description() const
  47.  
  48. /*  Builds a description of the exception and returns a pointer to it.
  49.     The exception is built in the static buffer provided by class
  50.     TLException.
  51. ---------------------------------------------------------------------------*/
  52. {
  53.     const char *iostate;
  54.  
  55.     if (mErrState == 0)
  56.         iostate = "No error";
  57.     if (mErrState & ios::eofbit)
  58.     iostate = "EOF";
  59.     else if (mErrState & ios::badbit)
  60.     iostate = "Bad state";
  61.     else if (mErrState & ios::failbit)
  62.     iostate = "Failed";
  63.     else
  64.     iostate = "Unknown";
  65.  
  66.     sprintf(sBuffer, "IOStream error: %s", iostate);
  67.     return sBuffer;
  68. }
  69.