#include #include #include typedef long TDate; class CurveObject { public: CurveObject(TDate baseDate, std::vector dates, std::vector rates, double basis, long dayCountConv) { _ptr = JpmcdsMakeTCurve(baseDate, dates.data(), rates.data(), dates.size(), basis, dayCountConv); } CurveObject(TCurve* ptr) { _ptr = ptr; } CurveObject(const CurveObject& other) { _ptr = JpmcdsCopyCurve(other._ptr); } CurveObject(CurveObject&& other) : _ptr(other._ptr) { other._ptr = nullptr; } CurveObject& operator=(const CurveObject& other) { if( this != &other) { JpmcdsFreeTCurve(_ptr); _ptr = JpmcdsCopyCurve(other._ptr); } return *this; } CurveObject& operator=(CurveObject&& other) { if( this != &other) { JpmcdsFreeTCurve(_ptr); _ptr = other._ptr; other._ptr = nullptr; } return *this; } TCurve* data() { return _ptr; } typedef TRatePt* iterator; typedef const TRatePt* const_iterator; iterator begin() { return _ptr->fArray; } iterator end() {return &_ptr->fArray[_ptr->fNumItems];} int size() { return _ptr->fNumItems; } TDate BaseDate() { return _ptr->fBaseDate; } double Basis() { return _ptr->fBasis; } double ForwardZeroPrice(TDate d2, TDate d1); double ForwardZeroPrice(TDate d2); ~CurveObject() { if(_ptr != nullptr) { JpmcdsFreeTCurve(_ptr); } } private: TCurve* _ptr; }; double CurveObject::ForwardZeroPrice(TDate d2, TDate d1) { return JpmcdsForwardZeroPrice(_ptr, d1, d2); } double CurveObject::ForwardZeroPrice(TDate d2) { return JpmcdsForwardZeroPrice(_ptr, _ptr->fBaseDate, d2); }