Rcpp Version 1.0.7
String.h
Go to the documentation of this file.
1 
2 // String.h: Rcpp R/C++ interface class library -- single string
3 //
4 // Copyright (C) 2012 - 2020 Dirk Eddelbuettel and Romain Francois
5 // Copyright (C) 2021 Dirk Eddelbuettel, Romain Francois and IƱaki Ucar
6 //
7 // This file is part of Rcpp.
8 //
9 // Rcpp is free software: you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // Rcpp is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21 
22 #ifndef Rcpp__String_h
23 #define Rcpp__String_h
24 
25 #ifndef RCPP_STRING_DEBUG_LEVEL
26 #define RCPP_STRING_DEBUG_LEVEL 0
27 #endif
28 
29 
30 #if RCPP_STRING_DEBUG_LEVEL > 0
31  #define RCPP_STRING_DEBUG_FORMAT "%40s:%4d "
32  #define RCPP_STRING_DEBUG(MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT "%s\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG);
33  #define RCPP_STRING_DEBUG_1(fmt, MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG);
34  #define RCPP_STRING_DEBUG_2(fmt, M1, M2) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2);
35  #define RCPP_STRING_DEBUG_3(fmt, M1, M2, M3) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3);
36 #else
37  #define RCPP_STRING_DEBUG(MSG)
38  #define RCPP_STRING_DEBUG_1(fmt, MSG)
39  #define RCPP_STRING_DEBUG_2(fmt, M1, M2)
40  #define RCPP_STRING_DEBUG_3(fmt, M1, M2, M3)
41 #endif
42 
43 namespace Rcpp {
44 
49  class String {
50  public:
53 
55  String(): data(Rf_mkCharCE("", CE_UTF8)), token(R_NilValue), buffer(), valid(true), buffer_ready(true), enc(CE_UTF8) {
57  RCPP_STRING_DEBUG("String()");
58  }
59 
61  String(const String& other) : data(other.get_sexp()), token(R_NilValue), valid(true), buffer_ready(false), enc(Rf_getCharCE(other.get_sexp())) {
63  RCPP_STRING_DEBUG("String(const String&)");
64  }
65 
67  String(SEXP charsxp) : data(R_NilValue), token(R_NilValue) {
68  if (TYPEOF(charsxp) == STRSXP) {
69  data = STRING_ELT(charsxp, 0);
70  } else if (TYPEOF(charsxp) == CHARSXP) {
71  data = charsxp;
72  }
73 
74  if (::Rf_isString(data) && ::Rf_length(data) != 1) {
75  const char* fmt = "Expecting a single string value: "
76  "[type=%s; extent=%i].";
77  throw ::Rcpp::not_compatible(fmt,
78  Rf_type2char(TYPEOF(data)),
79  ::Rf_length(data));
80  }
81 
82  valid = true;
83  buffer_ready = false;
84  enc = Rf_getCharCE(data);
86  RCPP_STRING_DEBUG("String(SEXP)");
87  }
88 
90  String(const StringProxy& proxy): data(proxy.get()), token(R_NilValue), valid(true), buffer_ready(false), enc(Rf_getCharCE(proxy.get())) {
92  RCPP_STRING_DEBUG("String(const StringProxy&)");
93  }
94 
95  String(const StringProxy& proxy, cetype_t enc): data(proxy.get()), token(R_NilValue), valid(true), buffer_ready(false) {
98  RCPP_STRING_DEBUG("String(const StringProxy&, cetype_t)");
99  }
100 
102  String(const const_StringProxy& proxy): data(proxy.get()), token(R_NilValue), valid(true), buffer_ready(false), enc(Rf_getCharCE(proxy.get())) {
104  RCPP_STRING_DEBUG("String(const const_StringProxy&)");
105  }
106 
107  String(const const_StringProxy& proxy, cetype_t enc): data(proxy.get()), token(R_NilValue), valid(true), buffer_ready(false) {
109  set_encoding(enc);
110  RCPP_STRING_DEBUG("String(const const_StringProxy&, cetype_t)");
111  }
112 
114  String(const std::string& s, cetype_t enc = CE_UTF8) : buffer(s), valid(false), buffer_ready(true), enc(enc) {
115  data = R_NilValue;
116  token = R_NilValue;
117  RCPP_STRING_DEBUG("String(const std::string&, cetype_t)");
118  }
119 
120  String(const std::wstring& s, cetype_t enc = CE_UTF8) : data(internal::make_charsexp(s)), token(R_NilValue), valid(true), buffer_ready(false), enc(enc) {
122  RCPP_STRING_DEBUG("String(const std::wstring&, cetype_t)");
123  }
124 
126  String(const char* s, cetype_t enc = CE_UTF8) : buffer(s), valid(false), buffer_ready(true), enc(enc) {
127  data = R_NilValue;
128  token = R_NilValue;
129  RCPP_STRING_DEBUG("String(const char*, cetype_t)");
130  }
131 
132  String(const wchar_t* s, cetype_t enc = CE_UTF8) : data(internal::make_charsexp(s)), token(R_NilValue), valid(true), buffer_ready(false), enc(enc) {
134  RCPP_STRING_DEBUG("String(const wchar_t* s, cetype_t)");
135  }
136 
138  String(int x) : data(internal::r_coerce<INTSXP,STRSXP>(x)), token(R_NilValue), valid(true), buffer_ready(false), enc(CE_UTF8) {
140  }
141  String(double x) : data(internal::r_coerce<REALSXP,STRSXP>(x)), token(R_NilValue), valid(true), buffer_ready(false), enc(CE_UTF8) {
143  }
144  String(bool x) : data(internal::r_coerce<LGLSXP,STRSXP>(x)), token(R_NilValue), valid(true) , buffer_ready(false), enc(CE_UTF8) {
146  }
147  String(Rcomplex x) : data(internal::r_coerce<CPLXSXP,STRSXP>(x)), token(R_NilValue), valid(true), buffer_ready(false), enc(CE_UTF8) {
149  }
150  String(Rbyte x) : data(internal::r_coerce<RAWSXP,STRSXP>(x)), token(R_NilValue), valid(true), buffer_ready(false), enc(CE_UTF8) {
152  }
153 
156  data = R_NilValue;
157  token = R_NilValue;
158  }
159 
160 
161  inline String& operator=(int x) {
162  data = internal::r_coerce<INTSXP, STRSXP>(x);
165  valid = true;
166  buffer_ready = false;
167  return *this;
168  }
169  inline String& operator=(double x) {
170  data = internal::r_coerce<REALSXP, STRSXP>(x);
173  valid = true;
174  buffer_ready = false;
175  return *this;
176  }
177  inline String& operator=(Rbyte x) {
178  data = internal::r_coerce<RAWSXP, STRSXP>(x);
181  valid = true;
182  buffer_ready = false;
183  return *this;
184  }
185  inline String& operator=(bool x) {
186  data = internal::r_coerce<LGLSXP, STRSXP>(x);
189  valid = true;
190  buffer_ready = false;
191  return *this;
192  }
193  inline String& operator=(Rcomplex x) {
194  data = internal::r_coerce<CPLXSXP, STRSXP>(x);
197  valid = true;
198  buffer_ready = false;
199  return *this;
200  }
201  inline String& operator=(SEXP x) {
202  if (data != x) {
203  data = x;
206  }
207  valid = true;
208  buffer_ready = false;
209  return *this;
210  }
211  inline String& operator=(const StringProxy& proxy) {
212  SEXP x = proxy.get();
213  if (data != x) {
214  data = x;
217  }
218  valid = true;
219  buffer_ready = false;
220  return *this;
221  }
222  inline String& operator=(const String& other) {
223  SEXP x = other.get_sexp();
224  if (data != x) {
225  data = x;
228  }
229  valid = true;
230  buffer_ready = false;
231  return *this;
232  }
233  inline String& operator=(const std::string& s) {
234  buffer = s;
235  valid = false;
236  buffer_ready = true;
237  return *this;
238  }
239  inline String& operator=(const char* s) {
240  buffer = s;
241  valid = false;
242  buffer_ready = true;
243  return *this;
244  }
245 
246  private:
247  template <typename T>
248  inline String& assign_wide_string(const T& s) {
249  data = internal::make_charsexp(s);
252  valid = true;
253  buffer_ready = false;
254  return *this;
255  }
256 
257  public:
258  inline String& operator=(const std::wstring& s) { return assign_wide_string(s); }
259  inline String& operator=(const wchar_t* s) { return assign_wide_string(s); }
260 
261  inline String& operator+=(const std::string& s) {
262  RCPP_STRING_DEBUG("String::operator+=(std::string)");
263  if (is_na()) return *this;
264  setBuffer(); buffer += s; valid = false;
265  return *this;
266  }
267 
268  inline String& operator+=(const char* s) {
269  RCPP_STRING_DEBUG("String::operator+=(const char*)");
270  if (is_na()) return *this;
271  setBuffer(); buffer += s; valid = false;
272  return *this;
273  }
274  private:
275  template <typename T>
276  inline String& append_wide_string(const T& s) {
277  RCPP_STRING_DEBUG_1("String::operator+=(%s)", DEMANGLE(T));
278  setData();
279  if (is_na()) return *this;
280  const char* buf = CHAR(data);
281  std::wstring tmp(buf, buf + strlen(buf));
282  tmp += s;
283  data = internal::make_charsexp(tmp);
286  valid = true;
287  buffer_ready = false;
288  return *this;
289  }
290 
291  public:
292 
293  inline String& operator+=(const std::wstring& s) { return append_wide_string(s); }
294  inline String& operator+=(const wchar_t* s) { return append_wide_string(s); }
295 
296  inline String& operator+=(const String& other) {
297  RCPP_STRING_DEBUG("String::operator+=(const char*)");
298  if (is_na()) return *this;
299  if (other.is_na()) {
300  data = NA_STRING;
303  valid = true;
304  buffer_ready = false;
305  return *this;
306  }
307  setBuffer(); buffer += other; valid = false;
308  return *this;
309  }
310  inline String& operator+=(const StringProxy& proxy) {
311  RCPP_STRING_DEBUG("String::operator+=(const StringProxy&)");
312  if (is_na()) return *this;
313  SEXP proxy_sexp = proxy;
314  if (proxy_sexp == NA_STRING) {
315  data = NA_STRING;
318  valid = true;
319  buffer_ready = false;
320  return *this;
321  }
322  setBuffer(); buffer += CHAR(proxy_sexp); valid = false;
323  return *this;
324  }
325  inline String& operator+=(const const_StringProxy& proxy) {
326  RCPP_STRING_DEBUG("String::operator+=(const StringProxy&)");
327  if (is_na()) return *this;
328  SEXP proxy_sexp = proxy;
329  if (proxy_sexp == NA_STRING) {
330  data = NA_STRING;
333  valid = true;
334  buffer_ready = false;
335  return *this;
336  }
337  setBuffer(); buffer += CHAR(proxy_sexp); valid = false;
338  return *this;
339  }
340  inline String& operator+=(SEXP x) {
341  RCPP_STRING_DEBUG("String::operator+=(SEXP)");
342  if (is_na()) return *this;
343  if (x == NA_STRING) {
344  data = NA_STRING;
347  valid = true;
348  buffer_ready = false;
349  return *this;
350  }
351  setBuffer(); buffer += CHAR(x); valid = false;
352  return *this;
353  }
354  // inline String& operator+=(int x ) { data += char_nocheck(internal::r_coerce<INTSXP ,STRSXP>(x)); return *this; }
355  // inline String& operator+=(double x ) { data += char_nocheck(internal::r_coerce<REALSXP,STRSXP>(x)); return *this; }
356  // inline String& operator+=(Rbyte x ) { data += char_nocheck(internal::r_coerce<RAWSXP ,STRSXP>(x)); return *this; }
357  // inline String& operator+=(bool x ) { data += char_nocheck(internal::r_coerce<LGLSXP ,STRSXP>(x)); return *this; }
358  // inline String& operator+=(Rcomplex x) { data += char_nocheck(internal::r_coerce<CPLXSXP,STRSXP>(x)); return *this; }
359 
360 
361  inline String& replace_first(const char* s, const char* news) {
362  RCPP_STRING_DEBUG_2("String::replace_first(const char* = '%s' , const char* = '%s')", s, news);
363  if (is_na()) return *this;
364  setBuffer();
365  std::string s2 = std::string(s);
366  size_t index = std::distance(buffer.begin(), std::search(buffer.begin(), buffer.end(), s2.begin(), s2.end()));
367  if (index != std::string::npos) buffer.replace(index, strlen(s), news);
368  valid = false;
369  return *this;
370  }
371  inline String& replace_first(const Rcpp::String& s, const char* news) {
372  // replace NA -> do nothing
373  if (s.is_na()) return *this;
374  return replace_first(s.get_cstring(), news);
375  }
376  inline String& replace_first(const char* s, const Rcpp::String& news) {
377  // replace NA -> do nothing
378  if (news.is_na()) return *this;
379  return replace_first(s, news.get_cstring());
380  }
381  inline String& replace_first(const Rcpp::String& s, const Rcpp::String& news) {
382  // replace NA -> do nothing
383  if (s.is_na() || news.is_na()) return *this;
384  return replace_first(s.get_cstring(), news.get_cstring());
385  }
386 
387  inline String& replace_last(const char* s, const char* news) {
388  RCPP_STRING_DEBUG_2("String::replace_last(const char* = '%s' , const char* = '%s')", s, news);
389  if (is_na()) return *this;
390  setBuffer();
391  std::string s2 = std::string(s);
392  size_t index = std::distance(buffer.begin(), std::find_end(buffer.begin(), buffer.end(), s2.begin(), s2.end()));
393  if (index != std::string::npos) buffer.replace(index, strlen(s), news);
394  valid = false;
395  return *this;
396  }
397  inline String& replace_last(const Rcpp::String& s, const char* news) {
398  // replace NA -> do nothing
399  if (s.is_na()) return *this;
400  return replace_last(s.get_cstring(), news);
401  }
402  inline String& replace_last(const char* s, const Rcpp::String& news) {
403  // replace NA -> do nothing
404  if (news.is_na()) return *this;
405  return replace_last(s, news.get_cstring());
406  }
407  inline String& replace_last(const Rcpp::String& s, const Rcpp::String& news) {
408  // replace NA -> do nothing
409  if (s.is_na() || news.is_na()) return *this;
410  return replace_last(s.get_cstring(), news.get_cstring());
411  }
412 
413 
414  inline String& replace_all(const char* s, const char* news) {
415  RCPP_STRING_DEBUG_2("String::replace_all(const char* = '%s' , const char* = '%s')", s, news);
416  if (is_na()) return *this;
417  setBuffer();
418  std::string s2 = std::string(s);
419  std::string::iterator iter = buffer.begin();
420  while(true) {
421  iter = std::search(iter, buffer.end(), s2.begin(), s2.end());
422  if (iter == buffer.end()) break;
423  size_t index = std::distance(buffer.begin(), iter);
424  if (index != std::string::npos) buffer.replace(index, strlen(s), news);
425  }
426  valid = false;
427  return *this;
428  }
429 
430  template <typename LHS, typename RHS>
431  inline String& replace_all(const LHS& s, const RHS& news) {
432  return replace_all(String(s), String(news));
433  }
434 
435  inline String& replace_all(const Rcpp::String& s, const char* news) {
436  // replace NA -> do nothing
437  if (s.is_na()) return *this;
438  return replace_all(s.get_cstring(), news);
439  }
440  inline String& replace_all(const char* s, const Rcpp::String& news) {
441  // replace NA -> do nothing
442  if (news.is_na()) return *this;
443  return replace_all(s, news.get_cstring());
444  }
445  inline String& replace_all(const Rcpp::String& s, const Rcpp::String& news) {
446  // replace NA -> do nothing
447  if (s.is_na() || news.is_na()) return *this;
448  return replace_all(s.get_cstring(), news.get_cstring());
449  }
450 
451  inline String& push_back(const char* s) {
452  if (is_na()) return *this;
453  setBuffer(); valid = false; buffer += s;
454  return *this;
455  }
456  inline String& push_back(const std::string& s) {
457  return push_back(s.c_str());
458  }
459  inline String& push_back(const Rcpp::String& s) {
460  if (is_na()) return *this;
461  if (s.is_na()) { set_na(); return *this; }
462  return push_back(s.get_cstring());
463  }
464 
465  inline String& push_front(const char* s) {
466  if (is_na()) return *this;
467  setBuffer(); valid = false; buffer = s + buffer;
468  return *this;
469  }
470  inline String& push_front(const std::string& s) {
471  return push_front(s.c_str());
472  }
473  inline String& push_front(const Rcpp::String& s) {
474  if (is_na()) return *this;
475  if (s.is_na()) { set_na(); return *this; }
476  return push_front(s.get_cstring());
477  }
478 
479 
480  inline void set_na() {
481  data = NA_STRING;
484  valid = true;
485  buffer_ready = false;
486  }
487 
488 
489  inline SEXP get_sexp_impl() const {
490 
491  // workaround for h5 package (currently deprecated so updates
492  // to CRAN may not be timely)
493 #ifdef __H5Cpp_H
494  return Rf_mkCharCE(buffer.c_str(), enc);
495 #else
496  if (buffer.find('\0') != std::string::npos)
497  throw embedded_nul_in_string();
498  return Rf_mkCharLenCE(buffer.c_str(), buffer.size(), enc);
499 #endif
500  }
501 
502  inline SEXP get_sexp() const {
503  RCPP_STRING_DEBUG_1("String::get_sexp const (valid = %d) ", valid);
504  return valid ? data : get_sexp_impl();
505  }
506 
507  inline SEXP get_sexp() {
508  RCPP_STRING_DEBUG_1("String::get_sexp (valid = %d) ", valid);
509  setData(); return data;
510  }
511 
512  inline operator std::string() const {
513  return get_cstring();
514  }
515 
516  inline operator std::wstring() const {
517  const char* s = get_cstring();
518  return std::wstring(s, s + strlen(s));
519  }
520 
521  inline const char* get_cstring() const {
522  return buffer_ready ? buffer.c_str() : CHAR(data);
523  }
524 
525  inline cetype_t get_encoding() const {
526  return enc;
527  }
528 
529  inline void set_encoding(cetype_t encoding) {
530  enc = encoding;
531 
532  if (valid) {
533  // TODO: may longjmp on failure to translate?
534  const char* translated = Rf_translateCharUTF8(data);
535  data = Rf_mkCharCE(translated, encoding);
538  } else {
539  data = get_sexp_impl();
541  valid = true;
542  }
543  }
544 
545  bool operator<(const Rcpp::String& other) const {
546  return strcmp(get_cstring(), other.get_cstring()) < 0;
547  }
548 
549  bool operator==(const Rcpp::String& other) const {
550  return get_sexp() == other.get_sexp();
551  }
552  bool operator!=(const Rcpp::String& other) const {
553  return get_sexp() != other.get_sexp();
554  }
555 
556  bool operator==(const StringProxy& other) const {
557  return get_sexp() == other.get();
558  }
559 
560  bool operator!=(const StringProxy& other) const {
561  return get_sexp() != other.get();
562  }
563 
564  bool operator==(const const_StringProxy& other) const {
565  return get_sexp() == other.get();
566  }
567 
568  bool operator!=(const const_StringProxy& other) const {
569  return get_sexp() != other.get();
570  }
571 
572  bool operator>(const Rcpp::String& other) const {
573  return strcmp(get_cstring(), other.get_cstring()) > 0;
574  }
575 
576  bool operator==(SEXP other) const {
577  return get_sexp() == other;
578  }
579 
580  bool operator!=(SEXP other) const {
581  return get_sexp() != other;
582  }
583 
584  private:
585 
587  SEXP data;
588  SEXP token;
589 
591  std::string buffer;
592 
594  bool valid;
595 
598 
600  cetype_t enc;
601 
602  inline bool is_na() const { return data == NA_STRING; }
603  inline void setBuffer() {
604  if (!buffer_ready) {
606  buffer_ready = true;
607  }
608  }
609  inline void setData() {
610  RCPP_STRING_DEBUG("setData");
611  if (!valid) {
612  data = get_sexp_impl();
614  valid = true;
615  }
616  }
617  template <typename T> void append(const T& s) { buffer += s;}
618  };
619 
620  namespace traits{
621  template<> struct r_type_traits<Rcpp::String>{ typedef r_type_RcppString_tag r_category; };
622  template<> struct r_sexptype_traits<Rcpp::String>{ enum{ rtype = STRSXP }; };
623  }
624 
625  namespace internal {
626  template <int RTYPE, template <class> class StoragePolicy>
628  set(s.get_sexp());
629  return *this;
630  }
631 
632  template <int RTYPE>
634  RCPP_DEBUG("string_element_converter::get< Rcpp::String >()")
635  return input.get_sexp();
636  }
637 
638  template <>
639  inline SEXP make_charsexp<Rcpp::String>(const Rcpp::String& s) {
640  return s.get_sexp();
641  }
642 
643  template <int RTYPE, template <class> class StoragePolicy>
644  template <typename T>
646  String tmp = get();
647  tmp += rhs;
648  set(tmp);
649  return *this;
650  }
651 
652  }
653 
654 
655  template <>
656  inline SEXP wrap<Rcpp::String>(const Rcpp::String& object) {
657  RCPP_STRING_DEBUG("wrap<String>()");
658  Shield<SEXP> res(Rf_allocVector(STRSXP, 1));
659  SEXP data = object.get_sexp();
660  SET_STRING_ELT(res, 0, data);
661  return res;
662  }
663 
664  inline bool operator==(const String::StringProxy& lhs, const String& rhs) {
665  return rhs == lhs;
666  }
667 
668  inline bool operator!=(const String::StringProxy& lhs, const String& rhs) {
669  return rhs != lhs;
670  }
671 
672  inline bool operator==(const String::const_StringProxy& lhs, const String& rhs) {
673  return rhs == lhs;
674  }
675 
676  inline bool operator!=(const String::const_StringProxy& lhs, const String& rhs) {
677  return rhs != lhs;
678  }
679 
680 } // Rcpp
681 
683 #if defined(RCPP_USING_CXX11) || defined(HAS_TR1)
684 namespace std
685 {
686 #ifndef RCPP_USING_CXX11
687 namespace tr1 {
688 #endif
689  template <>
690  struct hash<Rcpp::String>
691  {
692  size_t operator()(const Rcpp::String & s) const{
693  return hash<string>()(s.get_cstring());
694  }
695  };
696 #ifndef RCPP_USING_CXX11
697 }
698 #endif
699 }
700 #endif
701 
702 #endif
Rcpp::String::operator=
String & operator=(bool x)
Definition: String.h:185
Rcpp::String::operator+=
String & operator+=(const const_StringProxy &proxy)
Definition: String.h:325
Rcpp::String::operator=
String & operator=(Rbyte x)
Definition: String.h:177
Rcpp::String::get_sexp
SEXP get_sexp()
Definition: String.h:507
Rcpp::String::String
String(double x)
Definition: String.h:141
Rcpp::String::operator+=
String & operator+=(SEXP x)
Definition: String.h:340
Rcpp::String::String
String(const std::string &s, cetype_t enc=CE_UTF8)
Definition: String.h:114
Rcpp::String::assign_wide_string
String & assign_wide_string(const T &s)
Definition: String.h:248
Rcpp::String::operator=
String & operator=(const wchar_t *s)
Definition: String.h:259
Rcpp::String::replace_all
String & replace_all(const Rcpp::String &s, const char *news)
Definition: String.h:435
Rcpp::String::set_na
void set_na()
Definition: String.h:480
Rcpp::String::operator==
bool operator==(const const_StringProxy &other) const
Definition: String.h:564
Rcpp::String::String
String(const String &other)
Definition: String.h:61
Rcpp::String::replace_first
String & replace_first(const char *s, const Rcpp::String &news)
Definition: String.h:376
Rcpp::String::token
SEXP token
Definition: String.h:588
RCPP_STRING_DEBUG
#define RCPP_STRING_DEBUG(MSG)
Definition: String.h:37
Rcpp::String::String
String()
Definition: String.h:55
Rcpp::String::operator!=
bool operator!=(const const_StringProxy &other) const
Definition: String.h:568
Rcpp::String::String
String(int x)
Definition: String.h:138
Rcpp::String::operator==
bool operator==(const StringProxy &other) const
Definition: String.h:556
Rcpp::String::replace_all
String & replace_all(const char *s, const char *news)
Definition: String.h:414
Rcpp::String::replace_all
String & replace_all(const char *s, const Rcpp::String &news)
Definition: String.h:440
Rcpp::String::set_encoding
void set_encoding(cetype_t encoding)
Definition: String.h:529
Rcpp::String::push_back
String & push_back(const std::string &s)
Definition: String.h:456
Rcpp::String::operator=
String & operator=(double x)
Definition: String.h:169
Rcpp::String::operator+=
String & operator+=(const String &other)
Definition: String.h:296
Rcpp::operator!=
bool operator!=(const Date &d1, const Date &d2)
Definition: Date.h:170
Rcpp::String::String
String(const const_StringProxy &proxy)
Definition: String.h:102
char_nocheck
const char * char_nocheck(SEXP)
Definition: routines.h:258
Rcpp::String::get_sexp_impl
SEXP get_sexp_impl() const
Definition: String.h:489
Rcpp::String::operator==
bool operator==(SEXP other) const
Definition: String.h:576
Rcpp::traits::r_type_RcppString_tag
Definition: r_type_traits.h:99
Rcpp::String::buffer_ready
bool buffer_ready
Definition: String.h:597
Rcpp::internal::const_string_proxy
Definition: 00_forward_proxy.h:29
Rcpp::String::get_sexp
SEXP get_sexp() const
Definition: String.h:502
Rcpp::operator==
bool operator==(const Date &d1, const Date &d2)
Definition: Date.h:167
Rcpp::String::String
String(const const_StringProxy &proxy, cetype_t enc)
Definition: String.h:107
DEMANGLE
#define DEMANGLE(__TYPE__)
Definition: exceptions.h:382
Rcpp::String::append_wide_string
String & append_wide_string(const T &s)
Definition: String.h:276
Rcpp::String::setData
void setData()
Definition: String.h:609
Rcpp::String::buffer
std::string buffer
Definition: String.h:591
Rcpp::String::String
String(const wchar_t *s, cetype_t enc=CE_UTF8)
Definition: String.h:132
Rcpp::String::operator!=
bool operator!=(const Rcpp::String &other) const
Definition: String.h:552
Rcpp::String::operator=
String & operator=(const String &other)
Definition: String.h:222
RCPP_DEBUG
#define RCPP_DEBUG(MSG)
Definition: debug.h:43
Rcpp::String
Definition: String.h:49
Rcpp::String::String
String(bool x)
Definition: String.h:144
Rcpp::String::operator+=
String & operator+=(const wchar_t *s)
Definition: String.h:294
Rcpp::String::operator<
bool operator<(const Rcpp::String &other) const
Definition: String.h:545
Rcpp::Shield
Definition: Shield.h:35
Rcpp::String::String
String(SEXP charsxp)
Definition: String.h:67
Rcpp::String::operator+=
String & operator+=(const StringProxy &proxy)
Definition: String.h:310
Rcpp
Rcpp API.
Definition: algo.h:28
Rcpp::String::operator=
String & operator=(int x)
Definition: String.h:161
Rcpp::String::replace_all
String & replace_all(const LHS &s, const RHS &news)
Definition: String.h:431
Rcpp::String::operator=
String & operator=(const std::wstring &s)
Definition: String.h:258
Rcpp::Rcpp_PreciousPreserve
SEXP Rcpp_PreciousPreserve(SEXP object)
Definition: RcppCommon.h:115
Rcpp::String::replace_all
String & replace_all(const Rcpp::String &s, const Rcpp::String &news)
Definition: String.h:445
Rcpp::String::operator=
String & operator=(const std::string &s)
Definition: String.h:233
Rcpp::String::~String
~String()
Definition: String.h:154
Rcpp::internal::string_proxy::operator=
string_proxy & operator=(const string_proxy< RTYPE, StoragePolicy > &other)
Definition: string_proxy.h:57
Rcpp::internal::string_proxy
Definition: 00_forward_proxy.h:28
Rcpp::String::valid
bool valid
Definition: String.h:594
Rcpp::String::push_back
String & push_back(const char *s)
Definition: String.h:451
Rcpp::String::StringProxy
internal::string_proxy< STRSXP > StringProxy
Definition: String.h:51
Rcpp::String::get_encoding
cetype_t get_encoding() const
Definition: String.h:525
Rcpp::traits::r_sexptype_traits::rtype
@ rtype
Definition: r_sexptype_traits.h:33
Rcpp::traits::r_type_traits
Definition: r_type_traits.h:104
Rcpp::String::const_StringProxy
internal::const_string_proxy< STRSXP > const_StringProxy
Definition: String.h:52
Rcpp::String::push_front
String & push_front(const char *s)
Definition: String.h:465
Rcpp::internal::string_proxy::get
SEXP get() const
Definition: string_proxy.h:156
Rcpp::String::push_front
String & push_front(const Rcpp::String &s)
Definition: String.h:473
Rcpp::String::is_na
bool is_na() const
Definition: String.h:602
Rcpp::String::setBuffer
void setBuffer()
Definition: String.h:603
Rcpp::String::operator=
String & operator=(Rcomplex x)
Definition: String.h:193
Rcpp::internal::string_element_converter::get
static SEXP get(const T &input)
Definition: converter.h:48
Rcpp::String::operator>
bool operator>(const Rcpp::String &other) const
Definition: String.h:572
Rcpp::String::operator+=
String & operator+=(const char *s)
Definition: String.h:268
Rcpp::get
SEXP get(const std::string &name) const
Definition: Environment.h:103
Rcpp::String::operator!=
bool operator!=(SEXP other) const
Definition: String.h:580
Rcpp::Rcpp_PreciousRelease
void Rcpp_PreciousRelease(SEXP token)
Definition: RcppCommon.h:119
Rcpp::String::String
String(const std::wstring &s, cetype_t enc=CE_UTF8)
Definition: String.h:120
Rcpp::String::String
String(const char *s, cetype_t enc=CE_UTF8)
Definition: String.h:126
Rcpp::String::String
String(Rcomplex x)
Definition: String.h:147
Rcpp::String::operator+=
String & operator+=(const std::wstring &s)
Definition: String.h:293
Rcpp::String::operator!=
bool operator!=(const StringProxy &other) const
Definition: String.h:560
Rcpp::String::replace_first
String & replace_first(const Rcpp::String &s, const char *news)
Definition: String.h:371
Rcpp::String::String
String(const StringProxy &proxy, cetype_t enc)
Definition: String.h:95
RCPP_STRING_DEBUG_1
#define RCPP_STRING_DEBUG_1(fmt, MSG)
Definition: String.h:38
Rcpp::String::push_front
String & push_front(const std::string &s)
Definition: String.h:470
std
Definition: swap.h:25
Rcpp::String::operator==
bool operator==(const Rcpp::String &other) const
Definition: String.h:549
Rcpp::String::get_cstring
const char * get_cstring() const
Definition: String.h:521
Rcpp::internal::const_string_proxy::get
SEXP get() const
Definition: const_string_proxy.h:90
Rcpp::String::operator=
String & operator=(const char *s)
Definition: String.h:239
Rcpp::String::replace_last
String & replace_last(const Rcpp::String &s, const Rcpp::String &news)
Definition: String.h:407
Rcpp::internal::string_proxy::operator+=
string_proxy & operator+=(const T &rhs)
Rcpp::String::data
SEXP data
Definition: String.h:587
Rcpp::String::append
void append(const T &s)
Definition: String.h:617
Rcpp::String::replace_last
String & replace_last(const char *s, const char *news)
Definition: String.h:387
Rcpp::String::replace_last
String & replace_last(const Rcpp::String &s, const char *news)
Definition: String.h:397
Rcpp::String::replace_last
String & replace_last(const char *s, const Rcpp::String &news)
Definition: String.h:402
Rcpp::String::operator+=
String & operator+=(const std::string &s)
Definition: String.h:261
Rcpp::String::replace_first
String & replace_first(const char *s, const char *news)
Definition: String.h:361
Rcpp::String::push_back
String & push_back(const Rcpp::String &s)
Definition: String.h:459
Rcpp::String::operator=
String & operator=(const StringProxy &proxy)
Definition: String.h:211
RCPP_STRING_DEBUG_2
#define RCPP_STRING_DEBUG_2(fmt, M1, M2)
Definition: String.h:39
Rcpp::traits::r_sexptype_traits
Definition: r_sexptype_traits.h:33
Rcpp::String::String
String(Rbyte x)
Definition: String.h:150
Rcpp::String::enc
cetype_t enc
Definition: String.h:600
Rcpp::traits::r_type_traits< Rcpp::String >::r_category
r_type_RcppString_tag r_category
Definition: String.h:621
Rcpp::String::String
String(const StringProxy &proxy)
Definition: String.h:90
Rcpp::String::replace_first
String & replace_first(const Rcpp::String &s, const Rcpp::String &news)
Definition: String.h:381
Rcpp::String::operator=
String & operator=(SEXP x)
Definition: String.h:201