File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626#include < qle/quantext.hpp>
2727%}
2828
29+ %include qle_common.i
2930%include qle_calendars.i
3031%include qle_cashflows.i
3132%include qle_indexes.i
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright (C) 2023 Quaternion Risk Management Ltd
3+ All rights reserved.
4+
5+ This file is part of ORE, a free-software/open-source library
6+ for transparent pricing and risk analysis - http://opensourcerisk.org
7+
8+ ORE is free software: you can redistribute it and/or modify it
9+ under the terms of the Modified BSD License. You should have received a
10+ copy of the license along with this program.
11+ The license is also available online at <http://opensourcerisk.org>
12+
13+ This program is distributed on the basis that it will form a useful
14+ contribution to risk analytics and model standardisation, but WITHOUT
15+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16+ FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17+ */
18+ #ifndef qle_common_i
19+ #define qle_common_i
20+
21+ %{
22+ #include < boost/optional.hpp>
23+ %}
24+
25+
26+ #if defined(SWIGPYTHON)
27+ %typemap(in) boost::optional<bool > %{
28+ if ($input == Py_None) {
29+ $1 = boost::optional<bool >();
30+ }
31+ else if ($input == Py_True){
32+ $1 = boost::optional<bool >(true );
33+ } else {
34+ $1 = boost::optional<bool >(false );
35+ }
36+ %}
37+
38+ %typemap(out) boost::optional<bool > %{
39+ if ($1 ) {
40+ $result = PyBool_FromBool (*$1 );
41+ }
42+ else {
43+ $result = Py_None;
44+ Py_INCREF (Py_None);
45+ }
46+ %}
47+
48+ %typecheck (QL_TYPECHECK_BOOL) boost::optional<bool > {
49+ if (PyBool_Check ($input) || Py_None == $input)
50+ $1 = 1 ;
51+ else
52+ $1 = 0 ;
53+ }
54+
55+ #endif
56+
57+ #endif
You can’t perform that action at this time.
0 commit comments