Rcpp Version 1.0.14
Loading...
Searching...
No Matches
exceptions.h
Go to the documentation of this file.
1// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2//
3// exceptions.h: Rcpp R/C++ interface class library -- exceptions
4//
5// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
6// Copyright (C) 2017 Dirk Eddelbuettel, Romain Francois, and James J Balamuta
7//
8// This file is part of Rcpp.
9//
10// Rcpp is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 2 of the License, or
13// (at your option) any later version.
14//
15// Rcpp is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
22
23#ifndef Rcpp__exceptionscpp98__h
24#define Rcpp__exceptionscpp98__h
25
26namespace Rcpp {
27
28#define RCPP_ADVANCED_EXCEPTION_CLASS(__CLASS__, __WHAT__) \
29class __CLASS__ : public std::exception{ \
30 public: \
31 __CLASS__( ) throw() : message( std::string(__WHAT__) + "." ){} \
32 __CLASS__( const std::string& message ) throw() : message( std::string(__WHAT__) + ": " + message + "." ){} \
33 template <typename T1> \
34 __CLASS__(const char* fmt, const T1& arg1) throw() : \
35 message( tfm::format(fmt, arg1 ) ){} \
36 template <typename T1, typename T2> \
37 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2) throw() : \
38 message( tfm::format(fmt, arg1, arg2 ) ){} \
39 template <typename T1, typename T2, typename T3> \
40 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3) throw() : \
41 message( tfm::format(fmt, arg1, arg2, arg3 ) ){} \
42 template <typename T1, typename T2, typename T3, typename T4> \
43 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4) throw() : \
44 message( tfm::format(fmt, arg1, arg2, arg3, arg4 ) ){} \
45 template <typename T1, typename T2, typename T3, typename T4, typename T5> \
46 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5) throw() : \
47 message( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5 ) ){} \
48 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> \
49 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6) throw() : \
50 message( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6 ) ){} \
51 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
52 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7) throw() : \
53 message( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7 ) ){} \
54 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
55 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8) throw() : \
56 message( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 ) ){} \
57 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> \
58 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9) throw() : \
59 message( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 ) ){} \
60 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> \
61 __CLASS__(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9, const T10& arg10) throw() : \
62 message( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 ) ){} \
63 virtual ~__CLASS__() throw(){} \
64 virtual const char* what() const throw() { return message.c_str() ; } \
65 private: \
66 std::string message ; \
67} ; \
68
69// -- Start Rcpp::warning declaration
70
71template <typename T1>
72inline void warning(const char* fmt, const T1& arg1) {
74}
75
76template <typename T1, typename T2>
77inline void warning(const char* fmt, const T1& arg1, const T2& arg2) {
79}
80
81template <typename T1, typename T2, typename T3>
82inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3) {
84}
85
86template <typename T1, typename T2, typename T3, typename T4>
87inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4) {
89}
90
91template <typename T1, typename T2, typename T3, typename T4, typename T5>
92inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5) {
94}
95
96template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
97inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6) {
99}
100
101template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
102inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7) {
104}
105
106template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
107inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8) {
109}
110
111template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
112inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9) {
114}
115
116template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
117inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9, const T10& arg10) {
119}
120
121// -- End Rcpp::warning declaration
122
123// -- Start Rcpp::stop declaration
124
125template <typename T1>
126inline void NORET stop(const char* fmt, const T1& arg1) {
128}
129
130template <typename T1, typename T2>
131inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2) {
133}
134
135template <typename T1, typename T2, typename T3>
136inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3) {
138}
139
140template <typename T1, typename T2, typename T3, typename T4>
141inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4) {
143}
144
145template <typename T1, typename T2, typename T3, typename T4, typename T5>
146inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5) {
148}
149
150template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
151inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6) {
153}
154
155template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
156inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7) {
158}
159
160template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
161inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8) {
163}
164
165template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
166inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9) {
168}
169
170template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
171inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9, const T10& arg10) {
173}
174
175// -- End Rcpp::stop declaration
176} // namespace Rcpp
177#endif
#define NORET
Definition headers.h:82
Rcpp API.
Definition algo.h:28
void NORET stop(const std::string &message)
Definition exceptions.h:117
T as(SEXP x)
Definition as.h:151
void warning(const std::string &message)
Definition exceptions.h:113
void format(std::ostream &out, const char *fmt)
Definition tinyformat.h:996