// [[Rcpp::export]] std::vector<bool> isHoliday(std::string calendar, std::vector<QuantLib::Date> dates) { boost::shared_ptr<QuantLib::Calendar> pcal(getCalendar(calendar)); int n = dates.size(); std::vector<bool> hdays(n); for (int i=0; i<n; i++) { hdays[i] = pcal->isHoliday(dates[i]); } return hdays; }
RcppExport SEXP isHoliday(SEXP calSexp, SEXP dateSexp){ try { boost::shared_ptr<QuantLib::Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) ); Rcpp::DateVector dates = Rcpp::DateVector(dateSexp); int n = dates.size(); std::vector<int> hdays(n); for (int i=0; i<n; i++) { QuantLib::Date day( dateFromR(dates[i]) ); hdays[i] = pcal->isHoliday(day); } return Rcpp::wrap(hdays); } catch(std::exception &ex) { forward_exception_to_r(ex); } catch(...) { ::Rf_error("c++ exception (unknown reason)"); } return R_NilValue; }