Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_CWrapperSupport_Cpp.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_C_WRAPPER_SUPPORT_CPP_HPP
11 #define TEUCHOS_C_WRAPPER_SUPPORT_CPP_HPP
12 
13 
15 #include "Teuchos_FancyOStream.hpp"
16 
17 
21 namespace Teuchos {
22 
23 
28 public:
29 
34  static void setPrintErrorOStream(const RCP<FancyOStream> &errorOStream);
35 
40  static RCP<FancyOStream> getPrintErrorOStream();
41 
47  static void setShowStackTraceOnException(const bool showStrackTraceOnException);
48 
51  static bool getShowStackTraceOnException();
52 
53 
54 }; // class CWrapperErrorHandling
55 
56 
57 } // Teuchos
58 
59 
60 
65 #define TEUCHOS_CWRAPPER_TRY(IERR) \
66  TEUCHOS_TEST_FOR_EXCEPT((IERR) == 0); \
67  (*(IERR)) = 0; \
68  bool cwrapper_try_success = true; \
69  try
70 // Above: We must set *ierr = 0 in case a return statement will return the
71 // value.
72 
73 
78 #define TEUCHOS_CWRAPPER_CATCH_ERROR_CODE(IERR) \
79  TEUCHOS_STANDARD_CATCH_STATEMENTS_IMPL( \
80  true, *Teuchos::CWrapperErrorHandling::getPrintErrorOStream(), \
81  Teuchos::CWrapperErrorHandling::getShowStackTraceOnException(), \
82  cwrapper_try_success ); \
83  if (!cwrapper_try_success) { (*(IERR)) = -1; }
84 // Above: We make sure and set the error code in case there is a failure.
85 
86 
87 
95 #define TEUCHOS_CWRAPPER_SET_ERROR_CODE(IERR, IERR_VALUE) \
96  if ((IERR)) { \
97  (*(IERR)) = (IERR_VALUE); \
98  }
99 
100 
101 #endif // TEUCHOS_C_WRAPPER_SUPPORT_CPP_HPP
Static C Wrapper Error Handling Policy Class.
#define TEUCHOSCORE_LIB_DLL_EXPORT
Smart reference counting pointer class for automatic garbage collection.