Demonstrates the use of RTD handles to represent objects in Excel, where the objects are wrapped by boost::shared_ptr smart pointers
This add-in contains the code referred to in the User Guide topic Specifying a smart pointer type.
The code is based on the RtdHandleDemo sample, with the following changes:
RTDHANDLES_PTR_CLASS The macro RTDHANDLES_PTR_CLASS is used to define the smart pointer type used by the object cache:
#include <boost\shared_ptr.hpp> #define RTDHANDLES_PTR_CLASS boost::shared_ptr #include <extensions\rtdhandles.h>
Note that this definition must appear before the includion of
rtdhandles.h
.
psl::CreateHandleInCache The argument passed to the global function psl::CreateHandleInCache is a reference to a smart pointer, rather than a normal pointer:
CXlOper* Thing_Create_Impl(CXlOper& xloResult, const CXlStringArg& Name, long Value) { // End of generated code //}}XLP_SRC boost::shared_ptr<Thing> sp_thing(new Thing(Name, Value, CXlDate::Now())); xloResult = psl::CreateHandleInCache(sp_thing); return xloResult.Ret(); }
To edit the functions in this add-in, you need to load the extension file
RtdHandles.xpe
.
See Loading an extension file
for instructions.
You should also make sure that none of the following extension files is loaded, since the various types of handles are mutually exclusive.
NumericHandles.xpe
StringHandles.xpe
StringPtrHandles.xpe
In order to build this sample project, you need to do the following:
Download and install the boost libraries. (Visit http://www.boost.org.)
In the project's list of Additional Include Directories, change the
directory ..\..\..\3rdParty\Boost\boost_1_34_1
to the
directory where you installed the boost libraries.
(The directory you select should be the parent of the main boost
sub-directory.)
When you use the boost libraries under Visual Studio 2005, a host of
C4996
warnings appear.
These can be prevented by adding /D_SCL_SECURE_NO_WARNINGS
to the project's advanced compiler options.
Each sample project is located in a sub-directory of the Samples directory of the XLL+ installation. To use the sample project, open the solution file BoostHandles.sln or the project file BoostHandles.vcproj.
You can enable debugging under Excel by using the Setup Debugging command in the XLL+ ToolWindow.
When delivered, the help files are excluded from the build.
You can enable the help build by selecting the files
BoostHandles.help.xml
and
BoostHandles.chm
in the Solution Explorer,
and using the right-click menu to view Properties.
Select the page "Configuration Properties/General" and
set the "Excluded from build" property to "No".
See Generating help
in the User Guide for more information.
List of Sample Projects | Specifying a smart pointer type | RtdHandleDemo sample