[xsd-users] Pointers to references

Mathew Benson mathew.benson at gmail.com
Sat Mar 1 13:33:21 EST 2014


I already found that section, but to avoid confusion I tried to faithly
perform the steps detailed in that section.  The sample code doesn't work
for me out of the box, having problems just parsing the schema, compiling,
and unmarshalling the xml.  Either I don't have my build environment setup
correctly, or the sample code in the manual is really incomplete code
snippets.  For the benefit of anybody else that finds this post, I'm
attaching a tarball of my build project with a functioning example taken
from section 2.5.5 of the manual.  I apologize if the attachment doesn't go
through.  For a detailed example of what had failed and the changes
required, build the code exactly as found in the manual and diff that with
the example attached here.  The xsd command to generate the .cpp and .h
file is:

xsd cxx-tree --generate-serialization --generate-ostream --cxx-suffix .cpp
--hxx-suffix .h --fwd-suffix -fwd.h test.xsd

I couldn't get the second half of the example to compile.  Not that I don't
think that it should matter, but I didn't know what function to call to
unmarshall from a file and return a reference.  Any attempt to use
"root_type&" like the example resulted in the following compiler error:
../src/XSDTest.cpp:18:43: error: invalid initialization of non-const
reference of type 'test::root_type&' from an rvalue of type
'std::auto_ptr<test::root_type>

I also got an error on the following line from the example:

object_type& obj (*ref);

../src/XSDTest.cpp:20:25: error: invalid initialization of reference of
type 'test::object_type&' from expression of type
'xsd::cxx::tree::idref<char, xsd::cxx::tree::ncname<char,
xsd::cxx::tree::name<char, xsd::cxx::tree::token<char,
xsd::cxx::tree::normalized_string<char, xsd::cxx::tree::string<char,
xsd::cxx::tree::simple_type<xsd::cxx::tree::_type> > > > > >,
xsd::cxx::tree::_type>::ref_type {aka xsd::cxx::tree::_type}'

I would really like to get that second half of the example working so I
don't have to cast.

Lastly, using "root" as a variable name in the examples is probably not a
good idea when the example xsd file results in a class also called "root".
 Its a bit confusing.


On Fri, Feb 28, 2014 at 11:19 PM, Boris Kolpackov
<boris at codesynthesis.com>wrote:

> Hi Mathew,
>
> Mathew Benson <mathew.benson at gmail.com> writes:
>
> > Could you tell me the best way to retrieve
> > 'argumentTypeRef="IpAddressType"' given I have a pointer/reference to the
> > '<xtce:MetaCommand name="RCM_EnableOutput">' object?
>
> If you have an IDREF reference, then please read this section in the
> manual, it explains how to use them:
>
> http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.5.5
>
> If something is still not clear, please specify what exactly (i.e., "I
> tried foo and bar and biz did not work" instead of "tell me how to
> do foo").
>
> Boris
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Debug.tar.gz
Type: application/x-gzip
Size: 1548 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20140301/9ddf815b/Debug.tar.bin


More information about the xsd-users mailing list