[xsd-users] Re: solution to the visitor custom function? and regex or custom script?

Boris Kolpackov boris at codesynthesis.com
Mon Jul 15 06:59:57 EDT 2013


Hi Giuseppe,

giuseppe ferrari <giuseppe500 at yahoo.it> writes:

> The problem is, as you already saw the constructors.
> I get this error for example:
>
> base_IfcGeometricRepresentationItem::
> base_IfcGeometricRepresentationItem (const base_IfcGeometricRepresentationItem& x,
>                                      ::xml_schema::flags f,
>                                      ::xml_schema::container* c)
>   : ::ifcXML::IFC2x3::FINAL::IfcRepresentationItem (x, f, c) //ERROR

This is a copy constructor (with extra flag and container arguments).
You should be able to provide one in your wrapper:

template <typename B>
class Wrapper: public B
{
public:
  ...

  Wrapper (const Wrapper& w,
           xml_schema::flags f,
           xml_schema::container* c)
    : B (w, f, c)
  {
  }

  ...
};

What may also happen is that the generated code may require "initialization"
constructors that are not regular (i.e., they have a varying number of
arguments with varying types). Unfortunately, there is no way to suppress
their generation in XSD. But what you can do instead is provide forwarding
contructors in this form:

  template<typename T1>
  Wrapper (const T1& x1)
    : B (x1)
  {
  }

  template<typename T1, typename T2>
  Wrapper (const T1& x1, const T2& x2)
    : B (x1, x2)
  {
  }

  template<typename T1, typename T2, typename T3>
  Wrapper (const T1& x1, const T2& x2, const T3& x3)
    : B (x1, x2, x3)
  {
  }

  ...

If you are using C++11, then you may want to use perfect forwarding
(and variadic templates) instead. But I believe the above C++98
version will also work.

Boris



More information about the xsd-users mailing list