I will send the complete code and bold the part where it get stuck. C++ code template created :
namespace Rcpp{ template<> te::da::DataSourceInfo as (SEXP datasource){ * Rcpp::List dataSource (datasource);* te::da::DataSourceInfo ds; Rcpp::String typestring = (dataSource["type"]); std::string tstring = typestring; if(tstring == "OGR"){ std::map<std::string, std::string> connInfo; Rcpp::List cInfo = dataSource["connInfo"] ; connInfo.insert(std::pair<std::string,Rcpp::String>("URI",cInfo["URI"])); ds.setConnInfo(connInfo); ds.setType("OGR"); } return ds } } Here is where I try to use the template SEXP getTrajectory(SEXP datasource, SEXP dataset){ try { //Indicates the data source te::da::DataSourceInfo dsinfo = Rcpp::as<te::da::DataSourceInfo>(datasource); [.....] } } Here is the R list I send in the "datasource" $connInfo [1] "con" $title [1] "titl" $accessDriver [1] "ad" $title [1] "typ" I send using this method : setMethod( f = "getTrajectory", signature = c("DataSourceInfo","DataSetInfo"), definition = function(datasource, dataset) { loadPackages() dsource <- list("connInfo"=datasource@connInfo,"title"=datasource@title ,"accessDriver"=datasource@accessDriver,"title"=datasource@type) print(dsource) dset <- list("tableName"=dataset@tableName) c(dset,"phTimeName"=dataset@phTimeName) c(dset,"geomName"=dataset@geomName) c(dset,"trajId"=dataset@trajId) c(dset,"trajName"=dataset@trajName) c(dset,"objId"=dataset@trajName) traj1 <- getTrajectory(datasource,dataset) return (traj1) } ) Is this enough and understandable ? 2016-02-17 20:58 GMT-02:00 Dirk Eddelbuettel <e...@debian.org>: > > On 17 February 2016 at 20:28, Diego Monteiro wrote: > | Hello, I'm trying to implement a conversion from a R type into my own > Type , > | but in the beginning I am getting an error. > | > | The code is like the following : > | template<> MyType as (SEXP x){ > | > | Rcpp::List dataSource(x); > | [.....] > | } > | > | This is the ERROR: > | An exception has occurried: could not convert using R function : as.list > | > | "x" is a char list. > | > | Thanks for any help. > > Can you distill things to a minimal working example? It is pretty hard for > us to say something meaningful otherwise. > > Dirk > > -- > http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org >
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel