Re: [Rcpp-devel] convert std::string to Rcpp::RawVector

2010-10-08 Thread Romain Francois
Le 07/10/10 22:04, Koert Kuipers a écrit : Hello all, I need to convert a std::string to a RAWSXP. I think i know hot do to this without Rcpp. It goes something like this (i haven't tested this): SEXP stringToRaw(std::string x) { SEXP y; PROTECT(y = allocVector(RAWSXP, x.length())); memcpy(RAW(y

[Rcpp-devel] convert std::string to Rcpp::RawVector

2010-10-07 Thread Koert Kuipers
Hello all, I need to convert a std::string to a RAWSXP. I think i know hot do to this without Rcpp. It goes something like this (i haven't tested this): SEXP stringToRaw(std::string x) { SEXP y; PROTECT(y = allocVector(RAWSXP, x.length())); memcpy(RAW(y), x.data(), x.length()); UNPROTECT(1