00001 00009 #ifndef TYPING_QL 00010 #define TYPING_QL 00011 00012 #include <boost/date_time/gregorian/formatters.hpp> 00013 00014 #include <ql/quantlib.hpp> 00015 00016 namespace eepgwde { namespace detail { namespace i0 { 00017 00018 namespace ql = QuantLib; 00019 00043 00044 00046 template <typename U> 00047 typename enable_if<boost::is_same<ql::Date, U>, U>::type 00048 null1(dummy<0> = 2) { 00049 return QuantLib::Date(1, static_cast<ql::Month>(1), 1901); 00050 } 00051 00053 template <typename U> 00054 std::string 00055 ys(typename enable_if<boost::is_same<ql::Date, U>, U>::type, 00056 const boost::any &o, dummy<1> = 1) 00057 throw (std::domain_error &) { 00058 U r(boost::any_cast<U>(o)); 00059 boost::gregorian::date bdt(r.year(), r.month(), r.dayOfMonth()); 00060 return boost::gregorian::to_simple_string(bdt); 00061 } 00062 00064 template <typename U> 00065 U xs(typename enable_if<boost::is_same<ql::Date, U>, U>::type, 00066 const std::string & s, dummy<1> = 2) 00067 throw (std::domain_error &) { 00068 boost::gregorian::date dt = boost::gregorian::from_simple_string(s); 00069 U qdt(dt.day(), static_cast<ql::Month>(static_cast<int>(dt.month())), dt.year()); 00070 return qdt; 00071 } 00072 00075 00076 }}} 00077 00078 #endif