154 "impossible addition between " << *
this <<
170 "impossible addition between " << *
this <<
187 "impossible addition between " << *
this <<
203 "impossible addition between " << *
this <<
252 *
this <<
" cannot be divided by " <<
n);
262 std::pair<Integer,Integer> daysMinMax(
const Period& p) {
280 if (p.
length()==0)
return 0.0;
284 QL_FAIL(
"cannot convert Days into Years");
286 QL_FAIL(
"cannot convert Weeks into Years");
297 if (p.
length()==0)
return 0.0;
301 QL_FAIL(
"cannot convert Days into Months");
303 QL_FAIL(
"cannot convert Weeks into Months");
314 if (p.
length()==0)
return 0.0;
322 QL_FAIL(
"cannot convert Months into Weeks");
324 QL_FAIL(
"cannot convert Years into Weeks");
331 if (p.
length()==0)
return 0.0;
339 QL_FAIL(
"cannot convert Months into Days");
341 QL_FAIL(
"cannot convert Years into Days");
368 std::pair<Integer, Integer> p1lim = daysMinMax(p1);
369 std::pair<Integer, Integer> p2lim = daysMinMax(p2);
371 if (p1lim.second < p2lim.first)
373 else if (p1lim.first > p2lim.second)
376 QL_FAIL(
"undecidable comparison between " << p1 <<
" and " << p2);
407 switch (holder.
p.
units()) {
409 return out <<
n << (
n == 1 ?
" day" :
" days");
411 return out <<
n << (
n == 1 ?
" week" :
" weeks");
413 return out <<
n << (
n == 1 ?
" month" :
" months");
415 return out <<
n << (
n == 1 ?
" year" :
" years");
424 switch (holder.
p.
units()) {
426 return out <<
n <<
"D";
428 return out <<
n <<
"W";
430 return out <<
n <<
"M";
432 return out <<
n <<
"Y";
Period & operator+=(const Period &)
Period & operator/=(Integer)
Period & operator*=(Integer)
Period & operator-=(const Period &)
Frequency frequency() const
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Frequency
Frequency of events.
TimeUnit
Units used to describe time periods.
@ Biweekly
every second week
@ EveryFourthWeek
every fourth week
@ OtherFrequency
some other unknown frequency
@ Bimonthly
every second month
@ Once
only once, e.g., a zero-coupon
@ Quarterly
every third month
@ EveryFourthMonth
every fourth month
@ NoFrequency
null frequency
detail::short_period_holder short_period(const Period &p)
output periods in short format (e.g. "2w")
detail::long_period_holder long_period(const Period &p)
output periods in long format (e.g. "2 weeks")
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
std::ostream & operator<<(std::ostream &out, const short_date_holder &holder)
Quantity operator-(const Quantity &m1, const Quantity &m2)
Real weeks(const Period &p)
bool operator<(const Quantity &m1, const Quantity &m2)
Real months(const Period &p)
Real years(const Period &p)
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
Quantity operator+(const Quantity &m1, const Quantity &m2)
Real days(const Period &p)
Real operator/(const Quantity &m1, const Quantity &m2)
period- and frequency-related classes and enumerations