问题描述
假如我有C或C ++的结构,如:
Suppose I have a structure in C or C++, such as:
struct ConfigurableElement {
int ID;
char* strName;
long prop1;
long prop2;
...
};
我想加载/保存到/从以下XML元素:
I would like to load/save it to/from the following XML element:
<ConfigurableElement ID="1" strName="namedElem" prop1="2" prop2="3" ... />
这样的映射可以在Java / C#或任何其他语言与用于物质运行时反射来平凡完成。它可以在任何非单调乏味的方式来完成的C ++与宏/模板弄虚作假?
Such a mapping can be trivially done in Java/C# or any other language with run-time reflection for the matter. Can it be done in any non-tedious way in C++ with macros/template trickery?
积分为处理嵌套结构/联合。
Bonus points for handling nested structures/unions.
推荐答案
你想要的技术被称为序列化。您可能需要阅读这些文章:
The technique you want is called serialization. You may want to read these articles:
&LT;!===非常接近你想要什么
http://www.codesynthesis.com/products/xsd/ <=== Very close to what you want!
有是你的另一个选择:由Ultimatepp提供Xmlize:
There is another option for you: Xmlize provided by Ultimatepp:
这篇关于映射的C结构到XML元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!