// Copyright (C) 2005-2006 Code Synthesis Tools CC
//
// This program was generated by XML Schema Definition Compiler (XSD)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// In addition, as a special exception, Code Synthesis Tools CC gives
// permission to link this program with the Xerces-C++ library (or with
// modified versions of Xerces-C++ that use the same license as Xerces-C++),
// and distribute linked combinations including the two. You must obey
// the GNU General Public License version 2 in all respects for all of
// the code used other than Xerces-C++. If you modify this copy of the
// program, you may extend this exception to your version of the program,
// but you are not obligated to do so. If you do not wish to do so, delete
// this exception statement from your version.
//
// In addition, Code Synthesis Tools CC makes a special exception for
// the Free/Libre and Open Source Software (FLOSS) which is described
// in the accompanying FLOSSE file.
//

// Begin prologue.
//
//
// End prologue.

#include <xsd/cxx/pre.hxx>

#include "hello.hxx"

// hello_type
// 

const hello_type::greeting::type& hello_type::
greeting () const
{
  return this->_xsd_greeting_.get ();
}

hello_type::greeting::type& hello_type::
greeting ()
{
  return this->_xsd_greeting_.get ();
}

void hello_type::
greeting (const greeting::type& greeting)
{
  this->_xsd_greeting_.set (greeting);
}

void hello_type::
greeting (::std::auto_ptr< greeting::type > greeting)
{
  this->_xsd_greeting_.set (greeting);
}

const hello_type::name::container& hello_type::
name () const
{
  return this->_xsd_name_;
}

hello_type::name::container& hello_type::
name ()
{
  return this->_xsd_name_;
}

void hello_type::
name (const name::container& name)
{
  this->_xsd_name_ = name;
}


#include <xsd/cxx/xml/dom/parser.hxx>

// hello_type
//

hello_type::
hello_type (const greeting::type& _xsd_greeting)
: ::xsd::cxx::tree::type (),
_xsd_greeting_ (_xsd_greeting,
                ::xsd::cxx::tree::flags (),
                this),
_xsd_name_ (::xsd::cxx::tree::flags (), this)
{
}

hello_type::
hello_type (const hello_type& _xsd_hello_type,
            ::xsd::cxx::tree::flags f,
            ::xsd::cxx::tree::type* c)
: ::xsd::cxx::tree::type (_xsd_hello_type, f, c),
_xsd_greeting_ (_xsd_hello_type._xsd_greeting_,
                f | ::xsd::cxx::tree::flags::not_root,
                this),
_xsd_name_ (_xsd_hello_type._xsd_name_,
            f | ::xsd::cxx::tree::flags::not_root,
            this)
{
}

hello_type::
hello_type (const ::xsd::cxx::xml::dom::element< char >& e,
            ::xsd::cxx::tree::flags f,
            ::xsd::cxx::tree::type* c)
: ::xsd::cxx::tree::type (e, f, c),
_xsd_greeting_ (f | ::xsd::cxx::tree::flags::not_root, this),
_xsd_name_ (f | ::xsd::cxx::tree::flags::not_root, this)
{

  parse (e, f);
}

::hello_type* hello_type::
_clone (::xsd::cxx::tree::flags f,
        ::xsd::cxx::tree::type* c) const
{
  return new hello_type (*this, f, c);
}

void hello_type::
parse (const ::xsd::cxx::xml::dom::element< char >& e,
       ::xsd::cxx::tree::flags f)
{
  ::xsd::cxx::xml::dom::parser< char > p (e);

  while (p.more_elements ())
  {
    ::xsd::cxx::xml::dom::element< char > e (p.next_element ());

    // greeting
    //
    {
      if (e.name () == "greeting" && e.namespace_ ().empty ())
      {
        ::std::auto_ptr< greeting::type > r (
          greeting::traits::create (
            e, f | ::xsd::cxx::tree::flags::not_root, this));

        if (_xsd_greeting_.present ())
        {
          throw ::xsd::cxx::tree::unexpected_element< char > (
            e.name (), e.namespace_ (),
            "", "");
        }

        this->greeting (r);
        continue;
      }
    }

    // name
    //
    {
      if (e.name () == "name" && e.namespace_ ().empty ())
      {
        ::std::auto_ptr< name::type > r (
          name::traits::create (
            e, f | ::xsd::cxx::tree::flags::not_root, this));

        this->name ().push_back (r);
        continue;
      }
    }
  }

  if (!_xsd_greeting_.present ())
  {
    throw ::xsd::cxx::tree::expected_element< char > (
      "greeting",
      "");
  }
}

#include <istream>
#include <xercesc/framework/Wrapper4InputSource.hpp>
#include <xsd/cxx/xml/sax/std-input-source.hxx>
#include <xsd/cxx/tree/exceptions.hxx>
#include <xsd/cxx/tree/error-handler.hxx>

::std::auto_ptr< ::hello_type >
hello (const ::std::basic_string< char >& u,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xsd::cxx::tree::flags::dont_initialize) == 0,
    (f & ::xsd::cxx::tree::flags::keep_dom) == 0);

  ::xsd::cxx::tree::error_handler< char > h;

  ::xsd::cxx::xml::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (u, h, p, f));

  h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > ();

  return ::hello (
    static_cast< const ::xercesc::DOMDocument& > (*d), f);
}

::std::auto_ptr< ::hello_type >
hello (const ::std::basic_string< char >& u,
       ::xsd::cxx::xml::error_handler< char >& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xsd::cxx::tree::flags::dont_initialize) == 0,
    (f & ::xsd::cxx::tree::flags::keep_dom) == 0);

  ::xsd::cxx::xml::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (u, h, p, f));

  if (!d)
  {
    throw ::xsd::cxx::tree::parsing< char > ();
  }

  return ::hello (
    static_cast< const ::xercesc::DOMDocument& > (*d), f);
}

::std::auto_ptr< ::hello_type >
hello (const ::std::basic_string< char >& u,
       ::xercesc::DOMErrorHandler& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (u, h, p, f));

  if (!d)
  {
    throw ::xsd::cxx::tree::parsing< char > ();
  }

  return ::hello (
    static_cast< const ::xercesc::DOMDocument& > (*d), f);
}

::std::auto_ptr< ::hello_type >
hello (::std::istream& is,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xsd::cxx::tree::flags::dont_initialize) == 0,
    (f & ::xsd::cxx::tree::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is);
  xercesc::Wrapper4InputSource wrap (&isrc, false);
  return ::hello (wrap, f, p);
}

::std::auto_ptr< ::hello_type >
hello (::std::istream& is,
       ::xsd::cxx::xml::error_handler< char >& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xsd::cxx::tree::flags::dont_initialize) == 0,
    (f & ::xsd::cxx::tree::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is);
  xercesc::Wrapper4InputSource wrap (&isrc, false);
  return ::hello (wrap, h, f, p);
}

::std::auto_ptr< ::hello_type >
hello (::std::istream& is,
       ::xercesc::DOMErrorHandler& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::sax::std_input_source isrc (is);
  xercesc::Wrapper4InputSource wrap (&isrc, false);
  return ::hello (wrap, h, f, p);
}

::std::auto_ptr< ::hello_type >
hello (::std::istream& is,
       const ::std::basic_string< char >& sid,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xsd::cxx::tree::flags::dont_initialize) == 0,
    (f & ::xsd::cxx::tree::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is, sid);
  xercesc::Wrapper4InputSource wrap (&isrc, false);
  return ::hello (wrap, f, p);
}

::std::auto_ptr< ::hello_type >
hello (::std::istream& is,
       const ::std::basic_string< char >& sid,
       ::xsd::cxx::xml::error_handler< char >& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xsd::cxx::tree::flags::dont_initialize) == 0,
    (f & ::xsd::cxx::tree::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is, sid);
  xercesc::Wrapper4InputSource wrap (&isrc, false);
  return ::hello (wrap, h, f, p);
}

::std::auto_ptr< ::hello_type >
hello (::std::istream& is,
       const ::std::basic_string< char >& sid,
       ::xercesc::DOMErrorHandler& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::sax::std_input_source isrc (is, sid);
  xercesc::Wrapper4InputSource wrap (&isrc, false);
  return ::hello (wrap, h, f, p);
}

::std::auto_ptr< ::hello_type >
hello (const ::xercesc::DOMInputSource& i,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::tree::error_handler< char > h;

  ::xsd::cxx::xml::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (i, h, p, f));

  h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > ();

  return ::hello (
    static_cast< const ::xercesc::DOMDocument& > (*d), f, p);
}

::std::auto_ptr< ::hello_type >
hello (const ::xercesc::DOMInputSource& i,
       ::xsd::cxx::xml::error_handler< char >& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (i, h, p, f));

  if (!d)
  {
    throw ::xsd::cxx::tree::parsing< char > ();
  }

  return ::hello (
    static_cast< const ::xercesc::DOMDocument& > (*d), f, p);
}

::std::auto_ptr< ::hello_type >
hello (const ::xercesc::DOMInputSource& i,
       ::xercesc::DOMErrorHandler& h,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >& p)
{
  ::xsd::cxx::xml::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (i, h, p, f));

  if (!d)
  {
    throw ::xsd::cxx::tree::parsing< char > ();
  }

  return ::hello (
    static_cast< const ::xercesc::DOMDocument& > (*d), f, p);
}

::std::auto_ptr< ::hello_type >
hello (const ::xercesc::DOMDocument& d,
       ::xsd::cxx::tree::flags f,
       const ::xsd::cxx::tree::properties< char >&)
{
  ::xsd::cxx::xml::dom::auto_ptr< ::xercesc::DOMDocument > c (
    (f & ::xsd::cxx::tree::flags::keep_dom) 
    ? static_cast< ::xercesc::DOMDocument* > (d.cloneNode (true))
    : 0);

  ::xsd::cxx::xml::dom::element< char > e (
    c.get () ? c->getDocumentElement () : d.getDocumentElement ());

  if (e.name () == "hello" &&
      e.namespace_ () == "")
  {
    ::std::auto_ptr< ::hello_type > r (
      ::xsd::cxx::tree::traits< ::hello_type >::create (e, f, 0));
    if (f & ::xsd::cxx::tree::flags::keep_dom) c.release ();
    return r;
  }

  throw ::xsd::cxx::tree::unexpected_element < char > (
    e.name (),
    e.namespace_ (),
    "hello",
    "");
}

#include <xsd/cxx/post.hxx>

// Begin epilogue.
//
//
// End epilogue.

