// Copyright (C) 2005-2010 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema
// to C++ data binding compiler, in the Proprietary License mode.
// You should have received a proprietary license from Code Synthesis
// Tools CC prior to generating this code. See the license text for
// conditions.
//

// Begin prologue.
//


#define AOSLCPP_SOURCE 



//
// End prologue.

#include <xsd/cxx/pre.hxx>

#include "aosl/box.hpp"

#include <xsd/cxx/xml/dom/wildcard-source.hxx>

#include <xsd/cxx/xml/dom/parsing-source.hxx>

#include <xsd/cxx/tree/type-factory-map.hxx>

#include <xsd/cxx/tree/comparison-map.hxx>

namespace _xsd
{
  static
  const ::xsd::cxx::tree::type_factory_plate< 0, char >
  type_factory_plate_init;

  static
  const ::xsd::cxx::tree::comparison_plate< 0, char >
  comparison_plate_init;
}

namespace aosl
{
  // Box
  //

  Box::
  Box (const PositionType& position,
       const SizeType& size,
       const CenterType& center,
       const OrientationType& orientation)
  : ::xml_schema::Type (),
    position_ (position, ::xml_schema::Flags (), this),
    size_ (size, ::xml_schema::Flags (), this),
    center_ (center, ::xml_schema::Flags (), this),
    orientation_ (orientation, ::xml_schema::Flags (), this)
  {
  }

  Box::
  Box (::std::auto_ptr< PositionType >& position,
       ::std::auto_ptr< SizeType >& size,
       ::std::auto_ptr< CenterType >& center,
       ::std::auto_ptr< OrientationType >& orientation)
  : ::xml_schema::Type (),
    position_ (position, ::xml_schema::Flags (), this),
    size_ (size, ::xml_schema::Flags (), this),
    center_ (center, ::xml_schema::Flags (), this),
    orientation_ (orientation, ::xml_schema::Flags (), this)
  {
  }

  Box::
  Box (const Box& x,
       ::xml_schema::Flags f,
       ::xml_schema::Container* c)
  : ::xml_schema::Type (x, f, c),
    position_ (x.position_, f, this),
    size_ (x.size_, f, this),
    center_ (x.center_, f, this),
    orientation_ (x.orientation_, f, this)
  {
  }

  Box::
  Box (const ::xercesc::DOMElement& e,
       ::xml_schema::Flags f,
       ::xml_schema::Container* c)
  : ::xml_schema::Type (e, f | ::xml_schema::Flags::base, c),
    position_ (f, this),
    size_ (f, this),
    center_ (f, this),
    orientation_ (f, this)
  {
    if ((f & ::xml_schema::Flags::base) == 0)
    {
      ::xsd::cxx::xml::dom::parser< char > p (e, true, false);
      this->parse (p, f);
    }
  }

  void Box::
  parse (::xsd::cxx::xml::dom::parser< char >& p,
         ::xml_schema::Flags f)
  {
    for (; p.more_elements (); p.next_element ())
    {
      const ::xercesc::DOMElement& i (p.cur_element ());
      const ::xsd::cxx::xml::qualified_name< char > n (
        ::xsd::cxx::xml::dom::name< char > (i));

      // position
      //
      if (n.name () == "position" && n.namespace_ () == "artofsequence.org/aosl/1.0")
      {
        ::std::auto_ptr< PositionType > r (
          PositionTraits::create (i, f, this));

        if (!position_.present ())
        {
          this->position_.set (r);
          continue;
        }
      }

      // size
      //
      if (n.name () == "size" && n.namespace_ () == "artofsequence.org/aosl/1.0")
      {
        ::std::auto_ptr< SizeType > r (
          SizeTraits::create (i, f, this));

        if (!size_.present ())
        {
          this->size_.set (r);
          continue;
        }
      }

      // center
      //
      if (n.name () == "center" && n.namespace_ () == "artofsequence.org/aosl/1.0")
      {
        ::std::auto_ptr< CenterType > r (
          CenterTraits::create (i, f, this));

        if (!center_.present ())
        {
          this->center_.set (r);
          continue;
        }
      }

      // orientation
      //
      if (n.name () == "orientation" && n.namespace_ () == "artofsequence.org/aosl/1.0")
      {
        ::std::auto_ptr< OrientationType > r (
          OrientationTraits::create (i, f, this));

        if (!orientation_.present ())
        {
          this->orientation_.set (r);
          continue;
        }
      }

      break;
    }

    if (!position_.present ())
    {
      throw ::xsd::cxx::tree::expected_element< char > (
        "position",
        "artofsequence.org/aosl/1.0");
    }

    if (!size_.present ())
    {
      throw ::xsd::cxx::tree::expected_element< char > (
        "size",
        "artofsequence.org/aosl/1.0");
    }

    if (!center_.present ())
    {
      throw ::xsd::cxx::tree::expected_element< char > (
        "center",
        "artofsequence.org/aosl/1.0");
    }

    if (!orientation_.present ())
    {
      throw ::xsd::cxx::tree::expected_element< char > (
        "orientation",
        "artofsequence.org/aosl/1.0");
    }
  }

  Box* Box::
  _clone (::xml_schema::Flags f,
          ::xml_schema::Container* c) const
  {
    return new class Box (*this, f, c);
  }

  Box::
  ~Box ()
  {
  }

  bool
  operator== (const Box& x, const Box& y)
  {
    if (!(x.position () == y.position ()))
      return false;

    if (!(x.size () == y.size ()))
      return false;

    if (!(x.center () == y.center ()))
      return false;

    if (!(x.orientation () == y.orientation ()))
      return false;

    return true;
  }

  bool
  operator!= (const Box& x, const Box& y)
  {
    return !(x == y);
  }
}

#include <ostream>

#include <xsd/cxx/tree/std-ostream-map.hxx>

namespace _xsd
{
  static
  const ::xsd::cxx::tree::std_ostream_plate< 0, char >
  std_ostream_plate_init;
}

namespace aosl
{
  ::std::ostream&
  operator<< (::std::ostream& o, const Box& i)
  {
    o << ::std::endl << "position: " << i.position ();
    o << ::std::endl << "size: " << i.size ();
    o << ::std::endl << "center: " << i.center ();
    o << ::std::endl << "orientation: " << i.orientation ();
    return o;
  }
}

#include <istream>
#include <xsd/cxx/xml/sax/std-input-source.hxx>
#include <xsd/cxx/tree/error-handler.hxx>

namespace aosl
{
}

#include <ostream>
#include <xsd/cxx/tree/error-handler.hxx>
#include <xsd/cxx/xml/dom/serialization-source.hxx>

#include <xsd/cxx/tree/type-serializer-map.hxx>

namespace _xsd
{
  static
  const ::xsd::cxx::tree::type_serializer_plate< 0, char >
  type_serializer_plate_init;
}

namespace aosl
{
  void
  operator<< (::xercesc::DOMElement& e, const Box& i)
  {
    e << static_cast< const ::xml_schema::Type& > (i);

    // position
    //
    {
      ::xercesc::DOMElement& s (
        ::xsd::cxx::xml::dom::create_element (
          "position",
          "artofsequence.org/aosl/1.0",
          e));

      s << i.position ();
    }

    // size
    //
    {
      ::xercesc::DOMElement& s (
        ::xsd::cxx::xml::dom::create_element (
          "size",
          "artofsequence.org/aosl/1.0",
          e));

      s << i.size ();
    }

    // center
    //
    {
      ::xercesc::DOMElement& s (
        ::xsd::cxx::xml::dom::create_element (
          "center",
          "artofsequence.org/aosl/1.0",
          e));

      s << i.center ();
    }

    // orientation
    //
    {
      ::xercesc::DOMElement& s (
        ::xsd::cxx::xml::dom::create_element (
          "orientation",
          "artofsequence.org/aosl/1.0",
          e));

      s << i.orientation ();
    }
  }
}

#include <xsd/cxx/post.hxx>

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

