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
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- activeqt-dumpcpp.qdoc -->
<title>Qt 4.8: The dumpcpp Tool (ActiveQt)</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li>The dumpcpp Tool (ActiveQt)</li>
</ul>
</div>
</div>
<div class="content mainContent">
<h1 class="title">The dumpcpp Tool (ActiveQt)</h1>
<span class="subtitle"></span>
<!-- $$$activeqt-dumpcpp.html-description -->
<div class="descr"> <a name="details"></a>
<a name="dumpcpp"></a><p>The <tt>dumpcpp</tt> tool generates a C++ namespace for a type library.</p>
<p>To generate a C++ namespace for a type library, call <tt>dumpcpp</tt> with the following command line parameters:</p>
<table class="generic">
<thead><tr class="qt-style"><th >Option</th><th >Result</th></tr></thead>
<tr valign="top" class="odd"><td >input</td><td >Generate documentation for <i>input</i>. <i>input</i> can specify a type library file or a type library ID, or a CLSID or ProgID for an object</td></tr>
<tr valign="top" class="even"><td >-o file</td><td >Writes the class declaration to <i>file</i>.h and meta object infomation to <i>file</i>.cpp</td></tr>
<tr valign="top" class="odd"><td >-n namespace</td><td >Generate a C++ namespace <i>namespace</i></td></tr>
<tr valign="top" class="even"><td >-nometaobject</td><td >Do not generate a .cpp file with the meta object information. The meta object is then generated in runtime.</td></tr>
<tr valign="top" class="odd"><td >-getfile libid</td><td >Print the filename for the typelibrary <i>libid</i> to stdout</td></tr>
<tr valign="top" class="even"><td >-compat</td><td >Generate namespace with dynamicCall-compatible API</td></tr>
<tr valign="top" class="odd"><td >-v</td><td >Print version information</td></tr>
<tr valign="top" class="even"><td >-h</td><td >Print help</td></tr>
</table>
<p><tt>dumpcpp</tt> can be integrated into the <tt>qmake</tt> build system. In your .pro file, list the type libraries you want to use in the TYPELIBS variable:</p>
<pre class="cpp"> TEMPLATE = app
TARGET = qutlook
CONFIG += qaxcontainer
TYPELIBS = $$system(dumpcpp -getfile {00062FFF-0000-0000-C000-000000000046})</pre>
<p>The generated namespace will declare all enumerations, as well as one <a href="qaxobject.html">QAxObject</a> subclass for each <tt>coclass</tt> and <tt>interface</tt> declared in the type library. coclasses marked with the <tt>control</tt> attribute will be wrapped by a <a href="qaxwidget.html">QAxWidget</a> subclass.</p>
<p>Those classes that wrap creatable coclasses (i.e. coclasses that are not marked as <tt>noncreatable</tt>) have a default constructor; this is typically a single class of type <tt>Application</tt>.</p>
<pre class="cpp"> Outlook<span class="operator">::</span>Application <span class="operator">*</span>outlook <span class="operator">=</span> <span class="keyword">new</span> Outlook<span class="operator">::</span>Application;</pre>
<p>All other classes can only be created by passing an IDispatch interface pointer to the constructor; those classes should however not be created explicitly. Instead, use the appropriate API of already created objects.</p>
<pre class="cpp"> Outlook<span class="operator">::</span>_NameSpace <span class="operator">*</span>session <span class="operator">=</span> outlook<span class="operator">-</span><span class="operator">></span>Session();</pre>
<p>All coclass wrappers also have one constructors taking an interface wrapper class for each interface implemented.</p>
<pre class="cpp"> Outlook<span class="operator">::</span>NameSpace <span class="operator">*</span>session <span class="operator">=</span> outlook<span class="operator">-</span><span class="operator">></span>Session();</pre>
<p>You have to create coclasses to be able to connect to signals of the subobject. Note that the constructor deletes the interface object, so the following will cause a segmentation fault:</p>
<pre class="cpp"> Outlook<span class="operator">::</span>_NameSpace <span class="operator">*</span>tmp <span class="operator">=</span> outlook<span class="operator">-</span><span class="operator">></span>Session();
Outlook<span class="operator">::</span>NameSpace <span class="operator">*</span>session <span class="operator">=</span> <span class="keyword">new</span> Outlook<span class="operator">::</span>NameSpace(tmp);
<span class="keyword">delete</span> tmp; <span class="comment">// or any other use of tmp: segfault</span></pre>
<p>If the return type is of a coclass or interface type declared in another type library you have to include the namespace header for that other type library before including the header for the namespace you want to use (both header have to be generated with this tool).</p>
<p>By default, methods and property returning subobjects will use the type as in the type library. The caller of the function is responsible for deleting or reparenting the object returned. If the <tt>-compat</tt> switch is set, properties and method returning a COM object have the return type <tt>IDispatch*</tt>, and the namespace will not declare wrapper classes for interfaces.</p>
<p>In this case, create the correct wrapper class explicitly:</p>
<pre class="cpp"> Outlook<span class="operator">::</span>NameSpace <span class="operator">*</span>session <span class="operator">=</span> <span class="keyword">new</span> Outlook<span class="operator">::</span>NameSpace(outlook<span class="operator">-</span><span class="operator">></span>Session());</pre>
<p>You can of course use the IDispatch* returned directly, in which case you have to call <tt>Release()</tt> when finished with the interface.</p>
<p>All classes in the namespace are tagged with a macro that allows you to export or import them from a DLL. To do that, declare the macro to expand to <tt>__declspec(dllimport/export)</tt> before including the header file.</p>
<p>To build the tool you must first build the <a href="qaxcontainer.html">QAxContainer</a> library. Then run your make tool in <tt>tools/dumpcpp</tt>.</p>
</div>
<!-- @@@activeqt-dumpcpp.html -->
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|