mmdb_exception.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. /*
  24. * $XConsortium: mmdb_exception.h /main/6 1996/11/01 10:19:24 drk $
  25. *
  26. * Copyright (c) 1993 HAL Computer Systems International, Ltd.
  27. * All rights reserved. Unpublished -- rights reserved under
  28. * the Copyright Laws of the United States. USE OF A COPYRIGHT
  29. * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
  30. * OR DISCLOSURE.
  31. *
  32. * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
  33. * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
  34. * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
  35. * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
  36. * INTERNATIONAL, LTD.
  37. *
  38. * RESTRICTED RIGHTS LEGEND
  39. * Use, duplication, or disclosure by the Government is subject
  40. * to the restrictions as set forth in subparagraph (c)(l)(ii)
  41. * of the Rights in Technical Data and Computer Software clause
  42. * at DFARS 252.227-7013.
  43. *
  44. * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
  45. * 1315 Dell Avenue
  46. * Campbell, CA 95008
  47. *
  48. */
  49. #ifndef _mmdb_exception_h
  50. #define _mmdb_exception_h 1
  51. #include "dti_excs/Exceptions.hh"
  52. #ifdef C_API
  53. #include "utility/c_fstream.h"
  54. #else
  55. #include <fstream>
  56. #include <iostream>
  57. using namespace std;
  58. #endif
  59. #define END_TRY end_try
  60. #include <X11/Xosdefs.h>
  61. #include <errno.h>
  62. #ifdef X_NOT_STDC_ENV
  63. extern int errno;
  64. #endif
  65. class mmdbException : public Exception
  66. {
  67. public:
  68. DECLARE_EXCEPTION(mmdbException, Exception)
  69. virtual ~mmdbException() {};
  70. virtual ostream& asciiOut(ostream&);
  71. friend ostream& operator <<(ostream& out, mmdbException& e) {
  72. return e.asciiOut(out);
  73. }
  74. };
  75. class stringException : public mmdbException
  76. {
  77. protected:
  78. char* msg;
  79. public:
  80. DECLARE_EXCEPTION(stringException, mmdbException)
  81. stringException(char const* m) : msg((char*)m) {};
  82. ~stringException() {};
  83. virtual ostream& asciiOut(ostream&);
  84. };
  85. class formatException : public stringException
  86. {
  87. protected:
  88. public:
  89. DECLARE_EXCEPTION(formatException, stringException)
  90. formatException(char const* m) : stringException(m) {};
  91. ~formatException() {};
  92. };
  93. class intException : public mmdbException
  94. {
  95. protected:
  96. int v_code;
  97. public:
  98. DECLARE_EXCEPTION(intException, mmdbException)
  99. intException(int c) : v_code(c) {};
  100. ~intException() {};
  101. int code() { return v_code; };
  102. virtual ostream& asciiOut(ostream&);
  103. };
  104. class systemException : public intException
  105. {
  106. public:
  107. DECLARE_EXCEPTION(systemException, intException)
  108. systemException(int c) : intException(c) {};
  109. ~systemException() {};
  110. };
  111. class streamException : public intException
  112. {
  113. protected:
  114. public:
  115. DECLARE_EXCEPTION(streamException, intException)
  116. streamException(int c) : intException(c) {};
  117. ~streamException() {};
  118. };
  119. class boundaryException : public mmdbException
  120. {
  121. protected:
  122. long low;
  123. long high;
  124. long mindex;
  125. public:
  126. DECLARE_EXCEPTION(boundaryException, mmdbException)
  127. boundaryException(long l, long h, long i) :
  128. low(l), high(h), mindex(i) {};
  129. ~boundaryException() {};
  130. virtual ostream& asciiOut(ostream&);
  131. };
  132. class beginTransException: public mmdbException
  133. {
  134. public:
  135. DECLARE_EXCEPTION(beginTransException, mmdbException)
  136. beginTransException() {};
  137. ~beginTransException() {};
  138. };
  139. class commitTransException: public mmdbException
  140. {
  141. public:
  142. DECLARE_EXCEPTION(commitTransException, mmdbException)
  143. commitTransException() {};
  144. ~commitTransException() {};
  145. };
  146. class rollbackTransException: public mmdbException
  147. {
  148. public:
  149. DECLARE_EXCEPTION(rollbackTransException, mmdbException)
  150. rollbackTransException() {};
  151. ~rollbackTransException() {};
  152. };
  153. class demoException : public mmdbException
  154. {
  155. protected:
  156. const char* f_path;
  157. const char* f_name;
  158. public:
  159. DECLARE_EXCEPTION(demoException, mmdbException)
  160. demoException(const char* p, const char* n) : f_path(p), f_name(n) {};
  161. virtual ~demoException() {};
  162. const char* path() { return f_path; };
  163. const char* name() { return f_name; };
  164. virtual ostream& asciiOut(ostream& out) {
  165. out << f_path << "\t" << f_name << "\n";
  166. return out;
  167. }
  168. friend ostream& operator <<(ostream& out, demoException& e) {
  169. return e.asciiOut(out);
  170. }
  171. };
  172. #endif