|
From: Luigi B. <lui...@gm...> - 2009-10-12 15:17:20
|
On Mon, 2009-10-12 at 16:42 +0200, Ferdinando Ametrano wrote:
> I could provide a non-explicit string constructor for
> QuantLib::Period(std::string s) as solution, but something tells me
> Luigi might frown at this (or God forbid, even balk at this ;-)
At the very least, I'd raise an eyebrow :)
Would it be feasible to use a little adapter class in QLA? Something
like:
class QlaPeriod {
QuantLib::Period p_;
public:
// input in as many ways as you like...
QlaPeriod(QuantLib::Period p) : p_(p) {}
QlaPeriod(std::string s) : p_(PeriodParser::parse(s)) {}
// ...then pass it wherever a period is needed:
operator QuantLib::Period() const { return p_; }
};
Your various ObjectHandler::convert2 functions would return QlaPeriods
and the underlying functions would accept them after the automatic
conversion.
Luigi
P.S. On a related note, how about the hideous 0*Years vs 0*Days thing?
I'm still shaking from that one :)
--
I'd never join any club that would have the likes of me as a member.
-- Groucho Marx
|