00001
00002
00003
00004
00005
00006
00007 #include <string>
00008 #include <vector>
00009 #include <iostream>
00010
00011 #include <R.h>
00012 #include <Rembedded.h>
00013 #include <Rversion.h>
00014 #include <Rdefines.h>
00015 #ifndef WIN32
00016 #define R_INTERFACE_PTRS
00017 #include <Rinterface.h>
00018 #endif
00019 #include <R_ext/Parse.h>
00020
00021 #include "MemBuf.h"
00022
00023 class RInside {
00024 private:
00025 MemBuf mb_m;
00026
00027 bool verbose_m;
00028
00029 void init_tempdir(void);
00030 void init_rand(void);
00031 void autoloads(void);
00032
00033 public:
00034 int parseEval(const std::string & line, SEXP &ans);
00035 int parseEvalQ(const std::string & line);
00036
00037 void assign(const std::vector< std::vector< double > > & mat, const std::string & nam);
00038 void assign(const std::vector< std::vector< int > > & mat, const std::string & nam);
00039 void assign(const std::vector< std::string > & vec, const std::string & nam);
00040 void assign(const std::vector< double > & vec, const std::string & nam);
00041 void assign(const std::vector< int > & vec, const std::string & nam);
00042 void assign(const std::string & txt, const std::string & nam);
00043
00044 RInside(const int argc, const char* const argv[]);
00045 ~RInside();
00046 };
00047
00048
00049 inline void logTxtFunction(const char* file, const char* line, const char* expression, const bool verbose) {
00050 if (verbose) {
00051 std::cout << file << ":" << line << " expression: " << expression << std::endl;
00052 }
00053 }
00054
00055
00056 #define logTxt(x, b)