25 #include <Rcpp/internal/Exporter.h>
32 if (::Rf_length(x) != 1) {
33 const char* fmt =
"Expecting a single value: [extent=%i].";
34 throw ::Rcpp::not_compatible(fmt, ::Rf_length(x));
38 typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE;
39 T res = caster<STORAGE,T>(*r_vector_start<RTYPE>(y));
44 return primitive_as<T>(x);
48 if (TYPEOF(x) == CHARSXP)
return CHAR(x);
49 if (! ::Rf_isString(x) || Rf_length(x) != 1) {
50 const char* fmt =
"Expecting a single string value: "
51 "[type=%s; extent=%i].";
52 throw ::Rcpp::not_compatible(fmt,
53 Rf_type2char(TYPEOF(x)),
57 return CHAR(STRING_ELT(::Rcpp::r_cast<STRSXP>(x), 0));
63 return std::wstring(y, y+strlen(y));
75 if (! ::Rf_isString(x)) {
76 const char* fmt =
"Expecting a single string value: "
77 "[type=%s; extent=%i].";
78 throw ::Rcpp::not_compatible(fmt,
79 Rf_type2char(TYPEOF(x)),
82 return STRING_ELT(::Rcpp::r_cast<STRSXP>(x), 0);
87 ::Rcpp::traits::Exporter<T> exporter(x);
89 return exporter.get();
105 return as_module_object<typename traits::un_pointer<T>::type>(x);
110 T* obj = as_module_object<T>(x);
117 KLASS* obj = as_module_object<KLASS>(x);
124 KLASS* obj = as_module_object<KLASS>(x);
125 return const_cast<T
>(*obj);
130 return T(primitive_as<int>(x));
151 template <
typename T> T
as(SEXP x) {
159 template <
typename T>
161 return as< typename traits::remove_const_and_reference<T>::type >(x);
164 template<>
inline SEXP
as(SEXP x) {
return x; }
#define RCPP_DEBUG_1(fmt, MSG)
#define DEMANGLE(__TYPE__)
T as(SEXP x, ::Rcpp::traits::r_type_primitive_tag)
void * as_module_object_internal(SEXP obj)
const char * check_single_string(SEXP x)
object< T > as_module_object(SEXP x)
T as_string(SEXP x, Rcpp::traits::true_type)
traits::remove_const_and_reference< T >::type bare_as(SEXP x)
remove_const< typename remove_reference< T >::type >::type type