default 0*Days value for Period in QLXL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

default 0*Days value for Period in QLXL

Ferdinando M. Ametrano-3
Hi Eric and Plamen

I am unable to provide zero days as default value for Period in the XML specification file.
The problem is that the autogenerated code has two different constructs requiring different values ("0D" or 0*QuantLib::Days) so they cannot be satisfied at the same time.

        std::string ForwardStartCpp = ObjectHandler::convert2<std::string>(
            ObjectHandler::ConvertOper(*ForwardStart), "ForwardStart", "0D");
        [...]
        QuantLib::Period ForwardStartLib = ObjectHandler::convert2<QuantLib::Period>(
            ObjectHandler::ConvertOper(*ForwardStart), "ForwardStart", 0*QuantLib::Days);

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 ;-)

Any suggestion or quick fix ?

ciao -- Nando

RSS feed: http://www.google.com/reader/shared/ferdinando.ametrano


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: default 0*Days value for Period in QLXL

Luigi Ballabio
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



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: default 0*Days value for Period in QLXL

Ferdinando M. Ametrano-3
On Mon, Oct 12, 2009 at 5:16 PM, Luigi Ballabio
<[hidden email]> wrote:
> Would it be feasible to use a little adapter class in QLA?
It would, but it's probably unneeded. It's arcane to me, but I'm
pretty sure autogenerated code can be smarter than it is now.

btw what's against Period(std::string) ?

> P.S. On a related note, how about the hideous 0*Years vs 0*Days thing?
> I'm still shaking from that one :)

I'll get back on this as soon as I'll get more empirical evidences

ciao -- Nando

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev