[xsd-users] sequence to std::vector
Boris Kolpackov
boris at codesynthesis.com
Thu Apr 11 10:08:25 EDT 2013
Hi Nicolas,
nicolas.derhy at gdfsuez.com <nicolas.derhy at gdfsuez.com> writes:
> I have tested the basic features of this product and I am quite well
> surprised.
I hope in a positive way ;-).
> However, I have one problem with the generated code : the list are
> "sequence" and not "std::vector". I have already a lot of source
> code whose methods use parameters of type std::vector so I do not
> want modify existing code by replacing vector by sequence. So, is
> there a way to cast sequence to vector ?
For fundamental C++ types (integers, floating point, etc), XSD sequence
is a class derived from std::vector so you should be able to pass it as
std::vector without any problems.
For non-fundamental types the only way to do this is to create a copy
as std::vector:
root_type::foo_sequence& s (r.foo ());
std::vector<root_type::foo_type> (s.begin (), s.end ());
Boris
More information about the xsd-users
mailing list