RInside Version 0.2.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rinside_module_sample0.cpp
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4; -*-
2 //
3 // Simple example showing how expose a C++ function
4 //
5 // Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
6 
7 #include <RInside.h> // for the embedded R via RInside
8 
9 // a c++ function we wish to expose to R
10 const char* hello( std::string who ){
11  std::string result( "hello " ) ;
12  result += who ;
13  return result.c_str() ;
14 }
15 
16 // RCPP_MODULE(bling){
17 // using namespace Rcpp ;
18 // function( "hello", &hello );
19 // }
20 
21 int main(int argc, char *argv[]) {
22 
23  // create an embedded R instance -- and load Rcpp so that modules work
24  RInside R(argc, argv, true);
25 
26  // load the bling module
27  // R["bling"] = LOAD_RCPP_MODULE(bling) ;
28 
29  // call it and display the result
30  Rcpp::Rcout << "** rinside_module_sample0 is currently disabled.\n";
31  if (FALSE) {
32  std::string result = R.parseEval("bling$hello('world')") ;
33  std::cout << "bling$hello( 'world') = '" << result << "'" << std::endl ;
34  }
35  exit(0);
36 }
37 
int main(int argc, char *argv[])
int parseEval(const std::string &line, SEXP &ans)
Definition: RInside.cpp:308
const char * hello(std::string who)