| 44 | } |
| 45 | |
| 46 | inline const char* check_single_string(SEXP x) { |
| 47 | if (TYPEOF(x) == CHARSXP) return CHAR(x); // #nocov start |
| 48 | if (! ::Rf_isString(x) || Rf_length(x) != 1) { |
| 49 | const char* fmt = "Expecting a single string value: " |
| 50 | "[type=%s; extent=%i]."; |
| 51 | throw ::Rcpp::not_compatible(fmt, |
| 52 | Rf_type2char(TYPEOF(x)), |
| 53 | Rf_length(x)); |
| 54 | } // #nocov end |
| 55 | |
| 56 | return CHAR(STRING_ELT(::Rcpp::r_cast<STRSXP>(x), 0)); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | template <typename T> T as_string(SEXP x, Rcpp::traits::true_type) { |