RInside Version 0.2.16
RInside_C.cpp
Go to the documentation of this file.
1 
2 // RInside_C.cpp: R/C++ interface class library -- Easier R embedding into C
3 //
4 // Copyright (C) 2020 - Lance Bachmeier and Dirk Eddelbuettel
5 //
6 // This file is part of RInside.
7 //
8 // RInside is free software: you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // RInside is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with RInside. If not, see <http://www.gnu.org/licenses/>.
20 
21 #include <RInside.h>
22 
23 RInside *rr = NULL;
24 
25 extern "C" {
26  void setupRinC() {
27  if (rr == NULL)
28  rr = new RInside;
29  }
30 
31  void passToR(SEXP x, char * name) {
32  if (rr != NULL)
33  rr->assign(x, std::string(name));
34  }
35 
36  SEXP evalInR(char * cmd) {
37  if (rr != NULL)
38  return rr->parseEval(std::string(cmd));
39  else
40  return R_NilValue;
41  }
42 
43  void evalQuietlyInR(char * cmd) {
44  if (rr != NULL)
45  rr->parseEvalQ(std::string(cmd));
46  }
47 
48  void teardownRinC() {
49  if (rr != NULL) {
50  delete rr;
51  rr = NULL;
52  }
53  }
54 }
SEXP evalInR(char *cmd)
Definition: RInside_C.cpp:36
void evalQuietlyInR(char *cmd)
Definition: RInside_C.cpp:43
void passToR(SEXP x, char *name)
Definition: RInside_C.cpp:31
void setupRinC()
Definition: RInside_C.cpp:26
void parseEvalQ(const std::string &line)
Definition: RInside.cpp:384
int parseEval(const std::string &line, SEXP &ans)
Definition: RInside.cpp:326
RInside * rr
Definition: RInside_C.cpp:23
void assign(const T &object, const std::string &nam)
Definition: RInside.h:78
void teardownRinC()
Definition: RInside_C.cpp:48