2
0

TTFile.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: TTFile.h /main/3 1995/11/03 12:33:57 rswiston $ */
  24. /*******************************************************************
  25. ** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
  26. ** All rights are reserved. Copying or other reproduction of this
  27. ** program except for archival purposes is prohibited without prior
  28. ** written consent of Hewlett-Packard Company.
  29. ********************************************************************
  30. ****************************<+>*************************************/
  31. #ifndef _TTFILE_H_
  32. #define _TTFILE_H_
  33. #include "cstring.h"
  34. #include "Tt/tt_c.h"
  35. #ifdef HAS_EXCEPTIONS
  36. #define Throw(ex) throw ex
  37. #define Try try
  38. #define Catch(type,file) catch(type ex)
  39. #else
  40. #define Throw(ex) { ex; return; }
  41. #define Try
  42. #define Catch(type,file) if (file->ttFileOpFailed())
  43. #endif
  44. class TTFile : public CString {
  45. public:
  46. TTFile () : status(TT_OK) {}
  47. TTFile (const CString &, const CString &);
  48. TTFile (const TTFile &);
  49. ~TTFile();
  50. TTFile & operator=(const TTFile &);
  51. #ifdef HAS_EXCEPTIONS
  52. class TT_Exception {
  53. public:
  54. TT_Exception (char * str)
  55. { cerr << tt_status_message(tt_pointer_error(str)); }
  56. ~TT_Exception() {}
  57. friend ostream & operator<< (ostream &, TTFile &);
  58. };
  59. #else
  60. void TT_Exception (char *);
  61. friend std::ostream & operator<< (std::ostream &, TTFile &);
  62. #endif
  63. int ttFileOpFailed () { return status != TT_OK; }
  64. Tt_status getStatus() { return status; }
  65. private:
  66. Tt_status status;
  67. };
  68. #endif