Any pointer on how to cast std::string into cpp11::writables::raws

Building a BigQuery Storage Client.

Using message.SerializeToString gets me a std::string but I actually want that to remains in raws format instead character when returning to R.

See here : https://github.com/meztez/bigrquerystorage/blob/77102bd8f34080869580e174e81e49875a4833a1/src/bqs.cpp#L152

Willl keep reading doc, but if someone any has pointer. That would be great.

1 Like

Or a uint_8t array into raws

cpp11::raws to_raw(const std::string input) {
  cpp11::writable::raws rv(input.size());
  for(unsigned long i=0; i<input.size(); i++) {
    rv[i] = input.c_str()[i];
  }
  return rv;
}

I ended up using Rcpp instead and switched to a faster algo

// append std::string at the end of a std::vector<uint8_t> vector
void to_raw(const std::string input, std::vector<uint8_t>* output) {
  output->insert(output->end(), input.begin(), input.end());
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.