[xsd-users] Cropped data problem due to enforced upcasting in C++.
Tolga Hakan ODUNCU
thakanoduncu at gmail.com
Thu Mar 26 02:36:00 EDT 2020
Hello Boris,
I tried some generation parameters for required class as you proposed. When
I generated with --polymorphic-type-all, generated codes did not compile
but declaring each required class seperately worked.
Also verified by downcasting with dynamic_cast. Finally, I could succeed to
serialize my data as I want to do.
Thanks a lot for your help.
Sincerely
On Tue, Mar 24, 2020 at 5:43 PM Boris Kolpackov <boris at codesynthesis.com>
wrote:
> Tolga Hakan ODUNCU <thakanoduncu at gmail.com> writes:
>
> > Since this schema includes base and derived types, I generated the C++ 11
> > codes with -generate-polymorphic parameter as proposed on Command Line
> > Manuel.
>
> Have you also specified --polymorphic-type RequestContainer or,
> alternatively, --polymorphic-type-all?
>
>
> > However, when I push back my ReportTaskIssueRequest object to
> > x1RequestMessage_sequence directly or with _clone() function, my object
> is
> > upcasted to X1RequestMessage and properties belonging to
> > ReportTaskIssueRequest are cropped and xsi:type attribute is invisible.
>
> You could verify that the object you have pushed retains its dynamic
> type with dynamic_cast:
>
> x.x1RequestMessage ().push_back (...);
> dynamic_cast<ReportTaskIssueRequest&> (x.x1RequestMessage ().back ());
>
> If this works as expected, then it's definitely something with the
> configuration of the generated code (for example, missing
> --polymorphic-type*).
>
More information about the xsd-users
mailing list