-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaddindynamic2_8cpp-example.html
More file actions
212 lines (212 loc) · 17.8 KB
/
addindynamic2_8cpp-example.html
File metadata and controls
212 lines (212 loc) · 17.8 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!-- HTML header for doxygen 1.8.7-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<title>ObjectHandler: addindynamic2.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="tabs.css">
<link rel="stylesheet" href="ql.css">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
</head>
<body>
<div id='wrapper'>
<div id='header'>
<div id='floatleft'><a class="imglink" href="index.html"><img src="images/logo_oh.jpg" width="180" height="72" border="0" alt="ObjectHandler Logo"/></a></div>
<div id='floatright'><a class="imglink" href="http://quantlib.org"><img src="images/logo_ql.jpg" width="130" height="82" border="0" alt="QuantLib Logo"/></a></div>
</div>
<div id='content'>
<div id='col-left'>
<div id="version">Version 1.22.0</div>
<div id='sidebar'>
<ul>
<li class="menuheader"><a href="index.html">Home</a></li>
<li><a href="installation.html">Installation</a></li>
<li><a href="design.html">Design</a></li>
<li><a href="history.html">History</a></li>
<li><a href="license.html">License</a></li>
<li><a href="people.html">People</a></li>
<li class="menuheader"><a href="functional.html">Functional<br>Documentation</a></li>
<li><a href="manual.html">Manual</a></li>
<li><a href="allfunctions.html">Functions</a></li>
<li><a href="categories.html">Categories</a></li>
<li class="menuheader"><a href="technical.html">Technical<br>Documentation</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="hierarchy.html">Hierarchy</a></li>
<li><a href="files.html">Files</a></li>
<li><a href="examples.html">Examples</a></li>
</ul>
</div>
<div class="logo">
<div class="vspace"></div>
<a href="http://www.reposit.be" id="reposit_logo"></a>
<div class="vspace"></div>
</div>
</div>
<div id='col-right'>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">addindynamic2.cpp</div> </div>
</div><!--header-->
<div class="contents">
<p>XLL which links dynamically to ObjectHandler</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment"> This file is part of QuantLib, a free-software/open-source library</span></div>
<div class="line"><span class="comment"> for financial quantitative analysts and developers - http://quantlib.org/</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> QuantLib is free software: you can redistribute it and/or modify it</span></div>
<div class="line"><span class="comment"> under the terms of the QuantLib license. You should have received a</span></div>
<div class="line"><span class="comment"> copy of the license along with this program; if not, please email</span></div>
<div class="line"><span class="comment"> <quantlib-dev@lists.sf.net>. The license is also available online at</span></div>
<div class="line"><span class="comment"> <http://quantlib.org/license.shtml>.</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment"> This program is distributed in the hope that it will be useful, but WITHOUT</span></div>
<div class="line"><span class="comment"> ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span></div>
<div class="line"><span class="comment"> FOR A PARTICULAR PURPOSE. See the license for more details.</span></div>
<div class="line"><span class="comment">*/</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include <<a class="code" href="objecthandlerxl_8hpp.html">ohxl/objecthandlerxl.hpp</a>></span></div>
<div class="line"><span class="preprocessor">#include <<a class="code" href="xlutilities_8hpp.html">ohxl/utilities/xlutilities.hpp</a>></span></div>
<div class="line"><span class="preprocessor">#include <ExampleObjects/accountexample.hpp></span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Use BOOST_MSVC instead of _MSC_VER since some other vendors (Metrowerks,</span></div>
<div class="line"><span class="comment"> for example) also #define _MSC_VER</span></div>
<div class="line"><span class="comment">*/</span></div>
<div class="line"><span class="preprocessor">#ifdef BOOST_MSVC</span></div>
<div class="line"><span class="preprocessor"># define BOOST_LIB_DIAGNOSTIC</span></div>
<div class="line"><span class="preprocessor"># include <oh/auto_link.hpp></span></div>
<div class="line"><span class="preprocessor"># include <xlsdk/auto_link.hpp></span></div>
<div class="line"><span class="preprocessor"># undef BOOST_LIB_DIAGNOSTIC</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor">#include <sstream></span></div>
<div class="line"> </div>
<div class="line">DLLEXPORT <span class="keywordtype">int</span> xlAutoOpen() {</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">static</span> XLOPER xDll;</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">try</span> {</div>
<div class="line"> </div>
<div class="line"> Excel(xlGetName, &xDll, 0);</div>
<div class="line"> </div>
<div class="line"> Excel(xlfRegister, 0, 7, &xDll,</div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x10"</span><span class="stringliteral">"addin2GetBalance"</span>),<span class="comment">// function code name</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x04"</span><span class="stringliteral">"ECP#"</span>), <span class="comment">// parameter codes</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x10"</span><span class="stringliteral">"addin2GetBalance"</span>),<span class="comment">// function display name</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x10"</span><span class="stringliteral">"ObjectID,Trigger"</span>),<span class="comment">// comma-delimited list of parameters</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x01"</span><span class="stringliteral">"1"</span>), <span class="comment">// function type (0 = hidden function, 1 = worksheet function, 2 = command macro)</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x07"</span><span class="stringliteral">"Example"</span>)); <span class="comment">// function category</span></div>
<div class="line"> </div>
<div class="line"> Excel(xlfRegister, 0, 7, &xDll,</div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x0D"</span><span class="stringliteral">"addin2GetType"</span>), <span class="comment">// function code name</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x04"</span><span class="stringliteral">"CCP#"</span>), <span class="comment">// parameter codes</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x0D"</span><span class="stringliteral">"addin2GetType"</span>), <span class="comment">// function display name</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x10"</span><span class="stringliteral">"ObjectID,Trigger"</span>),<span class="comment">// comma-delimited list of parameters</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x01"</span><span class="stringliteral">"1"</span>), <span class="comment">// function type (0 = hidden function, 1 = worksheet function, 2 = command macro)</span></div>
<div class="line"> TempStrNoSize(<span class="stringliteral">"\x07"</span><span class="stringliteral">"Example"</span>)); <span class="comment">// function category</span></div>
<div class="line"> </div>
<div class="line"> Excel(xlFree, 0, 1, &xDll);</div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line"> </div>
<div class="line"> } <span class="keywordflow">catch</span> (<span class="keyword">const</span> std::exception &e) {</div>
<div class="line"> </div>
<div class="line"> std::ostringstream err;</div>
<div class="line"> err << <span class="stringliteral">"Error loading ExampleXllDynamic2: "</span> << e.what();</div>
<div class="line"> Excel(xlcAlert, 0, 1, TempStrStl(err.str()));</div>
<div class="line"> Excel(xlFree, 0, 1, &xDll);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line"> </div>
<div class="line"> } <span class="keywordflow">catch</span> (...) {</div>
<div class="line"> </div>
<div class="line"> Excel(xlFree, 0, 1, &xDll);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line"> </div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">DLLEXPORT <span class="keywordtype">void</span> xlAutoFree(XLOPER *px) {</div>
<div class="line"> </div>
<div class="line"> <a name="a0"></a><a class="code" href="xlutilities_8hpp.html#abded3ba5610e6be5616ee0f3a9d58818">freeOper</a>(px);</div>
<div class="line"> </div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">DLLEXPORT <span class="keywordtype">double</span> *addin2GetBalance(<span class="keywordtype">char</span> *objectID, OPER *trigger) {</div>
<div class="line"> </div>
<div class="line"> boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">try</span> {</div>
<div class="line"> </div>
<div class="line"> functionCall = boost::shared_ptr<ObjectHandler::FunctionCall></div>
<div class="line"> (<span class="keyword">new</span> <a name="_a1"></a><a class="code" href="class_object_handler_1_1_function_call.html">ObjectHandler::FunctionCall</a>(<span class="stringliteral">"addin2GetBalance"</span>));</div>
<div class="line"> </div>
<div class="line"> <a name="a2"></a><a class="code" href="ohdefines_8hpp.html#a523ba6d4f8fdf75d75612da8016c8f0d">OH_GET_OBJECT</a>(accountObject, objectID, AccountExample::AccountObject)</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">static</span> <span class="keywordtype">double</span> ret;</div>
<div class="line"> ret = accountObject->balance();</div>
<div class="line"> <span class="keywordflow">return</span> &ret;</div>
<div class="line"> </div>
<div class="line"> } <span class="keywordflow">catch</span> (<span class="keyword">const</span> std::exception &e) {</div>
<div class="line"> </div>
<div class="line"> <a name="a3"></a><a class="code" href="class_object_handler_1_1_repository_x_l.html#af79278189d5203d91b553d10a25e90d6">ObjectHandler::RepositoryXL::instance</a>().<a name="a4"></a><a class="code" href="class_object_handler_1_1_repository_x_l.html#a47f6346114416272fc1f2c62fa799a6d">logError</a>(e.what(), functionCall);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line"> </div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">DLLEXPORT <span class="keywordtype">char</span> *addin2GetType(<span class="keywordtype">char</span> *objectID, OPER *trigger) {</div>
<div class="line"> </div>
<div class="line"> boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">try</span> {</div>
<div class="line"> </div>
<div class="line"> functionCall = boost::shared_ptr<ObjectHandler::FunctionCall></div>
<div class="line"> (<span class="keyword">new</span> <a class="code" href="class_object_handler_1_1_function_call.html">ObjectHandler::FunctionCall</a>(<span class="stringliteral">"addin2GetType"</span>));</div>
<div class="line"> </div>
<div class="line"> AccountExample::Account::Type accountTypeEnum =</div>
<div class="line"> <a name="_a5"></a><a class="code" href="class_object_handler_1_1_create.html">ObjectHandler::Create<AccountExample::Account::Type></a>()(objectID);</div>
<div class="line"> </div>
<div class="line"> std::ostringstream s;</div>
<div class="line"> s << accountTypeEnum;</div>
<div class="line"> <span class="keyword">static</span> <span class="keywordtype">char</span> ret[XL_MAX_STR_LEN];</div>
<div class="line"> <a name="a6"></a><a class="code" href="namespace_object_handler.html#a749fc7e3e73be55b2ef518c734ee0d8a">ObjectHandler::stringToChar</a>(s.str(), ret);</div>
<div class="line"> <span class="keywordflow">return</span> ret;</div>
<div class="line"> </div>
<div class="line"> } <span class="keywordflow">catch</span> (<span class="keyword">const</span> std::exception &e) {</div>
<div class="line"> </div>
<div class="line"> <a class="code" href="class_object_handler_1_1_repository_x_l.html#af79278189d5203d91b553d10a25e90d6">ObjectHandler::RepositoryXL::instance</a>().<a class="code" href="class_object_handler_1_1_repository_x_l.html#a47f6346114416272fc1f2c62fa799a6d">logError</a>(e.what(), functionCall);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line"> </div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
</div><!-- fragment --> </div><!-- contents -->
<div class="ttc" id="aobjecthandlerxl_8hpp_html"><div class="ttname"><a href="objecthandlerxl_8hpp.html">objecthandlerxl.hpp</a></div><div class="ttdoc">#includes for all functionality in ObjectHandler</div></div>
<div class="ttc" id="aclass_object_handler_1_1_function_call_html"><div class="ttname"><a href="class_object_handler_1_1_function_call.html">ObjectHandler::FunctionCall</a></div><div class="ttdoc">Singleton encapsulating state relating to Excel function call.</div><div class="ttdef"><b>Definition:</b> functioncall.hpp:56</div></div>
<div class="ttc" id="axlutilities_8hpp_html_abded3ba5610e6be5616ee0f3a9d58818"><div class="ttname"><a href="xlutilities_8hpp.html#abded3ba5610e6be5616ee0f3a9d58818">freeOper</a></div><div class="ttdeci">DLL_API void freeOper(XLOPER *px)</div><div class="ttdoc">Free any memory associated with the XLOPER.</div></div>
<div class="ttc" id="axlutilities_8hpp_html"><div class="ttname"><a href="xlutilities_8hpp.html">xlutilities.hpp</a></div><div class="ttdoc">General utility functions for the Excel platform.</div></div>
<div class="ttc" id="aohdefines_8hpp_html_a523ba6d4f8fdf75d75612da8016c8f0d"><div class="ttname"><a href="ohdefines_8hpp.html#a523ba6d4f8fdf75d75612da8016c8f0d">OH_GET_OBJECT</a></div><div class="ttdeci">#define OH_GET_OBJECT(NAME, ID, OBJECT_CLASS)</div><div class="ttdoc">Get a boost shared pointer to a class derived from Object.</div><div class="ttdef"><b>Definition:</b> ohdefines.hpp:87</div></div>
<div class="ttc" id="aclass_object_handler_1_1_create_html"><div class="ttname"><a href="class_object_handler_1_1_create.html">ObjectHandler::Create</a></div><div class="ttdoc">Create the enumerated type associated with a string.</div><div class="ttdef"><b>Definition:</b> typefactory.hpp:135</div></div>
<div class="ttc" id="anamespace_object_handler_html_a749fc7e3e73be55b2ef518c734ee0d8a"><div class="ttname"><a href="namespace_object_handler.html#a749fc7e3e73be55b2ef518c734ee0d8a">ObjectHandler::stringToChar</a></div><div class="ttdeci">DLL_API void stringToChar(const std::string &, char *)</div><div class="ttdoc">Convert the std::string to the char*.</div></div>
<div class="ttc" id="aclass_object_handler_1_1_repository_x_l_html_af79278189d5203d91b553d10a25e90d6"><div class="ttname"><a href="class_object_handler_1_1_repository_x_l.html#af79278189d5203d91b553d10a25e90d6">ObjectHandler::RepositoryXL::instance</a></div><div class="ttdeci">static RepositoryXL & instance()</div><div class="ttdoc">Client applications access the global object via a call to RepositoryXL::instance().</div></div>
<div class="ttc" id="aclass_object_handler_1_1_repository_x_l_html_a47f6346114416272fc1f2c62fa799a6d"><div class="ttname"><a href="class_object_handler_1_1_repository_x_l.html#a47f6346114416272fc1f2c62fa799a6d">ObjectHandler::RepositoryXL::logError</a></div><div class="ttdeci">void logError(const std::string &message, const boost::shared_ptr< FunctionCall > &functionCall)</div><div class="ttdoc">Log an error message.</div></div>
<!-- HTML footer for doxygen 1.8.7-->
<!-- start footer part -->
</div>
<div class='clearfix'></div>
<div id="footer">SourceForge logo copyright © Open Source Technology Group<br>reposit logo <a href="http://www.reposit.be">copyright © 2015 reposit Ltd Dublin</a><br>all other content <a href="license.html">copyright © 2004-20015 The QuantLib Group</a></div>
</div>
<div class='clearfix'></div>
</div>
<div class='clearfix'></div>
</body>
</html>