summaryrefslogtreecommitdiffstats
path: root/tools/qscxmlc/doc/qscxmlc.qdoc
blob: 6f7ec9a3eaa36fa8d0f076fc5d6bff72ef81def2 (plain)
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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page qscxmlc.html
    \title Using the Qt SCXML Compiler (qscxmlc)
    \keyword qscxmlc

    \brief The Qt SCXML Compiler, \c qscxmlc, compiles state chart XML
           (.scxml) files to C++ source files.

    The \c qscxmlc tool reads an .scxml file and produces C++ source
    and header files, containing a class that implements a state machine as
    defined in SCXML.

    \section1 Usage

    The \c qscxmlc tool is invoked automatically if the project is linked against
    the \c scxml library in the project file, and the \c .scxml file to use is specified
    using the special build directives \c STATECHARTS or \l{qt_add_statecharts}.

    When using cmake:

    \include qtscxml-module-use.qdocinc cmakebuild
    \include qtscxml-module-use.qdocinc cmakestatecharts

    When using qmake:

    \include qtscxml-module-use.qdocinc qmakebuild
    \include qtscxml-module-use.qdocinc qmakestatecharts

    With above definitions, \c qmake or \c cmake invokes \c qscxmlc to generate
    MyStatemachine.h and MyStatemachine.cpp, and adds them appropriately
    to the project as headers and sources.

    By default, the name of the generated class that implements the state
    machine corresponds with the \e name attribute of the \c <scxml> root
    element.

    The \c qscxmlc tool can also be invoked manually and the resulting header and
    source files can be used as regular source files in a project. When
    using these source files as part of a \c cmake project, one must
    additionally disable automatic moc in the CMakeLists.txt file as
    illustrated by this example:
    \code
    set_source_files_properties(statemachine.h PROPERTIES SKIP_AUTOMOC TRUE)
    \endcode
    If you omit this, you will see duplicate symbol errors during compilation.

    \section1 Command-Line Options

    The \c qscxmlc tool supports the following command-line options:

    \table
      \header
        \li Option
        \li Description
      \row
        \li \c {--namespace <namespace>}
        \li Put the generated class(es) in the specified namespace.
      \row
        \li \c {-o <base/out/name>}
        \li The base name of the output files. This can include a path. If none is specified, the
            basename of the input file is used.
      \row
        \li \c {--header <header/out>}
        \li The name of the output header file. If none is specified, .h is added to the base name.
      \row
        \li \c {--impl <cpp/out>}
        \li The name of the output header file. If none is specified, .cpp is added to the base name.
      \row
        \li \c {--classname <StateMachineClassName>}
        \li The class name of the generated state machine. If none is specified, the value of the
            name attribute of the <scxml> tag is taken. If that attribute is not specified either,
            the basename (excluding path) is taken from the input file name.
      \row
        \li \c --statemethods
        \li Generate extra accessor and signal methods for states. This way you can connect to
            state changes with plain QObject::connect() and directly call a method to find out if
            a state is currently active.
    \endtable

    The \c qmake and \c CMake project files support the following options:

    \table
      \header
        \li Option
        \li Description
      \row
        \li \c {QSCXMLC_DIR|OUTPUT_DIRECTORY <directory>}
        \li \c QSCXMLC_DIR (qmake) or \c OUTPUT_DIRECTORY (cmake) specifies the directory for
               the output files. OUTPUT_DIR (cmake) has been deprecated.
      \row
        \li \c {QSCXMLC_NAMESPACE|NAMESPACE <namespace>}
        \li \c QSCXMLC_NAMESPACE (qmake) or \c NAMESPACE (cmake) specifies the namespace for the
            generated classes.
      \row
        \li \c {QSCXMLC_ARGUMENTS|OPTIONS <options>}
        \li \c QSCXMLC_ARGUMENTS (qmake) or \c OPTIONS (cmake) allows specifying additional
            options for the \c qscxmlc compiler. QSCXMLC_ARGUMENTS with cmake has been
            deprecated.
    \endtable
*/