易截截图软件、单文件、免安装、纯绿色、仅160KB

D Bus学习(九):利用XML定义D Bus之Singal收发例子


  在前面我们学习了使用Glib的高程捆绑方式的method的收发,现在学习singal的收发,xml例子如下
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/com/wei/MyObject">
  <interface name="com.wei.MyObject.Sample">
    <method name="Test">
      <arg name="x" type="u" direction="in" />
      <arg name="d_ret" type="d" direction="out" />
    </method >
    <signal name="Hello">
      <arg name="w_dialog" type="s" />
    </signal>
  </interface >
</node >
  在前面我们已经学习了方法Test的处理,现在增加一个信号Hello,为了是的处理方式更为简洁,这个信号只带来一个叫做w_dialog的字符串。同样我们使用dbus-binding-tool工具分别生成了server的头文件wei_server2.h和client的头文件wei_client2.h。(操作方式,请参阅上两次学习)。
Server的编写
  查看wei_server2.h,和之前只有method的相比,只有稍稍的改动,在对象的info中,增加了Hello的说明。如下:
... ...
const DBusGObjectInfo dbus_glib_com_wei_object_info = {
  0,
  dbus_glib_com_wei_methods,
  1,
"com.wei.MyObject.Sample\0Test\0S\0x\0I\0u\0d_ret\0O\0F\0N\0d\0\0\0",
"com.wei.MyObject.Sample\0Hello\0\0"
,
"\0"
};
  我们需要对象中增加相关的代码,头文件com_wei_myobject2.h如下:
#ifndef WEI_COM_WEI_MYOBJECT2_H
#define WEI_COM_WEI_MYOBJECT2_H
typedef struct ComWeiMyObject2 ComWeiMyObject2;
typedef struct ComWeiMyObject2Class ComWeiMyObject2Class;
struct ComWeiMyObject2
{
  GObject parent;
};
struct ComWeiMyObject2Class
{
  GObjectClass parent;
};
#define COM_WEI_MYOBJECT2_TYPE  (com_wei_myobject2_get_type())
GType com_wei_myobject2_get_type(void);
gboolean com_wei_test(ComWeiMyObject2 * obj ,


相关文档:

FusionCharts的XML标签属性

FusionCharts 的 XML标签属性有一下四种数据类型
* Boolean - 布尔类型,只能为1或者0。例如:<graph showNames=’1′ >
* Number - 数字类型,只能为数字。例如:<graph yAxisMaxValue=’200′ >
* String - 字符串类型,只能为字符串。例如: <graph caption=’My Chart&r ......

Java生成XML的缩进和换行

一 DOM 以下代码用DOM是生成一个XML文档
package xml;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
imp ......

使用dom4j解析XML例子

包括三个文件:studentInfo.xml(待解析的xml文件), Dom4jReadExmple.java(解析的主要类), TestDom4jReadExmple.java(测试解析的结果) (由于使用csdn blog自带的代码粘贴工具会朝里加入一些"..."字符,虽然利于查看,但是不利于把代码copy出来运行,而亲自运行代码对程序员来说是很重要的,故没有使用csdn blog自带的代码粘 ......

C#获取XML文件指定节点的数据

实例说明会更清楚些,假设有如下XML文件:
 File: message_hutaow.xml
<?xml version="1.0" encoding="UTF-8"?>
<hutaow:Message version="1.0" xmlns:hutaow="http://wangtao.cublog.cn">
<hutaow:Head>
<hutaow:Date>20080502</hutaow:Date>
<hutaow:Source>
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号