| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*!
|
|---|
| 43 | \page activeqt-dumpcpp.html
|
|---|
| 44 | \title The dumpcpp Tool (ActiveQt)
|
|---|
| 45 |
|
|---|
| 46 | \ingroup activeqt-tools
|
|---|
| 47 |
|
|---|
| 48 | \keyword dumpcpp
|
|---|
| 49 |
|
|---|
| 50 | The \c dumpcpp tool generates a C++ namespace for a type library.
|
|---|
| 51 |
|
|---|
| 52 | To generate a C++ namespace for a type library, call \c dumpcpp with the following
|
|---|
| 53 | command line parameters:
|
|---|
| 54 |
|
|---|
| 55 | \table
|
|---|
| 56 | \header
|
|---|
| 57 | \i Option
|
|---|
| 58 | \i Result
|
|---|
| 59 | \row
|
|---|
| 60 | \i input
|
|---|
| 61 | \i Generate documentation for \e input. \e input can specify a type library file or a type
|
|---|
| 62 | library ID, or a CLSID or ProgID for an object
|
|---|
| 63 | \row
|
|---|
| 64 | \i -o file
|
|---|
| 65 | \i Writes the class declaration to \e {file}.h and meta object infomation to \e {file}.cpp
|
|---|
| 66 | \row
|
|---|
| 67 | \i -n namespace
|
|---|
| 68 | \i Generate a C++ namespace \e namespace
|
|---|
| 69 | \row
|
|---|
| 70 | \i -nometaobject
|
|---|
| 71 | \i Do not generate a .cpp file with the meta object information.
|
|---|
| 72 | The meta object is then generated in runtime.
|
|---|
| 73 | \row
|
|---|
| 74 | \i -getfile libid
|
|---|
| 75 | \i Print the filename for the typelibrary \e libid to stdout
|
|---|
| 76 | \row
|
|---|
| 77 | \i -compat
|
|---|
| 78 | \i Generate namespace with dynamicCall-compatible API
|
|---|
| 79 | \row
|
|---|
| 80 | \i -v
|
|---|
| 81 | \i Print version information
|
|---|
| 82 | \row
|
|---|
| 83 | \i -h
|
|---|
| 84 | \i Print help
|
|---|
| 85 | \endtable
|
|---|
| 86 |
|
|---|
| 87 | \c dumpcpp can be integrated into the \c qmake build system. In your .pro file, list the type
|
|---|
| 88 | libraries you want to use in the TYPELIBS variable:
|
|---|
| 89 |
|
|---|
| 90 | \snippet examples/activeqt/qutlook/qutlook.pro 0
|
|---|
| 91 |
|
|---|
| 92 | The generated namespace will declare all enumerations, as well as one QAxObject subclass
|
|---|
| 93 | for each \c coclass and \c interface declared in the type library. coclasses marked with
|
|---|
| 94 | the \c control attribute will be wrapped by a QAxWidget subclass.
|
|---|
| 95 |
|
|---|
| 96 | Those classes that wrap creatable
|
|---|
| 97 | coclasses
|
|---|
| 98 | (i.e. coclasses that are not marked
|
|---|
| 99 | as \c noncreatable) have a default constructor; this is typically a single class
|
|---|
| 100 | of type \c Application.
|
|---|
| 101 |
|
|---|
| 102 | \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 0
|
|---|
| 103 |
|
|---|
| 104 | All other classes can only be created by passing an IDispatch interface pointer
|
|---|
| 105 | to the constructor; those classes should however not
|
|---|
| 106 | be created explicitly.
|
|---|
| 107 | Instead, use the appropriate API of already created
|
|---|
| 108 | objects.
|
|---|
| 109 |
|
|---|
| 110 | \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 1
|
|---|
| 111 |
|
|---|
| 112 | All coclass wrappers also have one constructors taking an interface wrapper class
|
|---|
| 113 | for each interface implemented.
|
|---|
| 114 |
|
|---|
| 115 | \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 2
|
|---|
| 116 |
|
|---|
| 117 | You have to create coclasses to be able to connect to signals of the subobject.
|
|---|
| 118 | Note that the constructor deletes the interface object, so the following will
|
|---|
| 119 | cause a segmentation fault:
|
|---|
| 120 |
|
|---|
| 121 | \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 3
|
|---|
| 122 |
|
|---|
| 123 | If the return type is of a coclass or interface type declared in another type
|
|---|
| 124 | library you have to include the namespace header for that other type library
|
|---|
| 125 | before including the header for the namespace you want to use (both header have
|
|---|
| 126 | to be generated with this tool).
|
|---|
| 127 |
|
|---|
| 128 | By default, methods and property returning subobjects will use the type as in
|
|---|
| 129 | the type library. The caller of the function is responsible for deleting or
|
|---|
| 130 | reparenting the object
|
|---|
| 131 | returned. If the \c -compat switch is set, properties
|
|---|
| 132 | and method returning a COM object have the return type \c IDispatch*, and
|
|---|
| 133 | the namespace will not declare wrapper classes for
|
|---|
| 134 | interfaces.
|
|---|
| 135 |
|
|---|
| 136 | In this case, create the correct wrapper class explicitly:
|
|---|
| 137 |
|
|---|
| 138 | \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 4
|
|---|
| 139 |
|
|---|
| 140 | You can of course use the IDispatch* returned directly, in which case you have to
|
|---|
| 141 | call
|
|---|
| 142 | \c Release() when finished with the interface.
|
|---|
| 143 |
|
|---|
| 144 | All classes in the namespace are tagged with a macro that allows you to export
|
|---|
| 145 | or import them from a DLL. To do that, declare the macro to expand to
|
|---|
| 146 | \c __declspec(dllimport/export) before including the header file.
|
|---|
| 147 |
|
|---|
| 148 | To build the tool you must first build the QAxContainer library.
|
|---|
| 149 | Then run your make tool in \c tools/dumpcpp.
|
|---|
| 150 | */
|
|---|