rds2cpp
C++ library for parsing RDS files
Loading...
Searching...
No Matches
rds2cpp Namespace Reference

Parse an RDS file in C++. More...

Classes

struct  AtomicVector
 Vector of some atomic type. More...
 
struct  Attributes
 Attribute names and values. More...
 
struct  BuiltInFunction
 Built-in function. More...
 
struct  Environment
 An R environment. More...
 
struct  EnvironmentIndex
 Reference to an environment. More...
 
struct  ExpressionVector
 Expression vector. More...
 
struct  ExternalPointerIndex
 Reference to an external pointer. More...
 
struct  GenericVector
 Generic vector, i.e., an ordinary R list. More...
 
struct  LanguageObject
 Language object, i.e., a function call. More...
 
struct  Null
 R's NULL value. More...
 
struct  PairList
 Pairlist, i.e., a linked list. More...
 
struct  ParseRdsOptions
 Options for parse_rds(). More...
 
struct  RdsFile
 Contents of the parsed RDS file. More...
 
struct  RObject
 Virtual class for all unserialized R objects. More...
 
struct  S4Object
 S4 object. More...
 
struct  StringVector
 String vector. More...
 
struct  Symbol
 An R symbol. More...
 
struct  SymbolIndex
 Reference to a language symbol. More...
 

Typedefs

typedef AtomicVector< int32_t, SEXPType::INT > IntegerVector
 Integer vector.
 
typedef AtomicVector< int32_t, SEXPType::LGL > LogicalVector
 Logical vector.
 
typedef AtomicVector< double, SEXPType::REAL > DoubleVector
 Double-precision vector.
 
typedef AtomicVector< unsigned char, SEXPType::RAW > RawVector
 Raw vector.
 
typedef AtomicVector< std::complex< double >, SEXPType::CPLX > ComplexVector
 Complex vector.
 
typedef RdsFile Parsed
 

Enumerations

enum class  StringEncoding : unsigned char { NONE , LATIN1 , UTF8 , ASCII }
 
enum class  SEXPType : unsigned char {
  NIL = 0 , SYM = 1 , LIST = 2 , CLO = 3 ,
  ENV = 4 , PROM = 5 , LANG = 6 , SPECIAL = 7 ,
  BUILTIN = 8 , CHAR = 9 , LGL = 10 , INT = 13 ,
  REAL = 14 , CPLX = 15 , STR = 16 , DOT = 17 ,
  ANY = 18 , VEC = 19 , EXPR = 20 , BCODE = 21 ,
  EXTPTR = 22 , WEAKREF = 23 , RAW = 24 , S4 = 25 ,
  REF = 255 , NILVALUE_ = 254 , GLOBALENV_ = 253 , UNBOUNDVALUE_ = 252 ,
  MISSINGARG_ = 251 , BASENAMESPACE_ = 250 , NAMESPACE = 249 , PACKAGE = 248 ,
  PERSIST = 247 , CLASSREF = 246 , GENERICREF = 245 , BCREPDEF = 244 ,
  BCREPREF = 243 , EMPTYENV_ = 242 , BASEENV_ = 241 , ATTRLANG = 240 ,
  ATTRLIST = 239 , ALTREP_ = 238
}
 

Functions

template<class Reader_ >
RdsFile parse_rds (Reader_ &reader, const ParseRdsOptions &options)
 
RdsFile parse_rds (std::string file, const ParseRdsOptions &options)
 
template<class Writer >
void write_rds (const RdsFile &info, Writer &writer)
 
void write_rds (const RdsFile &info, const char *path)
 
void write_rds (const RdsFile &info, std::string path)
 

Detailed Description

Parse an RDS file in C++.

Typedef Documentation

◆ Parsed

Typedef for back-compatibility.

Enumeration Type Documentation

◆ SEXPType

enum class rds2cpp::SEXPType : unsigned char
strong

Data types within R.

Values from 0 to 25 were taken from the R internals documentation. Of particular interest are the following:

  • NIL is R's NULL.
  • ENV is an R environment.
  • LGL is a logical vector.
  • INT is an integer vector.
  • REAL is a double vector.
  • CPLX is a complex vector.
  • STR is a string vector (also known as a character vector in R). Do not confuse this with CHAR, which refers to an internal representation of a single string.
  • VEC is an ordinary R list. Do not confuse this with LIST, which refers to a pairlist.

Values from 238 to 255 were determined by inspecting the R source code.

◆ StringEncoding

enum class rds2cpp::StringEncoding : unsigned char
strong

Encoding options for R strings.

Function Documentation

◆ parse_rds() [1/2]

template<class Reader_ >
RdsFile rds2cpp::parse_rds ( Reader_ & reader,
const ParseRdsOptions & options )

Parse the contents of an RDS file.

Template Parameters
Reader_A byteme::Reader class, or any class with a compatible interface.
Parameters
readerInstance of a Reader class, containing the contents of the RDS file.
optionsFurther options for parsing.
Returns
An RdsFile object containing the contents of the RDS file.

◆ parse_rds() [2/2]

RdsFile rds2cpp::parse_rds ( std::string file,
const ParseRdsOptions & options )
inline

Parse the contents of an RDS file.

Parameters
filePath to an RDS file.
optionsFurther options for parsing.
Returns
An RdsFile object containing the contents of file.

◆ write_rds() [1/3]

void rds2cpp::write_rds ( const RdsFile & info,
const char * path )
inline

Write an R object to a Gzip-compressed RDS file.

Parameters
infoInformation about the RDS file to be written, including a pointer to a valid RObject.
pathPath to the output file.

◆ write_rds() [2/3]

void rds2cpp::write_rds ( const RdsFile & info,
std::string path )
inline

Write an R object to a Gzip-compressed RDS file.

Parameters
infoInformation about the RDS file to be written, including a pointer to a valid RObject.
pathPath to the output file.

◆ write_rds() [3/3]

template<class Writer >
void rds2cpp::write_rds ( const RdsFile & info,
Writer & writer )

Convert an R object into the RDS format and write it to a specified output.

Template Parameters
WriterA byteme::Writer class, or any class with a compatible interface.
Parameters
infoInformation about the RDS file to be written, including a pointer to a valid RObject.
writerInstance of a Writer class, where the RDS file is to be written.