forked from tidyverse/dplyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.cpp
40 lines (34 loc) · 928 Bytes
/
init.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "pch.h"
#include <dplyr/main.h>
#include <dplyr/registration.h>
#include <dplyr/HybridHandler.h>
using namespace Rcpp;
using namespace dplyr;
SEXP get_cache() {
static SEXP cache = 0;
if (!cache) {
SEXP vec = PROTECT(Rf_allocVector(VECSXP, 2));
SEXP date_classes = PROTECT(Rf_mkString("Date"));
SET_VECTOR_ELT(vec, 0, date_classes);
CharacterVector time_classes = CharacterVector::create("POSIXct", "POSIXt");
SET_VECTOR_ELT(vec, 1, time_classes);
UNPROTECT(2);
R_PreserveObject(vec);
cache = vec;
}
return cache;
}
// [[Rcpp::interfaces(cpp)]]
// [[Rcpp::export]]
SEXP get_date_classes() {
return VECTOR_ELT(get_cache(), 0);
}
// [[Rcpp::interfaces(cpp)]]
// [[Rcpp::export]]
SEXP get_time_classes() {
return VECTOR_ELT(get_cache(), 1);
}
// work around a problem (?) in Rcpp
// [[Rcpp::interfaces(cpp)]]
// [[Rcpp::export]]
DataFrame build_index_cpp(DataFrame data);