Sharing generated code for shared imported XSD files

断了今生、忘了曾经 提交于 2019-12-22 08:46:45

问题


I use gSOAP for XML data binding.

Recently I refactored my XSD files by extracting a common part from two files to a separate third file and then imported it in the first two files. This was a deep and complex element that was refactored out.

In actual code I would like to have a single function that takes an object of gSOAP generated type describing that element and constructs some internal objects.

But for this I would need to have that generated class be stable and same for both final XSD files (so that the function can take a single type). Yet I don't see any way to achieve that.

Is there any solution?


I considered making the function a template based on the fact, that even if generated types are different (in particular because of being in different C++ namespaces) they have the same members and so template should work well. But that requires me to expose implementation which I don't want to do (it is complex correspondingly to the element complexity).


Another approach I tried was to force gSOAP to generated code for both primary XSD files into same C++ namespace so that the code generated for the imported XSD will be considered same. But this leads to link issues since the definitions repeat then.

来源:https://stackoverflow.com/questions/16604243/sharing-generated-code-for-shared-imported-xsd-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!