convert an Rcpp container constructor to an R argument (returns empty string if no conversion possible)
| 2707 | // convert an Rcpp container constructor to an R argument |
| 2708 | // (returns empty string if no conversion possible) |
| 2709 | std::string cppConstructorArgToRArg(const std::string& cppArg) { |
| 2710 | |
| 2711 | // map Rcpp containers to R default initializers |
| 2712 | static std::map<std::string, std::string> RcppContainerToR; |
| 2713 | RcppContainerToR.insert(std::make_pair("NumericVector", "numeric")); |
| 2714 | RcppContainerToR.insert(std::make_pair("DoubleVector", "numeric")); |
| 2715 | RcppContainerToR.insert(std::make_pair("CharacterVector", "character")); |
| 2716 | RcppContainerToR.insert(std::make_pair("IntegerVector", "integer")); |
| 2717 | RcppContainerToR.insert(std::make_pair("LogicalVector", "logical")); |
| 2718 | RcppContainerToR.insert(std::make_pair("ComplexVector", "complex")); |
| 2719 | |
| 2720 | // for each entry in the map above, see if we find it; if we do, |
| 2721 | // return the R version |
| 2722 | typedef std::map<std::string, std::string>::const_iterator Iterator; |
| 2723 | for (Iterator it = RcppContainerToR.begin(); it != RcppContainerToR.end(); ++it) { |
| 2724 | size_t loc = cppArg.find(it->first); |
| 2725 | if (loc != std::string::npos) { |
| 2726 | return it->second + cppArg.substr(it->first.size(), std::string::npos); |
| 2727 | } |
| 2728 | } |
| 2729 | |
| 2730 | return std::string(); // #nocov end |
| 2731 | |
| 2732 | } |
| 2733 | |
| 2734 | // convert a C++ argument value to an R argument value (returns empty |
| 2735 | // string if no conversion is possible) |
no test coverage detected