[Rcpp-devel] convert std::string to Rcpp::RawVector
Koert Kuipers
Koert.Kuipers at diamondnotch.com
Thu Oct 7 22:04:06 CEST 2010
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);
return y;
}
How do i do this with Rcpp? Say i want to return a Rcpp::RawVector?
Thanks,
Koert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101007/c5ee9427/attachment.htm>
More information about the Rcpp-devel
mailing list