CXXR (C++ R) API
Classes | Namespaces | Enumerations | Functions | Variables
String.h File Reference

($Id: String.h 1390 2013-06-11 14:41:41Z arr $)

Class CXXR::String and associated C interface. More...

#include "CXXR/GCRoot.h"
#include "CXXR/VectorBase.h"
#include <boost/serialization/nvp.hpp>
#include <tr1/unordered_map>
#include <string>
#include "CXXR/Allocator.hpp"
#include "CXXR/SEXP_downcast.hpp"
#include "CXXR/SchwarzCounter.hpp"
Include dependency graph for String.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CXXR::String
 RObject representing a character string. More...
class  CXXR::String::Comparator
 Comparison object for CXXR::String. More...

Namespaces

namespace  CXXR
 Namespace for the CXXR project.

Enumerations

enum  cetype_t {
  CE_NATIVE = 0, CE_UTF8 = 1, CE_LATIN1 = 2, CE_BYTES = 3,
  CE_SYMBOL = 5, CE_ANY = 99
}

Functions

bool CXXR::isASCII (const std::string &str)
 Is a std::string entirely ASCII?
int ENC_KNOWN (SEXP x)
 Is the encoding of a CXXR::String known?
int IS_ASCII (SEXP x)
 Is a CXXR::String pure ASCII?
int IS_BYTES (SEXP x)
 Does a CXXR::String have bytecode encoding?
Rboolean IS_LATIN1 (SEXP x)
 Does a CXXR::String have LATIN1 encoding?
Rboolean IS_UTF8 (SEXP x)
 Does a CXXR::String have UTF8 encoding?
const char * R_CHAR (SEXP x)
 Access the content of CXXR::String as a C-style string.
SEXP Rf_mkChar (const char *str)
 Get a pointer to a CXXR::String object.
SEXP Rf_mkCharCE (const char *str, cetype_t encoding)
 Get a pointer to a CXXR::String object.
SEXP Rf_mkCharLenCE (const char *text, int length, cetype_t encoding)
 Create a CXXR::String object for specified text and encoding.
SEXP Rf_mkCharLen (const char *text, int length)
 Create a CXXR::String object for specified text.
const char * Rf_translateCharUTF8 (SEXP x)
 Convert contents of a CXXR::String to UTF8.

Variables

SEXP R_NaString
SEXP R_BlankString

Detailed Description

Class CXXR::String and associated C interface.


Function Documentation

int ENC_KNOWN ( SEXP  x)
inline

Is the encoding of a CXXR::String known?

Parameters:
xPointer to a CXXR::String.
Returns:
a non-zero value iff x is marked as having either LATIN1 encoding or UTF8 encoding.
int IS_ASCII ( SEXP  x)
inline

Is a CXXR::String pure ASCII?

Parameters:
xPointer to a CXXR::String.
Returns:
true iff x contains only ASCII characters..
int IS_BYTES ( SEXP  x)
inline

Does a CXXR::String have bytecode encoding?

Parameters:
xPointer to a CXXR::String.
Returns:
true iff x is marked as having BYTES encoding.
Rboolean IS_LATIN1 ( SEXP  x)
inline

Does a CXXR::String have LATIN1 encoding?

Parameters:
xPointer to a CXXR::String.
Returns:
true iff x is marked as having LATIN1 encoding.
Rboolean IS_UTF8 ( SEXP  x)
inline

Does a CXXR::String have UTF8 encoding?

Parameters:
xPointer to a CXXR::String (checked).
Returns:
true iff x is marked as having UTF8 encoding.
const char* R_CHAR ( SEXP  x)
inline

Access the content of CXXR::String as a C-style string.

Parameters:
xnon-null pointer to a CXXR::String .
Returns:
const pointer to character 0 of x .
SEXP Rf_mkChar ( const char *  str)
inline

Get a pointer to a CXXR::String object.

Get a pointer to a cached ASCII string object.

CE_NATIVE encoding is assumed. If no CXXR::String with the specified text and encoding currently exists, one will be created. Otherwise a pointer to the existing CXXR::String will be returned.

Parameters:
strThe null-terminated text of the required string.
Returns:
Pointer to a string object representing the specified text.
SEXP Rf_mkCharCE ( const char *  str,
cetype_t  encoding 
)
inline

Get a pointer to a CXXR::String object.

Get a pointer to a cached string object.

If no CXXR::String with the specified text and encoding currently exists, one will be created. Otherwise a pointer to the existing CXXR::String will be returned.

Parameters:
strThe null-terminated text of the required cached string.
encodingThe encoding of the required String. Only CE_NATIVE, CE_UTF8 or CE_LATIN1 are permitted in this context (checked).
Returns:
Pointer to a string object representing the specified text in the specified encoding.
SEXP Rf_mkCharLen ( const char *  text,
int  length 
)
inline

Create a CXXR::String object for specified text.

Create a CXXR::UncachedString object for specified text.

CE_NATIVE encoding is assumed. If no CXXR::String with the specified text and encoding currently exists, one will be created. Otherwise a pointer to the existing CXXR::String will be returned.

Parameters:
textThe text of the string to be created, possibly including embedded null characters. The encoding is assumed to be CE_NATIVE.
lengthThe length of the string pointed to by text. Must be nonnegative. The created string will comprise the text plus an appended null byte.
Returns:
Pointer to the created string.
SEXP Rf_mkCharLenCE ( const char *  text,
int  length,
cetype_t  encoding 
)

Create a CXXR::String object for specified text and encoding.

If no CXXR::String with the specified text and encoding currently exists, one will be created. Otherwise a pointer to the existing CXXR::String will be returned.

Parameters:
textThe text of the string to be created, possibly including embedded null characters. The encoding is assumed to be CE_NATIVE.
lengthThe length of the string pointed to by text. Must be nonnegative. The created string will comprise the text plus an appended null byte.
encodingThe encoding of the required String. Only CE_NATIVE, CE_UTF8 or CE_LATIN1 are permitted in this context (checked).
Returns:
Pointer to the created string.
const char* Rf_translateCharUTF8 ( SEXP  x)

Convert contents of a CXXR::String to UTF8.

Parameters:
xNon-null pointer to a CXXR::String.
Returns:
The text of x rendered in UTF8 encoding.
Note:
The result is held in memory allocated using R_alloc(). The calling code must arrange for this memory to be released in due course.