Skip to content

Commit b4ed19f

Browse files
committed
Merge pull request #245 from RcppCore/feature/warning-function
Add Rcpp::warning function as wrapper for Rf_warning
2 parents 5439594 + 54ca8c7 commit b4ed19f

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-02-03 JJ Allaire <jj@rstudio.org>
2+
3+
* inst/include/Rcpp/exceptions.h: Add Rcpp::warning function as
4+
wrapper for Rf_warning
5+
16
2014-02-03 JJ Allaire <jj@rstudio.org>
27

38
* inst/include/Rcpp/XPtr.h: Improvements to XPtr including new

inst/NEWS.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
\itemize{
99
\item Defining an error handler for tinyformat prevents \code{assert()}
1010
from spilling.
11+
\item Add Rcpp::warning function as wrapper for Rf_warning.
1112
\item Improvements to XPtr including new \code{checked_get} and
1213
\code{release} functions as well as improved behavior (throw an
1314
exception rather than crash) when a NULL external pointer is

inst/include/Rcpp/exceptions.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,61 @@ std::string demangle( const std::string& name) ;
192192
#define DEMANGLE(__TYPE__) demangle( typeid(__TYPE__).name() ).c_str()
193193

194194
namespace Rcpp{
195+
196+
inline void warning(const std::string& message) {
197+
Rf_warning(message.c_str());
198+
}
199+
200+
template <typename T1>
201+
inline void warning(const char* fmt, const T1& arg1) {
202+
Rf_warning( tfm::format(fmt, arg1 ).c_str() );
203+
}
204+
205+
template <typename T1, typename T2>
206+
inline void warning(const char* fmt, const T1& arg1, const T2& arg2) {
207+
Rf_warning( tfm::format(fmt, arg1, arg2 ).c_str() );
208+
}
209+
210+
template <typename T1, typename T2, typename T3>
211+
inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3) {
212+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3).c_str() );
213+
}
214+
215+
template <typename T1, typename T2, typename T3, typename T4>
216+
inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4) {
217+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4).c_str() );
218+
}
219+
220+
template <typename T1, typename T2, typename T3, typename T4, typename T5>
221+
inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5) {
222+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5).c_str() );
223+
}
224+
225+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
226+
inline void warning(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6) {
227+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6).c_str() );
228+
}
229+
230+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
231+
inline 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) {
232+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7).c_str() );
233+
}
234+
235+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
236+
inline 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) {
237+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8).c_str() );
238+
}
239+
240+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
241+
inline 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) {
242+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9).c_str() );
243+
}
244+
245+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
246+
inline 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) {
247+
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10).c_str() );
248+
}
249+
195250
inline void stop(const std::string& message) {
196251
throw Rcpp::exception(message.c_str());
197252
}

0 commit comments

Comments
 (0)