RInside Version 0.2.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bar_rcpp_wrapper_definitions.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4  * These wrappers only wrap into a trivial list. More complicated objects should either
5  * map to a similar
6  */
7 
8 namespace Rcpp {
9 
10  // Bar
11  template<> SEXP wrap(const Bar &bar) {
12  Rcpp::List list;
13 
14  list["name"] = bar.name;
15  list["foo"] = bar.foo;
16 
17  return Rcpp::wrap(list);
18  }
19  template<> Bar as(SEXP sexp) {
20  Rcpp::List list = Rcpp::as<Rcpp::List>(sexp);
21 
22  return Bar(
23  Rcpp::as<std::string>(list["name"]),
24  Rcpp::as<Foo>(list["foo"])
25  );
26  }
27 }
28 
SEXP wrap(const Bar &bar)
Definition: bar.h:19
std::string name
Definition: bar.h:24
Foo foo
Definition: bar.h:25
Bar as(SEXP sexp)