File: rcppversion.cpp

package info (click to toggle)
rcpp 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,480 kB
  • sloc: cpp: 27,436; ansic: 7,778; sh: 53; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <Rcpp.h>

// [[Rcpp::export]]
Rcpp::List checkVersion(Rcpp::IntegerVector v) {

    // incoming, we expect v to have been made by
    //     as.integer(unlist(strsplit(as.character(packageVersion("Rcpp")), "\\.")))
    // yielding eg
    //     c(1L, 0L, 3L, 1L)

    // ensure that length is four, after possibly appending 0
    if (v.size() == 3) v.push_back(0);
    if (v.size() == 4) v.push_back(0);
    if (v.size() > 5) Rcpp::stop("Expect vector with up to five elements.");

    return Rcpp::List::create(Rcpp::Named("def_ver")     = RCPP_VERSION,
                              Rcpp::Named("def_str")     = RCPP_VERSION_STRING,
                              Rcpp::Named("cur_ver")     = Rcpp_Version(v[0], v[1], v[2]),
                              Rcpp::Named("def_dev_ver") = RCPP_DEV_VERSION,
                              Rcpp::Named("def_dev_str") = RCPP_DEV_VERSION_STRING,
                              Rcpp::Named("cur_dev_ver") = RcppDevVersion(v[0], v[1], v[2], v[3]));
}