Rcpp Version 0.12.12
Rcpp::String Class Reference

#include <String.h>

Public Types

typedef internal::string_proxy< STRSXP > StringProxy
 
typedef internal::const_string_proxy< STRSXP > const_StringProxy
 

Public Member Functions

 String ()
 
 String (const String &other)
 
 String (SEXP charsxp)
 
 String (const StringProxy &proxy)
 
 String (const StringProxy &proxy, cetype_t enc)
 
 String (const const_StringProxy &proxy)
 
 String (const const_StringProxy &proxy, cetype_t enc)
 
 String (const std::string &s, cetype_t enc=CE_UTF8)
 
 String (const std::wstring &s, cetype_t enc=CE_UTF8)
 
 String (const char *s, cetype_t enc=CE_UTF8)
 
 String (const wchar_t *s, cetype_t enc=CE_UTF8)
 
 String (int x)
 
 String (double x)
 
 String (bool x)
 
 String (Rcomplex x)
 
 String (Rbyte x)
 
 ~String ()
 
Stringoperator= (int x)
 
Stringoperator= (double x)
 
Stringoperator= (Rbyte x)
 
Stringoperator= (bool x)
 
Stringoperator= (Rcomplex x)
 
Stringoperator= (SEXP x)
 
Stringoperator= (const StringProxy &proxy)
 
Stringoperator= (const String &other)
 
Stringoperator= (const std::string &s)
 
Stringoperator= (const char *s)
 
Stringoperator= (const std::wstring &s)
 
Stringoperator= (const wchar_t *s)
 
Stringoperator+= (const std::string &s)
 
Stringoperator+= (const char *s)
 
Stringoperator+= (const std::wstring &s)
 
Stringoperator+= (const wchar_t *s)
 
Stringoperator+= (const String &other)
 
Stringoperator+= (const StringProxy &proxy)
 
Stringoperator+= (const const_StringProxy &proxy)
 
Stringoperator+= (SEXP x)
 
Stringreplace_first (const char *s, const char *news)
 
Stringreplace_first (const Rcpp::String &s, const char *news)
 
Stringreplace_first (const char *s, const Rcpp::String &news)
 
Stringreplace_first (const Rcpp::String &s, const Rcpp::String &news)
 
Stringreplace_last (const char *s, const char *news)
 
Stringreplace_last (const Rcpp::String &s, const char *news)
 
Stringreplace_last (const char *s, const Rcpp::String &news)
 
Stringreplace_last (const Rcpp::String &s, const Rcpp::String &news)
 
Stringreplace_all (const char *s, const char *news)
 
template<typename LHS , typename RHS >
Stringreplace_all (const LHS &s, const RHS &news)
 
Stringreplace_all (const Rcpp::String &s, const char *news)
 
Stringreplace_all (const char *s, const Rcpp::String &news)
 
Stringreplace_all (const Rcpp::String &s, const Rcpp::String &news)
 
Stringpush_back (const char *s)
 
Stringpush_back (const std::string &s)
 
Stringpush_back (const Rcpp::String &s)
 
Stringpush_front (const char *s)
 
Stringpush_front (const std::string &s)
 
Stringpush_front (const Rcpp::String &s)
 
void set_na ()
 
SEXP get_sexp () const
 
SEXP get_sexp ()
 
 operator std::string () const
 
 operator std::wstring () const
 
const char * get_cstring () const
 
cetype_t get_encoding () const
 
void set_encoding (cetype_t encoding)
 
bool operator< (const Rcpp::String &other) const
 
bool operator== (const Rcpp::String &other) const
 
bool operator!= (const Rcpp::String &other) const
 
bool operator== (const StringProxy &other) const
 
bool operator!= (const StringProxy &other) const
 
bool operator== (const const_StringProxy &other) const
 
bool operator!= (const const_StringProxy &other) const
 
bool operator> (const Rcpp::String &other) const
 
bool operator== (SEXP other) const
 
bool operator!= (SEXP other) const
 

Private Member Functions

template<typename T >
Stringassign_wide_string (const T &s)
 
template<typename T >
Stringappend_wide_string (const T &s)
 
bool is_na () const
 
void setBuffer ()
 
void setData ()
 
template<typename T >
void append (const T &s)
 

Private Attributes

SEXP data
 
std::string buffer
 
bool valid
 
bool buffer_ready
 
cetype_t enc
 

Detailed Description

A single string, i.e. an element of a character vector. This represents CHARSXP SEXP

Definition at line 49 of file String.h.

Member Typedef Documentation

Definition at line 52 of file String.h.

Definition at line 51 of file String.h.

Constructor & Destructor Documentation

Rcpp::String::String ( )
inline

default constructor

Definition at line 55 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), and RCPP_STRING_DEBUG.

Referenced by replace_all().

Here is the call graph for this function:

Rcpp::String::String ( const String other)
inline

copy constructor

Definition at line 61 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), and RCPP_STRING_DEBUG.

Here is the call graph for this function:

Rcpp::String::String ( SEXP  charsxp)
inline

construct a string from a single CHARSXP SEXP

Definition at line 67 of file String.h.

References buffer_ready, data, enc, Rcpp::Rcpp_PreserveObject(), RCPP_STRING_DEBUG, and valid.

Here is the call graph for this function:

Rcpp::String::String ( const StringProxy proxy)
inline

from string proxy

Definition at line 90 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), and RCPP_STRING_DEBUG.

Here is the call graph for this function:

Rcpp::String::String ( const StringProxy proxy,
cetype_t  enc 
)
inline

Definition at line 95 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), RCPP_STRING_DEBUG, and set_encoding().

Here is the call graph for this function:

Rcpp::String::String ( const const_StringProxy proxy)
inline

from string proxy

Definition at line 102 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), and RCPP_STRING_DEBUG.

Here is the call graph for this function:

Rcpp::String::String ( const const_StringProxy proxy,
cetype_t  enc 
)
inline

Definition at line 107 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), RCPP_STRING_DEBUG, and set_encoding().

Here is the call graph for this function:

Rcpp::String::String ( const std::string &  s,
cetype_t  enc = CE_UTF8 
)
inline

from a std::string

Definition at line 114 of file String.h.

References data, and RCPP_STRING_DEBUG.

Rcpp::String::String ( const std::wstring &  s,
cetype_t  enc = CE_UTF8 
)
inline

Definition at line 119 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), and RCPP_STRING_DEBUG.

Here is the call graph for this function:

Rcpp::String::String ( const char *  s,
cetype_t  enc = CE_UTF8 
)
inline

from a const char*

Definition at line 125 of file String.h.

References data, and RCPP_STRING_DEBUG.

Rcpp::String::String ( const wchar_t *  s,
cetype_t  enc = CE_UTF8 
)
inline

Definition at line 130 of file String.h.

References data, Rcpp::Rcpp_PreserveObject(), and RCPP_STRING_DEBUG.

Here is the call graph for this function:

Rcpp::String::String ( int  x)
inline

constructors from R primitives

Definition at line 136 of file String.h.

References data, and Rcpp::Rcpp_PreserveObject().

Here is the call graph for this function:

Rcpp::String::String ( double  x)
inline

Definition at line 137 of file String.h.

References data, and Rcpp::Rcpp_PreserveObject().

Here is the call graph for this function:

Rcpp::String::String ( bool  x)
inline

Definition at line 138 of file String.h.

References data, and Rcpp::Rcpp_PreserveObject().

Here is the call graph for this function:

Rcpp::String::String ( Rcomplex  x)
inline

Definition at line 139 of file String.h.

References data, and Rcpp::Rcpp_PreserveObject().

Here is the call graph for this function:

Rcpp::String::String ( Rbyte  x)
inline

Definition at line 140 of file String.h.

References data, and Rcpp::Rcpp_PreserveObject().

Here is the call graph for this function:

Rcpp::String::~String ( )
inline

Definition at line 142 of file String.h.

References data, and Rcpp::Rcpp_ReleaseObject().

Here is the call graph for this function:

Member Function Documentation

template<typename T >
void Rcpp::String::append ( const T &  s)
inlineprivate

Definition at line 477 of file String.h.

template<typename T >
String& Rcpp::String::append_wide_string ( const T &  s)
inlineprivate

Definition at line 187 of file String.h.

References buffer_ready, data, DEMANGLE, is_na(), Rcpp::Rcpp_ReplaceObject(), RCPP_STRING_DEBUG_1, setData(), and valid.

Referenced by operator+=().

Here is the call graph for this function:

template<typename T >
String& Rcpp::String::assign_wide_string ( const T &  s)
inlineprivate

Definition at line 161 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Referenced by operator=().

Here is the call graph for this function:

const char* Rcpp::String::get_cstring ( ) const
inline
cetype_t Rcpp::String::get_encoding ( ) const
inline

Definition at line 390 of file String.h.

References enc.

SEXP Rcpp::String::get_sexp ( )
inline

Definition at line 372 of file String.h.

References data, RCPP_STRING_DEBUG_1, setData(), and valid.

Here is the call graph for this function:

bool Rcpp::String::is_na ( ) const
inlineprivate
Rcpp::String::operator std::string ( ) const
inline

Definition at line 377 of file String.h.

References get_cstring().

Here is the call graph for this function:

Rcpp::String::operator std::wstring ( ) const
inline

Definition at line 381 of file String.h.

References get_cstring().

Here is the call graph for this function:

bool Rcpp::String::operator!= ( const Rcpp::String other) const
inline

Definition at line 413 of file String.h.

References get_sexp().

Here is the call graph for this function:

bool Rcpp::String::operator!= ( const StringProxy other) const
inline

Definition at line 421 of file String.h.

References Rcpp::internal::string_proxy< RTYPE >::get(), and get_sexp().

Here is the call graph for this function:

bool Rcpp::String::operator!= ( const const_StringProxy other) const
inline

Definition at line 429 of file String.h.

References Rcpp::internal::const_string_proxy< RTYPE >::get(), and get_sexp().

Here is the call graph for this function:

bool Rcpp::String::operator!= ( SEXP  other) const
inline

Definition at line 441 of file String.h.

References get_sexp().

Here is the call graph for this function:

String& Rcpp::String::operator+= ( const std::string &  s)
inline

Definition at line 172 of file String.h.

References buffer, is_na(), RCPP_STRING_DEBUG, setBuffer(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator+= ( const char *  s)
inline

Definition at line 179 of file String.h.

References buffer, is_na(), RCPP_STRING_DEBUG, setBuffer(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator+= ( const std::wstring &  s)
inline

Definition at line 202 of file String.h.

References append_wide_string().

Here is the call graph for this function:

String& Rcpp::String::operator+= ( const wchar_t *  s)
inline

Definition at line 203 of file String.h.

References append_wide_string().

Here is the call graph for this function:

String& Rcpp::String::operator+= ( const String other)
inline

Definition at line 205 of file String.h.

References buffer, buffer_ready, data, is_na(), Rcpp::Rcpp_ReplaceObject(), RCPP_STRING_DEBUG, setBuffer(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator+= ( const StringProxy proxy)
inline

Definition at line 212 of file String.h.

References buffer, buffer_ready, data, is_na(), Rcpp::Rcpp_ReplaceObject(), RCPP_STRING_DEBUG, setBuffer(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator+= ( const const_StringProxy proxy)
inline

Definition at line 220 of file String.h.

References buffer, buffer_ready, data, is_na(), Rcpp::Rcpp_ReplaceObject(), RCPP_STRING_DEBUG, setBuffer(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator+= ( SEXP  x)
inline

Definition at line 228 of file String.h.

References buffer, buffer_ready, data, is_na(), Rcpp::Rcpp_ReplaceObject(), RCPP_STRING_DEBUG, setBuffer(), and valid.

Here is the call graph for this function:

bool Rcpp::String::operator< ( const Rcpp::String other) const
inline

Definition at line 406 of file String.h.

References get_cstring().

Here is the call graph for this function:

String& Rcpp::String::operator= ( int  x)
inline

Definition at line 148 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( double  x)
inline

Definition at line 149 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( Rbyte  x)
inline

Definition at line 150 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( bool  x)
inline

Definition at line 151 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( Rcomplex  x)
inline

Definition at line 152 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( SEXP  x)
inline

Definition at line 153 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( const StringProxy proxy)
inline

Definition at line 154 of file String.h.

References buffer_ready, data, Rcpp::internal::string_proxy< RTYPE >::get(), Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( const String other)
inline

Definition at line 155 of file String.h.

References buffer_ready, data, get_sexp(), Rcpp::Rcpp_ReplaceObject(), and valid.

Here is the call graph for this function:

String& Rcpp::String::operator= ( const std::string &  s)
inline

Definition at line 156 of file String.h.

References buffer, buffer_ready, and valid.

String& Rcpp::String::operator= ( const char *  s)
inline

Definition at line 157 of file String.h.

References buffer, buffer_ready, and valid.

String& Rcpp::String::operator= ( const std::wstring &  s)
inline

Definition at line 169 of file String.h.

References assign_wide_string().

Here is the call graph for this function:

String& Rcpp::String::operator= ( const wchar_t *  s)
inline

Definition at line 170 of file String.h.

References assign_wide_string().

Here is the call graph for this function:

bool Rcpp::String::operator== ( const Rcpp::String other) const
inline

Definition at line 410 of file String.h.

References get_sexp().

Here is the call graph for this function:

bool Rcpp::String::operator== ( const StringProxy other) const
inline

Definition at line 417 of file String.h.

References Rcpp::internal::string_proxy< RTYPE >::get(), and get_sexp().

Here is the call graph for this function:

bool Rcpp::String::operator== ( const const_StringProxy other) const
inline

Definition at line 425 of file String.h.

References Rcpp::internal::const_string_proxy< RTYPE >::get(), and get_sexp().

Here is the call graph for this function:

bool Rcpp::String::operator== ( SEXP  other) const
inline

Definition at line 437 of file String.h.

References get_sexp().

Here is the call graph for this function:

bool Rcpp::String::operator> ( const Rcpp::String other) const
inline

Definition at line 433 of file String.h.

References get_cstring().

Here is the call graph for this function:

String& Rcpp::String::push_back ( const char *  s)
inline

Definition at line 332 of file String.h.

References buffer, is_na(), setBuffer(), and valid.

Referenced by push_back().

Here is the call graph for this function:

String& Rcpp::String::push_back ( const std::string &  s)
inline

Definition at line 337 of file String.h.

References push_back().

Here is the call graph for this function:

String& Rcpp::String::push_back ( const Rcpp::String s)
inline

Definition at line 340 of file String.h.

References get_cstring(), is_na(), push_back(), and set_na().

Here is the call graph for this function:

String& Rcpp::String::push_front ( const char *  s)
inline

Definition at line 346 of file String.h.

References buffer, is_na(), setBuffer(), and valid.

Referenced by push_front().

Here is the call graph for this function:

String& Rcpp::String::push_front ( const std::string &  s)
inline

Definition at line 351 of file String.h.

References push_front().

Here is the call graph for this function:

String& Rcpp::String::push_front ( const Rcpp::String s)
inline

Definition at line 354 of file String.h.

References get_cstring(), is_na(), push_front(), and set_na().

Here is the call graph for this function:

String& Rcpp::String::replace_all ( const char *  s,
const char *  news 
)
inline

Definition at line 295 of file String.h.

References buffer, is_na(), RCPP_STRING_DEBUG_2, setBuffer(), and valid.

Referenced by replace_all().

Here is the call graph for this function:

template<typename LHS , typename RHS >
String& Rcpp::String::replace_all ( const LHS &  s,
const RHS &  news 
)
inline

Definition at line 312 of file String.h.

References replace_all(), and String().

Here is the call graph for this function:

String& Rcpp::String::replace_all ( const Rcpp::String s,
const char *  news 
)
inline

Definition at line 316 of file String.h.

References get_cstring(), is_na(), and replace_all().

Here is the call graph for this function:

String& Rcpp::String::replace_all ( const char *  s,
const Rcpp::String news 
)
inline

Definition at line 321 of file String.h.

References get_cstring(), is_na(), and replace_all().

Here is the call graph for this function:

String& Rcpp::String::replace_all ( const Rcpp::String s,
const Rcpp::String news 
)
inline

Definition at line 326 of file String.h.

References get_cstring(), is_na(), and replace_all().

Here is the call graph for this function:

String& Rcpp::String::replace_first ( const char *  s,
const char *  news 
)
inline

Definition at line 242 of file String.h.

References buffer, is_na(), RCPP_STRING_DEBUG_2, setBuffer(), and valid.

Referenced by replace_first().

Here is the call graph for this function:

String& Rcpp::String::replace_first ( const Rcpp::String s,
const char *  news 
)
inline

Definition at line 252 of file String.h.

References get_cstring(), is_na(), and replace_first().

Here is the call graph for this function:

String& Rcpp::String::replace_first ( const char *  s,
const Rcpp::String news 
)
inline

Definition at line 257 of file String.h.

References get_cstring(), is_na(), and replace_first().

Here is the call graph for this function:

String& Rcpp::String::replace_first ( const Rcpp::String s,
const Rcpp::String news 
)
inline

Definition at line 262 of file String.h.

References get_cstring(), is_na(), and replace_first().

Here is the call graph for this function:

String& Rcpp::String::replace_last ( const char *  s,
const char *  news 
)
inline

Definition at line 268 of file String.h.

References buffer, is_na(), RCPP_STRING_DEBUG_2, setBuffer(), and valid.

Referenced by replace_last().

Here is the call graph for this function:

String& Rcpp::String::replace_last ( const Rcpp::String s,
const char *  news 
)
inline

Definition at line 278 of file String.h.

References get_cstring(), is_na(), and replace_last().

Here is the call graph for this function:

String& Rcpp::String::replace_last ( const char *  s,
const Rcpp::String news 
)
inline

Definition at line 283 of file String.h.

References get_cstring(), is_na(), and replace_last().

Here is the call graph for this function:

String& Rcpp::String::replace_last ( const Rcpp::String s,
const Rcpp::String news 
)
inline

Definition at line 288 of file String.h.

References get_cstring(), is_na(), and replace_last().

Here is the call graph for this function:

void Rcpp::String::set_encoding ( cetype_t  encoding)
inline

Definition at line 394 of file String.h.

References buffer, data, enc, Rcpp::Rcpp_PreserveObject(), Rcpp::Rcpp_ReplaceObject(), and valid.

Referenced by String().

Here is the call graph for this function:

void Rcpp::String::set_na ( )
inline

Definition at line 361 of file String.h.

References buffer_ready, data, Rcpp::Rcpp_ReplaceObject(), and valid.

Referenced by push_back(), and push_front().

Here is the call graph for this function:

void Rcpp::String::setBuffer ( )
inlineprivate

Definition at line 463 of file String.h.

References char_nocheck().

Referenced by operator+=(), push_back(), push_front(), replace_all(), replace_first(), and replace_last().

Here is the call graph for this function:

void Rcpp::String::setData ( )
inlineprivate

Definition at line 469 of file String.h.

References enc, Rcpp::Rcpp_PreserveObject(), and RCPP_STRING_DEBUG.

Referenced by append_wide_string(), and get_sexp().

Here is the call graph for this function:

Member Data Documentation

std::string Rcpp::String::buffer
private

a buffer used to do string operations withough going back to the SEXP

Definition at line 451 of file String.h.

Referenced by get_cstring(), get_sexp(), operator+=(), operator=(), push_back(), push_front(), replace_all(), replace_first(), replace_last(), and set_encoding().

bool Rcpp::String::buffer_ready
private

is the buffer initialized

Definition at line 457 of file String.h.

Referenced by append_wide_string(), assign_wide_string(), get_cstring(), operator+=(), operator=(), set_na(), and String().

SEXP Rcpp::String::data
private
cetype_t Rcpp::String::enc
private

the encoding of encapsulated CHARSXP

Definition at line 460 of file String.h.

Referenced by get_encoding(), get_sexp(), set_encoding(), setData(), and String().

bool Rcpp::String::valid
private

The documentation for this class was generated from the following file: