From 87140ae9f841798752ae4e5422698a4090f16329 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 10 Dec 2021 11:53:35 +0200 Subject: Omit instantiating serializers for abstract elements, similar to parsing --- libxsd/xsd/cxx/tree/type-serializer-map.hxx | 5 ++++- libxsd/xsd/cxx/tree/type-serializer-map.txx | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'libxsd/xsd/cxx') diff --git a/libxsd/xsd/cxx/tree/type-serializer-map.hxx b/libxsd/xsd/cxx/tree/type-serializer-map.hxx index 38b2fb9..50869b5 100644 --- a/libxsd/xsd/cxx/tree/type-serializer-map.hxx +++ b/libxsd/xsd/cxx/tree/type-serializer-map.hxx @@ -216,8 +216,11 @@ namespace xsd template struct element_serializer_initializer { + typedef typename type_serializer_map::serializer serializer; + element_serializer_initializer (const C* root_name, const C* root_ns, - const C* subst_name, const C* subst_ns); + const C* subst_name, const C* subst_ns, + serializer); ~element_serializer_initializer (); diff --git a/libxsd/xsd/cxx/tree/type-serializer-map.txx b/libxsd/xsd/cxx/tree/type-serializer-map.txx index 1acdad2..a6c690a 100644 --- a/libxsd/xsd/cxx/tree/type-serializer-map.txx +++ b/libxsd/xsd/cxx/tree/type-serializer-map.txx @@ -550,14 +550,21 @@ namespace xsd template element_serializer_initializer:: element_serializer_initializer (const C* root_name, const C* root_ns, - const C* subst_name, const C* subst_ns) + const C* subst_name, const C* subst_ns, + serializer s) : root_name_ (root_name), root_ns_ (root_ns) { + // Note that we still have to use real typeid (instead of, say, NULL) + // for abstract elements to make sure we have separate entries for + // each of them. We can assume that such a typeid can never be looked + // up (since it's impossible to instantiate the corresponding abstract + // type). + // type_serializer_map_instance ().register_element ( xml::qualified_name (root_name, root_ns), xml::qualified_name (subst_name, subst_ns), typeid (T), - &serializer_impl); + s); } template -- cgit v1.1