/usr/share/quantlib-python/money.i is in quantlib-python 1.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /*
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
Copyright (C) 2003, 2004, 2005 StatPro Italia srl
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
#ifndef quantlib_money_i
#define quantlib_money_i
%include currencies.i
%{
using QuantLib::Money;
%}
class Money {
#if defined(SWIGRUBY)
%rename("conversionType=") setConversionType;
%rename("baseCurrency=") setBaseCurrency;
#elif defined(SWIGMZSCHEME) || defined(SWIGGUILE)
%rename("conversion-type-set!") setConversionType;
%rename("base-currency-set!") setBaseCurrency;
#elif defined(SWIGJAVA)
%rename("compare") __cmp__;
#endif
public:
Money(const Currency& currency, Decimal value);
Money(Decimal value, const Currency& currency);
const Currency& currency() const;
Decimal value() const;
Money rounded() const;
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA)
Money operator+() const;
Money operator-() const;
%extend {
Money operator+(const Money& m) { return *self+m; }
Money operator-(const Money& m) { return *self-m; }
Money operator*(Decimal x) { return *self*x; }
Money operator/(Decimal x) { return *self/x; }
Decimal operator/(const Money& m) { return *self/m; }
#if defined(SWIGPYTHON)
Money __rmul__(Decimal x) { return *self*x; }
#endif
int __cmp__(const Money& other) {
if (*self < other)
return -1;
else if (*self == other)
return 0;
else
return 1;
}
std::string __str__() {
std::ostringstream out;
out << *self;
return out.str();
}
}
#endif
enum ConversionType { NoConversion,
BaseCurrencyConversion,
AutomatedConversion };
%extend {
static void setConversionType(ConversionType type) {
Money::conversionType = type;
}
static void setBaseCurrency(const Currency& c) {
Money::baseCurrency = c;
}
}
};
#if defined(SWIGMZSCHEME) || defined(SWIGGUILE)
%rename("Money+") Money_plus;
%rename("Money-") Money_minus;
%rename("Money*") Money_times;
%rename("Money/") Money_divided;
%rename("Money=?") Money_equal;
%rename("Money<?") Money_less;
%rename("Money<=?") Money_less_equal;
%rename("Money>?") Money_greater;
%rename("Money>=?") Money_greater_equal;
%inline %{
Money Money_plus(const Money& m1, const Money& m2) {
return m1+m2;
}
Money Money_minus(const Money& m1, const Money& m2) {
return m1-m2;
}
Money Money_times(const Money& m1, Decimal x) {
return m1*x;
}
Money Money_times(Decimal x, const Money& m2) {
return m2*x;
}
Money Money_divided(const Money& m1, Decimal x) {
return m1/x;
}
Decimal Money_divided(const Money& m1, const Money& m2) {
return m1/m2;
}
bool Money_equal(const Money& d1, const Money& d2) {
return d1 == d2;
}
bool Money_less(const Money& d1, const Money& d2) {
return d1 < d2;
}
bool Money_less_equal(const Money& d1, const Money& d2) {
return d1 <= d2;
}
bool Money_greater(const Money& d1, const Money& d2) {
return d1 > d2;
}
bool Money_greater_equal(const Money& d1, const Money& d2) {
return d1 >= d2;
}
%}
#endif
#endif
|