Wednesday, 20 July 2011

generate xml from cpp

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
This produces a file named which contains this:
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "">
  <interface name="">
    <signal name="backgroundChanged">
    <method name="refreshBackground">
    <method name="currentBackground">
      <arg type="s" direction="out"/>
    <method name="setBackground">
      <arg type="b" direction="out"/>
      <arg name="name" type="s" direction="in"/>
This file should be shipped with your project's source distribution.

No comments:

Post a Comment