[xsd-users] Using template to serialize and deserialize

Boris Kolpackov boris at codesynthesis.com
Thu Apr 26 10:58:24 EDT 2012


Hi Joakim,

Wallman, Joakim <Joakim.Wallman at gyros.com> writes:

> When we generate code with the Codesynthesis XSD we get serialization and
> parsing functions as global (not defined in the class) functions. Is there
> any way to generate so these functions will be static in the class and have
> same name for all classes so it is possible to use template to minimize the
> code?

No, this won't be possible because parsing functions will only differ by the
return type.

If you are looking for a uniform way to perform parsing/serialization, then
you may want to consider using the element type and element map features.
See the 'messaging' example and Section 2.9, "Mapping for Global Elements"
in the C++/Tree Mapping Manual:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.9

Boris



More information about the xsd-users mailing list