[xsd-users] construct object from iterator

Schmilinsky, Remsy Remsy.Schmilinsky at ccra-adrc.gc.ca
Wed Nov 15 14:56:12 EST 2006


Hi. From the library example:

    for (catalog::book::const_iterator bi (c->book ().begin ());
         bi != c->book ().end ();
         ++bi)

I want to save each book in dbxml as a separate document instead of the
whole catalog. can I convert iterator bi to catalog::book object and
then use it to save a document in dbxml? 

I am following the dbxml example, it shows how to save the catalog as a
document instead of a document for each book.

thanks,

Remsy

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: November 3, 2006 1:05 AM
To: Schmilinsky, Remsy
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] assign enumeration to string


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




More information about the xsd-users mailing list