[xsd-users] assign enumeration to string

Boris Kolpackov boris at codesynthesis.com
Fri Nov 3 01:05:21 EST 2006


Hi Remsy,

Schmilinsky, Remsy <Remsy.Schmilinsky at ccra-adrc.gc.ca> writes:

> How can I assign the generated value corresponding to an
> xsd::enumeration to a std::string variable?
>
> I try to do this in my test file:
>
> // Parse the tree
> std::auto_ptr<service::request> s(service::request_(file, 0,
> queryProps));
> std::string requestType = s->requestType();
>
> of course I get the error:
>
> test.cpp:37: error: conversion from
> `xsd::cxx::tree::optional<service::requestType,  false>' to non-scalar
> type `std::basic_st
> ring<char, std::char_traits<char>, std::allocator<char> >' requested

From the error message above I can see that you are using the container
instead of a value (notice how the error says that it cannot convert
xsd::cxx::tree::optional<...> to std::string instead of service::requestType
to std::string).

If you change your last line to be:

if (s->requestType().present ())
{
  std::string requestType = s->requestType().get ();
)

then it will work.


hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061103/744c8e22/attachment.pgp


More information about the xsd-users mailing list