6 #ifndef RCPP_SERIALIZE_HPP 7 #define RCPP_SERIALIZE_HPP 9 #undef HAVE_VISIBILITY_ATTRIBUTE 16 #include <RApiSerializeAPI.h> 18 #include <boost/regex.hpp> 19 #include <boost/algorithm/string.hpp> 22 inline std::string serializeToStr(SEXP
object) {
24 Rcpp::RawVector val = serializeToRaw(
object);
29 for (
size_t i = 0; i < val.size(); i++) {
30 res = res + std::to_string(
int(val[i])) +
"\t";
37 inline SEXP unserializeFromStr(std::string s) {
39 std::vector<std::string> strs;
40 boost::regex e(
"^\\d.+");
41 if (boost::regex_match(s, e)) {
45 Rcpp::RawVector object(strs.size() - 1);
47 for (
size_t i = 0; i < strs.size() - 1; i++) {
48 object[i] =
static_cast<unsigned char>(std::stoi(strs[i]));
51 return unserializeFromRaw(
object);
void split(S &&input, T &&output1, T &&output2, FilterFn filterfn, size_t random_seed=std::time(NULL))