[Rquantlib-commits] r249 - pkg/RQuantLib/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 15 05:18:51 CEST 2010


Author: edd
Date: 2010-06-15 05:18:51 +0200 (Tue, 15 Jun 2010)
New Revision: 249

Modified:
   pkg/RQuantLib/src/calendars.cpp
Log:
return explicit NULL if holidayList is empty


Modified: pkg/RQuantLib/src/calendars.cpp
===================================================================
--- pkg/RQuantLib/src/calendars.cpp	2010-06-15 03:18:19 UTC (rev 248)
+++ pkg/RQuantLib/src/calendars.cpp	2010-06-15 03:18:51 UTC (rev 249)
@@ -45,12 +45,12 @@
         pcal = new Germany(Germany::Settlement);
     } else if (calstr == "Germany/Xetra") {
         pcal = new Germany(Germany::Xetra);
-        } else if (calstr == "Germany/Eurex") {
+    } else if (calstr == "Germany/Eurex") {
         pcal = new Germany(Germany::Eurex);
         
     } else if (calstr == "Italy" || calstr == "Italy/Settlement") {
         pcal = new Italy(Italy::Settlement);
-        } else if (calstr == "Italy/Exchange") {
+    } else if (calstr == "Italy/Exchange") {
         pcal = new Italy(Italy::Exchange);
         
     } else if (calstr == "Japan" || calstr == "Japan/Settlement") {
@@ -63,7 +63,7 @@
 
     } else if (calstr == "UnitedKingdom" || calstr == "UnitedKingdom/Settlement") {
         pcal = new UnitedKingdom(UnitedKingdom::Settlement);
-        } else if (calstr == "UnitedKingdom/Exchange") {
+    } else if (calstr == "UnitedKingdom/Exchange") {
         pcal = new UnitedKingdom(UnitedKingdom::Exchange);
     } else if (calstr == "UnitedKingdom/Metals") {
         pcal = new UnitedKingdom(UnitedKingdom::Metals);
@@ -72,7 +72,7 @@
         pcal = new UnitedStates(UnitedStates::Settlement);
     } else if (calstr == "UnitedStates/NYSE") {
         pcal = new UnitedStates(UnitedStates::NYSE);
-        } else if (calstr == "UnitedStates/GovernmentBond") {
+    } else if (calstr == "UnitedStates/GovernmentBond") {
         pcal = new UnitedStates(UnitedStates::GovernmentBond);
     } else if (calstr == "UnitedStates/NERC") {
         pcal = new UnitedStates(UnitedStates::NERC);
@@ -361,12 +361,16 @@
                                                        Date(dateFromR(d2)), 
                                                        iw == 1 ? true : false);                
 
-        RcppDateVector dv( holidays.size() );
-        for (unsigned int i = 0; i< holidays.size(); i++){
-            dv.set(i, RcppDate(holidays[i].month(), holidays[i].dayOfMonth(), holidays[i].year()));
+        delete pcal;
+        if (holidays.size() > 0) {
+            RcppDateVector dv( holidays.size() );
+            for (unsigned int i = 0; i< holidays.size(); i++){
+                dv.set(i, RcppDate(holidays[i].month(), holidays[i].dayOfMonth(), holidays[i].year()));
+            }
+            return Rcpp::wrap(dv);
+        } else {
+            return R_NilValue;
         }
-        delete pcal;
-        return Rcpp::wrap(dv);
 
     } catch(std::exception &ex) { 
         forward_exception_to_r(ex); 



More information about the Rquantlib-commits mailing list