Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_CWrapperSupport_Cpp.hpp
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
14#include "Teuchos_StandardCatchMacros.hpp"
15#include "Teuchos_FancyOStream.hpp"
16
17
21namespace Teuchos {
22
23
27class TEUCHOSCORE_LIB_DLL_EXPORT CWrapperErrorHandling {
28public:
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.
Smart reference counting pointer class for automatic garbage collection.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...