RInside Version 0.2.16
foo_rcpp_wrapper_definitions.h
Go to the documentation of this file.
1
#pragma once
2
3
/*
4
* Foo objects are wrapped into a trivial list. More complicated objects should either
5
* map to a similar native R type or possibly create their own S4 definitions.
6
*/
7
8
namespace
Rcpp
{
9
// Foo
10
template
<> SEXP
wrap
(
const
Foo
&foo) {
11
Rcpp::List list;
12
13
list[
"name"
] = foo.
name
;
14
list[
"a"
] = foo.
a
;
15
list[
"b"
] = foo.
b
;
16
17
return
Rcpp::wrap
(list);
18
}
19
template
<>
Foo
as
(SEXP sexp) {
20
Rcpp::List list = Rcpp::as<Rcpp::List>(sexp);
21
22
return
Foo
(
23
Rcpp::as<std::string>(list[
"name"
]),
24
Rcpp::as<int>(list[
"a"
]),
25
Rcpp::as<int>(list[
"b"
])
26
);
27
}
28
}
29
Foo
Definition:
foo.h:17
Foo::name
std::string name
Definition:
foo.h:22
Rcpp::wrap
SEXP wrap(const Bar &bar)
Definition:
bar_rcpp_wrapper_definitions.h:11
Foo::a
int32_t a
Definition:
foo.h:23
Foo::b
int32_t b
Definition:
foo.h:23
Rcpp
Definition:
bar_rcpp_wrapper_declarations.h:4
Rcpp::as
Bar as(SEXP sexp)
Definition:
bar_rcpp_wrapper_definitions.h:19
inst
examples
sandboxed_server
datatypes
foo_rcpp_wrapper_definitions.h
Generated on Wed Mar 11 2020 22:27:24 for RInside Version 0.2.16 by
1.8.13