Wednesday 20 July 2011

generate xml from cpp

qdbuscpp2xml
To generate the XML we will be using the qdbuscpp2xml command line tool that comes with Qt. This program takes a C++ source file and generates a D-Bus XML definition of the interface for us. It lets us to define which methods to export using the following command line switches:
qdbuscpp2xml switches
Switch Exports
-S all signals
-M all public slots
-P all properties
-A all exportable items
-s scriptable signals
-m scriptable public slots
-p scriptable properties
-a all scriptable items
In our example above we want to export all the public slots but only scriptable signals. Therefore we would use this command line:
$> qdbuscpp2xml -M -s background.h -o org.foo.Background.xml
This produces a file named org.foo.Background.xml which contains this:
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.foo.Background">
    <signal name="backgroundChanged">
    </signal>
    <method name="refreshBackground">
    </method>
    <method name="currentBackground">
      <arg type="s" direction="out"/>
    </method>
    <method name="setBackground">
      <arg type="b" direction="out"/>
      <arg name="name" type="s" direction="in"/>
    </method>
  </interface>
</node>
This file should be shipped with your project's source distribution.

No comments:

Post a Comment