25#ifndef RCPP_STRING_DEBUG_LEVEL
26#define RCPP_STRING_DEBUG_LEVEL 0
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);
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)
78 const char*
fmt =
"Expecting a single string value: "
79 "[type=%s; extent=%i].";
80 throw ::Rcpp::not_compatible(
fmt,
120#ifdef RCPP_USING_CXX11
126 s.buffer = std::string();
128 s.buffer_ready =
true;
241 if (
other.buffer_ready) {
270#ifdef RCPP_USING_CXX11
281 other.buffer = std::string();
283 other.buffer_ready =
true;
302 template <
typename T>
318 if (
is_na())
return *
this;
325 if (
is_na())
return *
this;
330 template <
typename T>
334 if (
is_na())
return *
this;
336 std::wstring
tmp(buf, buf +
strlen(buf));
353 if (
is_na())
return *
this;
367 if (
is_na())
return *
this;
382 if (
is_na())
return *
this;
397 if (
is_na())
return *
this;
418 if (
is_na())
return *
this;
420 std::string
s2 = std::string(
s);
421 size_t index = std::distance(
buffer.begin(), std::search(
buffer.begin(),
buffer.end(),
s2.begin(),
s2.end()));
428 if (
s.is_na())
return *
this;
433 if (
news.is_na())
return *
this;
438 if (
s.is_na() ||
news.is_na())
return *
this;
444 if (
is_na())
return *
this;
446 std::string
s2 = std::string(
s);
447 size_t index = std::distance(
buffer.begin(), std::find_end(
buffer.begin(),
buffer.end(),
s2.begin(),
s2.end()));
454 if (
s.is_na())
return *
this;
459 if (
news.is_na())
return *
this;
464 if (
s.is_na() ||
news.is_na())
return *
this;
471 if (
is_na())
return *
this;
473 std::string
s2 = std::string(
s);
474 std::string::iterator iter =
buffer.begin();
476 iter = std::search(iter,
buffer.end(),
s2.begin(),
s2.end());
477 if (iter ==
buffer.end())
break;
478 size_t index = std::distance(
buffer.begin(), iter);
485 template <
typename LHS,
typename RHS>
492 if (
s.is_na())
return *
this;
497 if (
news.is_na())
return *
this;
502 if (
s.is_na() ||
news.is_na())
return *
this;
507 if (
is_na())
return *
this;
515 if (
is_na())
return *
this;
516 if (
s.is_na()) {
set_na();
return *
this; }
521 if (
is_na())
return *
this;
529 if (
is_na())
return *
this;
530 if (
s.is_na()) {
set_na();
return *
this; }
551 if (
buffer.find(
'\0') != std::string::npos)
567 inline operator std::string()
const {
571 inline operator std::wstring()
const {
681 template <
int RTYPE,
template <
class>
class StoragePolicy>
689 RCPP_DEBUG(
"string_element_converter::get< Rcpp::String >()")
690 return input.get_sexp();
698 template <
int RTYPE,
template <
class>
class StoragePolicy>
699 template <
typename T>
714 SEXP data =
object.get_sexp();
738#if defined(RCPP_USING_CXX11) || defined(HAS_TR1)
741#ifndef RCPP_USING_CXX11
745 struct hash<
Rcpp::String>
751#ifndef RCPP_USING_CXX11
#define RCPP_STRING_DEBUG_2(fmt, M1, M2)
#define RCPP_STRING_DEBUG_1(fmt, MSG)
#define RCPP_STRING_DEBUG(MSG)
const char * char_nocheck(SEXP)
String(const const_StringProxy &proxy)
String & push_front(const std::string &s)
String & operator+=(const String &other)
String & operator=(const StringProxy &proxy)
String & replace_all(const Rcpp::String &s, const char *news)
String & replace_last(const char *s, const Rcpp::String &news)
bool operator==(const StringProxy &other) const
String & operator=(double x)
String & operator=(Rbyte x)
String & push_front(const char *s)
String(const char *s, cetype_t enc=CE_UTF8)
String & assign_wide_string(const T &s)
String & replace_last(const char *s, const char *news)
String & operator+=(const std::wstring &s)
String & replace_last(const Rcpp::String &s, const Rcpp::String &news)
bool operator>(const Rcpp::String &other) const
String & operator=(const char *s)
bool operator!=(const Rcpp::String &other) const
String & operator=(Rcomplex x)
String & replace_all(const Rcpp::String &s, const Rcpp::String &news)
bool operator!=(const const_StringProxy &other) const
String & replace_all(const LHS &s, const RHS &news)
cetype_t get_encoding() const
void set_encoding(cetype_t encoding)
String(const StringProxy &proxy)
String & operator+=(const std::string &s)
String & operator=(const std::string &s)
String & operator=(const std::wstring &s)
String & replace_first(const Rcpp::String &s, const Rcpp::String &news)
internal::string_proxy< STRSXP > StringProxy
String & operator+=(const wchar_t *s)
String(const std::string &s, cetype_t enc=CE_UTF8)
String & operator+=(const const_StringProxy &proxy)
String & operator+=(const char *s)
bool operator==(const const_StringProxy &other) const
String & replace_first(const Rcpp::String &s, const char *news)
internal::const_string_proxy< STRSXP > const_StringProxy
String(const const_StringProxy &proxy, cetype_t enc)
String & push_back(const Rcpp::String &s)
String(const std::wstring &s, cetype_t enc=CE_UTF8)
String & operator=(bool x)
String & replace_first(const char *s, const Rcpp::String &news)
const char * get_cstring() const
String & operator+=(const StringProxy &proxy)
bool operator!=(const StringProxy &other) const
String & operator=(SEXP x)
SEXP get_sexp_impl() const
String & operator=(const wchar_t *s)
String(const wchar_t *s, cetype_t enc=CE_UTF8)
bool operator==(const Rcpp::String &other) const
String & operator=(int x)
bool operator<(const Rcpp::String &other) const
String & operator=(const String &other)
String & push_back(const char *s)
String(const StringProxy &proxy, cetype_t enc)
String & push_front(const Rcpp::String &s)
bool operator!=(SEXP other) const
String & operator+=(SEXP x)
bool operator==(SEXP other) const
String & replace_last(const Rcpp::String &s, const char *news)
String & push_back(const std::string &s)
String & replace_all(const char *s, const Rcpp::String &news)
String & append_wide_string(const T &s)
String & replace_first(const char *s, const char *news)
String & replace_all(const char *s, const char *news)
static SEXP get(const T &input)
string_proxy & operator+=(const T &rhs)
string_proxy & operator=(const string_proxy< RTYPE, StoragePolicy > &other)
#define DEMANGLE(__TYPE__)
T as(SEXP x, ::Rcpp::traits::r_type_primitive_tag)
SEXP make_charsexp< Rcpp::String >(const Rcpp::String &s)
SEXP wrap< Rcpp::String >(const Rcpp::String &object)
bool operator!=(const Date &d1, const Date &d2)
SEXP get(const std::string &name) const
SEXP Rcpp_PreciousPreserve(SEXP object)
void Rcpp_PreciousRelease(SEXP token)
bool operator==(const Date &d1, const Date &d2)
r_type_RcppString_tag r_category