| 580 | } |
| 581 | |
| 582 | inline void set_encoding(cetype_t encoding) { |
| 583 | enc = encoding; |
| 584 | |
| 585 | if (valid) { |
| 586 | // TODO: may longjmp on failure to translate? |
| 587 | const char* translated = Rf_translateCharUTF8(data); |
| 588 | data = Rf_mkCharCE(translated, encoding); |
| 589 | Rcpp_PreciousRelease(token); |
| 590 | token = Rcpp_PreciousPreserve(data); |
| 591 | } else { |
| 592 | data = get_sexp_impl(); |
| 593 | token = Rcpp_PreciousPreserve(data); |
| 594 | valid = true; |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | bool operator<(const Rcpp::String& other) const { |
| 599 | return strcmp(get_cstring(), other.get_cstring()) < 0; |