[Rcpp-commits] r3836 - in pkg/RcppBDT: . R inst/include src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Oct 25 04:53:00 CEST 2012
Author: edd
Date: 2012-10-25 04:53:00 +0200 (Thu, 25 Oct 2012)
New Revision: 3836
Modified:
pkg/RcppBDT/ChangeLog
pkg/RcppBDT/R/zzz.R
pkg/RcppBDT/inst/include/RcppBDT.h
pkg/RcppBDT/inst/include/RcppBDTdt.h
pkg/RcppBDT/src/RcppBDTdt.cpp
Log:
comparison for bdtDt
Modified: pkg/RcppBDT/ChangeLog
===================================================================
--- pkg/RcppBDT/ChangeLog 2012-10-25 01:49:16 UTC (rev 3835)
+++ pkg/RcppBDT/ChangeLog 2012-10-25 02:53:00 UTC (rev 3836)
@@ -5,6 +5,8 @@
on Rcpp::wrap() for conversion, rather than always directly converting
* src/RcppBDTdt.cpp: Idem
+ * src/RcppBDTdt.cpp: Comparison support for bdtDt type
+
* man/bdtDu.Rd: Document new methods for Arithmetic and Comparison
* man/bdtPt.Rd: Idem
Modified: pkg/RcppBDT/R/zzz.R
===================================================================
--- pkg/RcppBDT/R/zzz.R 2012-10-25 01:49:16 UTC (rev 3835)
+++ pkg/RcppBDT/R/zzz.R 2012-10-25 02:53:00 UTC (rev 3836)
@@ -85,4 +85,11 @@
setMethod("Compare", signature(e1 = "Rcpp_bdtPt", e2 = "Rcpp_bdtPt"),
function(e1, e2) compare_bdtPt_bdtPt(e1, e2, .Generic))
+ setMethod("Compare", signature(e1 = "Rcpp_bdtDt", e2 = "Rcpp_bdtDt"),
+ function(e1, e2) compare_bdtDt_bdtDt(e1, e2, .Generic))
+ setMethod("Compare", signature(e1 = "Rcpp_bdtDt", e2 = "Date"),
+ function(e1, e2) compare_bdtDt_bdtDt(e1, new(bdtDt, e2), .Generic))
+# setMethod("Compare", signature(e1 = "Date", e2 = "Rcpp_bdtDt"), ,
+# function(e1, e2) compare_bdtDt_bdtDt(new(bdtDt, e1), e2, .Generic))
+
})
Modified: pkg/RcppBDT/inst/include/RcppBDT.h
===================================================================
--- pkg/RcppBDT/inst/include/RcppBDT.h 2012-10-25 01:49:16 UTC (rev 3835)
+++ pkg/RcppBDT/inst/include/RcppBDT.h 2012-10-25 02:53:00 UTC (rev 3836)
@@ -25,9 +25,11 @@
#include <RcppCommon.h>
// forward declarations and helping module classes
+class bdtDt;
class bdtDu;
class bdtPt;
RCPP_EXPOSED_CLASS(bdtDu)
+RCPP_EXPOSED_CLASS(bdtDt)
RCPP_EXPOSED_CLASS(bdtPt)
// Setting this variable enables use of nanoseconds (as opposed to microseconds)
Modified: pkg/RcppBDT/inst/include/RcppBDTdt.h
===================================================================
--- pkg/RcppBDT/inst/include/RcppBDTdt.h 2012-10-25 01:49:16 UTC (rev 3835)
+++ pkg/RcppBDT/inst/include/RcppBDTdt.h 2012-10-25 02:53:00 UTC (rev 3836)
@@ -77,6 +77,7 @@
private:
boost::gregorian::date m_dt; // private Boost date instance
+ friend bool compare_bdtDt_bdtDt(const bdtDt&, const bdtDt&, std::string);
};
#endif
Modified: pkg/RcppBDT/src/RcppBDTdt.cpp
===================================================================
--- pkg/RcppBDT/src/RcppBDTdt.cpp 2012-10-25 01:49:16 UTC (rev 3835)
+++ pkg/RcppBDT/src/RcppBDTdt.cpp 2012-10-25 02:53:00 UTC (rev 3836)
@@ -67,6 +67,25 @@
return fdab.get_date(dt);
}
+
+bool compare_bdtDt_bdtDt( const bdtDt& e1, const bdtDt& e2, std::string op ){
+ if( !op.compare( "==" ) ){
+ return e1.m_dt == e2.m_dt ;
+ } else if( !op.compare( "!=" ) ){
+ return e1.m_dt != e2.m_dt ;
+ } else if( !op.compare( ">" ) ){
+ return e1.m_dt > e2.m_dt ;
+ } else if( !op.compare( "<" ) ){
+ return e1.m_dt < e2.m_dt ;
+ } else if( !op.compare( ">=" ) ){
+ return e1.m_dt >= e2.m_dt ;
+ } else if( !op.compare( "<=" ) ){
+ return e1.m_dt <= e2.m_dt ;
+ }
+ Rf_error( "unknown operator" ) ;
+ return R_NilValue ;
+}
+
RCPP_MODULE(bdtDtMod) {
Rcpp::class_<bdtDt>("bdtDt")
@@ -118,6 +137,8 @@
;
+ Rcpp::function("compare_bdtDt_bdtDt", &compare_bdtDt_bdtDt);
+
}
More information about the Rcpp-commits
mailing list