Qt OPC UA 数据类型生成器

从 Qt 6.7 开始,Qt OPC UA 附带了一个名为qopcuaxmldatatypes2cpp 的数据类型生成器,它可以从 .bsd 文件中的枚举和结构化类型生成Qt OPC UA 兼容 C++ 的枚举和数据类型。

生成器是一个命令行工具,可通过以下参数控制:

短参数目的
-输入-i一个 .bsd 文件,将为其生成所有包含的枚举和结构类型。可多次使用,为多个模型生成代码。
-依赖输入-d依赖输入 .bsd 文件,只生成通过 -input 传递的输入文件中结构体所需的类型。可多次使用,以适应与多个其他模型有依赖关系的模型。
-输出-o生成文件的输出目录。
-前缀-p生成文件、枚举和类名称的前缀。默认值为GeneratedOpcUa

每次运行都会生成以下文件:

  • 一个.h 文件,包含一个包含所有枚举类型的命名空间
  • 每个结构化类型一个.h 和一个.cpp 文件
  • 一个.h 和一个.cpp 文件,包含编码和解码方法

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.