[QuantLibAddin-cvs] QuantLibAddin/qlo conversions.hpp,1.11,1.12
Brought to you by:
ericehlers,
nando
|
From: Eric E. <eri...@us...> - 2006-07-25 16:33:37
|
Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv11058/qlo Modified Files: conversions.hpp Log Message: additional support for IDs which may be Enumerations or Objects Index: conversions.hpp =================================================================== RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/conversions.hpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** conversions.hpp 21 Jul 2006 11:24:27 -0000 1.11 --- conversions.hpp 25 Jul 2006 16:33:34 -0000 1.12 *************** *** 98,117 **** } ! // Accept a string which is the ID of either ! // 1) A Euribor Enumerated Class ! // 2) An Object of class Index (or its derived classes e.g. Xibor, Euribor) ! template <class qlClass, class qloClass> ! inline boost::shared_ptr<qlClass> convertEuribor( const std::string &id, bool failIfEmpty = false) { if (id.empty()) { if (failIfEmpty) ! QL_FAIL("attempt to retrieve euribor object with null string as ID"); else return boost::shared_ptr<qlClass>(); } ! if (QuantLibAddin::Create<boost::shared_ptr<QuantLib::Euribor> >().checkType(id)) { ! boost::shared_ptr<QuantLib::Euribor> ret = ! QuantLibAddin::Create<boost::shared_ptr<QuantLib::Euribor> >()(id); boost::shared_ptr<qlClass> ret2 = boost::dynamic_pointer_cast<qlClass>(ret); --- 98,117 ---- } ! // enumOrObject - accept a string which is the ID of either ! // and Enumerated Class or an object in the repository, ! // and return the appropriate object ! template <class enumClass, class qlClass, class qloClass> ! inline boost::shared_ptr<qlClass> enumOrObject( const std::string &id, bool failIfEmpty = false) { if (id.empty()) { if (failIfEmpty) ! QL_FAIL("attempt to retrieve object with null string as ID"); else return boost::shared_ptr<qlClass>(); } ! if (QuantLibAddin::Create<boost::shared_ptr<enumClass> >().checkType(id)) { ! boost::shared_ptr<enumClass> ret = ! QuantLibAddin::Create<boost::shared_ptr<enumClass> >()(id); boost::shared_ptr<qlClass> ret2 = boost::dynamic_pointer_cast<qlClass>(ret); |