// Copyright (c) 2005-2011 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD/e, an XML Schema
// to C++ data binding compiler for embedded systems.
//
// 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
//
//

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

#include "WeaponDescription-pskel.h"

// WeaponTypeEnum_pskel
//

WeaponTypeEnum_pskel::
WeaponTypeEnum_pskel (::xml_schema::string_pskel* tiein)
: ::xml_schema::string_pskel (tiein, 0),
  WeaponTypeEnum_impl_ (0)
{
  this->_enumeration_facet (_xsde_WeaponTypeEnum_pskel_enums_, 1UL);
}

WeaponTypeEnum_pskel::
WeaponTypeEnum_pskel (WeaponTypeEnum_pskel* impl, void*)
: ::xml_schema::string_pskel (impl, 0),
  WeaponTypeEnum_impl_ (impl)
{
  this->_enumeration_facet (_xsde_WeaponTypeEnum_pskel_enums_, 1UL);
}

// RangeType_pskel
//

void RangeType_pskel::
Initial_parser (::xml_schema::float_pskel& p)
{
  this->Initial_parser_ = &p;
}

void RangeType_pskel::
Up_parser (::xml_schema::float_pskel& p)
{
  this->Up_parser_ = &p;
}

void RangeType_pskel::
Down_parser (::xml_schema::float_pskel& p)
{
  this->Down_parser_ = &p;
}

void RangeType_pskel::
parsers (::xml_schema::float_pskel& Initial,
         ::xml_schema::float_pskel& Up,
         ::xml_schema::float_pskel& Down)
{
  this->Initial_parser_ = &Initial;
  this->Up_parser_ = &Up;
  this->Down_parser_ = &Down;
}

RangeType_pskel::
RangeType_pskel ()
: RangeType_impl_ (0),
  Initial_parser_ (0),
  Up_parser_ (0),
  Down_parser_ (0),
  v_state_stack_ (sizeof (v_state_), &v_state_first_)
{
}

RangeType_pskel::
RangeType_pskel (RangeType_pskel* impl, void*)
: ::xsde::cxx::parser::validating::complex_content (impl, 0),
  RangeType_impl_ (impl),
  Initial_parser_ (0),
  Up_parser_ (0),
  Down_parser_ (0),
  v_state_stack_ (sizeof (v_state_), &v_state_first_)
{
}

// WeaponDescriptionType_pskel
//

void WeaponDescriptionType_pskel::
WeaponType_parser (::WeaponTypeEnum_pskel& p)
{
  this->WeaponType_parser_ = &p;
}

void WeaponDescriptionType_pskel::
Icon_parser (::xml_schema::string_pskel& p)
{
  this->Icon_parser_ = &p;
}

void WeaponDescriptionType_pskel::
Mass_parser (::RangeType_pskel& p)
{
  this->Mass_parser_ = &p;
}

void WeaponDescriptionType_pskel::
Speed_parser (::RangeType_pskel& p)
{
  this->Speed_parser_ = &p;
}

void WeaponDescriptionType_pskel::
ProjectileCount_parser (::RangeType_pskel& p)
{
  this->ProjectileCount_parser_ = &p;
}

void WeaponDescriptionType_pskel::
parsers (::WeaponTypeEnum_pskel& WeaponType,
         ::xml_schema::string_pskel& Icon,
         ::RangeType_pskel& Mass,
         ::RangeType_pskel& Speed,
         ::RangeType_pskel& ProjectileCount)
{
  this->WeaponType_parser_ = &WeaponType;
  this->Icon_parser_ = &Icon;
  this->Mass_parser_ = &Mass;
  this->Speed_parser_ = &Speed;
  this->ProjectileCount_parser_ = &ProjectileCount;
}

WeaponDescriptionType_pskel::
WeaponDescriptionType_pskel ()
: WeaponDescriptionType_impl_ (0),
  WeaponType_parser_ (0),
  Icon_parser_ (0),
  Mass_parser_ (0),
  Speed_parser_ (0),
  ProjectileCount_parser_ (0),
  v_state_stack_ (sizeof (v_state_), &v_state_first_)
{
}

WeaponDescriptionType_pskel::
WeaponDescriptionType_pskel (WeaponDescriptionType_pskel* impl, void*)
: ::xsde::cxx::parser::validating::complex_content (impl, 0),
  WeaponDescriptionType_impl_ (impl),
  WeaponType_parser_ (0),
  Icon_parser_ (0),
  Mass_parser_ (0),
  Speed_parser_ (0),
  ProjectileCount_parser_ (0),
  v_state_stack_ (sizeof (v_state_), &v_state_first_)
{
}

#include <assert.h>

// WeaponTypeEnum_pskel
//

::std::string WeaponTypeEnum_pskel::
post_string ()
{
  assert (this->string_impl_);
  return this->string_impl_->post_string ();
}

const char* const WeaponTypeEnum_pskel::_xsde_WeaponTypeEnum_pskel_enums_[1UL] = 
{
  "PROJECTILE"
};

// RangeType_pskel
//

void RangeType_pskel::
Initial (float x)
{
  if (this->RangeType_impl_)
    this->RangeType_impl_->Initial (x);
}

void RangeType_pskel::
Up (float x)
{
  if (this->RangeType_impl_)
    this->RangeType_impl_->Up (x);
}

void RangeType_pskel::
Down (float x)
{
  if (this->RangeType_impl_)
    this->RangeType_impl_->Down (x);
}

void RangeType_pskel::
_reset ()
{
  if (this->resetting_)
    return;

  typedef ::xsde::cxx::parser::validating::complex_content base;
  base::_reset ();

  this->v_state_stack_.clear ();

  this->resetting_ = true;

  if (this->Initial_parser_)
    this->Initial_parser_->_reset ();

  if (this->Up_parser_)
    this->Up_parser_->_reset ();

  if (this->Down_parser_)
    this->Down_parser_->_reset ();

  this->resetting_ = false;
}

// WeaponDescriptionType_pskel
//

void WeaponDescriptionType_pskel::
WeaponType (const ::WeaponTypeEnum& x)
{
  if (this->WeaponDescriptionType_impl_)
    this->WeaponDescriptionType_impl_->WeaponType (x);
}

void WeaponDescriptionType_pskel::
Icon (const ::std::string& x)
{
  if (this->WeaponDescriptionType_impl_)
    this->WeaponDescriptionType_impl_->Icon (x);
}

void WeaponDescriptionType_pskel::
Mass (const ::RangeType& x)
{
  if (this->WeaponDescriptionType_impl_)
    this->WeaponDescriptionType_impl_->Mass (x);
}

void WeaponDescriptionType_pskel::
Speed (const ::RangeType& x)
{
  if (this->WeaponDescriptionType_impl_)
    this->WeaponDescriptionType_impl_->Speed (x);
}

void WeaponDescriptionType_pskel::
ProjectileCount (const ::RangeType& x)
{
  if (this->WeaponDescriptionType_impl_)
    this->WeaponDescriptionType_impl_->ProjectileCount (x);
}

void WeaponDescriptionType_pskel::
_reset ()
{
  if (this->resetting_)
    return;

  typedef ::xsde::cxx::parser::validating::complex_content base;
  base::_reset ();

  this->v_state_stack_.clear ();

  this->resetting_ = true;

  if (this->WeaponType_parser_)
    this->WeaponType_parser_->_reset ();

  if (this->Icon_parser_)
    this->Icon_parser_->_reset ();

  if (this->Mass_parser_)
    this->Mass_parser_->_reset ();

  if (this->Speed_parser_)
    this->Speed_parser_->_reset ();

  if (this->ProjectileCount_parser_)
    this->ProjectileCount_parser_->_reset ();

  this->resetting_ = false;
}

#include <assert.h>

// Element validation and dispatch functions for RangeType_pskel.
//
bool RangeType_pskel::
_start_element_impl (const ::xsde::cxx::ro_string& ns,
                     const ::xsde::cxx::ro_string& n)
{
  ::xsde::cxx::parser::context& ctx = this->_context ();

  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_* vd = vs.data + (vs.size - 1);

  if (vd->func == 0 && vd->state == 0)
  {
    typedef ::xsde::cxx::parser::validating::complex_content base;
    if (base::_start_element_impl (ns, n))
      return true;
    else
      vd->state = 1;
  }

  while (vd->func != 0)
  {
    (this->*vd->func) (vd->state, vd->count, ns, n, true);

    vd = vs.data + (vs.size - 1);

    if (vd->state == ~0UL && !ctx.error_type ())
      vd = vs.data + (--vs.size - 1);
    else
      break;
  }

  if (vd->func == 0)
  {
    if (vd->state != ~0UL)
    {
      unsigned long s = ~0UL;

      if (n == "Initial" && ns.empty ())
        s = 0UL;

      if (s != ~0UL)
      {
        vd->count++;
        vd->state = ~0UL;

        vd = vs.data + vs.size++;
        vd->func = &RangeType_pskel::sequence_0;
        vd->state = s;
        vd->count = 0;

        this->sequence_0 (vd->state, vd->count, ns, n, true);
      }
      else
      {
        if (vd->count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          return true;
        }

        return false;
      }
    }
    else
      return false;
  }

  return true;
}

bool RangeType_pskel::
_end_element_impl (const ::xsde::cxx::ro_string& ns,
                   const ::xsde::cxx::ro_string& n)
{
  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_& vd = vs.data[vs.size - 1];

  if (vd.func == 0 && vd.state == 0)
  {
    typedef ::xsde::cxx::parser::validating::complex_content base;
    if (!base::_end_element_impl (ns, n))
      assert (false);
    return true;
  }

  assert (vd.func != 0);
  (this->*vd.func) (vd.state, vd.count, ns, n, false);

  if (vd.state == ~0UL)
    vs.size--;

  return true;
}

void RangeType_pskel::
_pre_e_validate ()
{
  this->v_state_stack_.push ();
  static_cast< v_state_* > (this->v_state_stack_.top ())->size = 0;

  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_& vd = vs.data[vs.size++];

  vd.func = 0;
  vd.state = 0;
  vd.count = 0;
}

void RangeType_pskel::
_post_e_validate ()
{
  ::xsde::cxx::parser::context& ctx = this->_context ();

  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_* vd = vs.data + (vs.size - 1);

  ::xsde::cxx::ro_string empty;
  while (vd->func != 0)
  {
    (this->*vd->func) (vd->state, vd->count, empty, empty, true);

    if (ctx.error_type ())
      return;

    assert (vd->state == ~0UL);
    vd = vs.data + (--vs.size - 1);
  }

  if (vd->count < 1UL)
    this->_schema_error (::xsde::cxx::schema_error::expected_element);

  this->v_state_stack_.pop ();
}

void RangeType_pskel::
sequence_0 (unsigned long& state,
            unsigned long& count,
            const ::xsde::cxx::ro_string& ns,
            const ::xsde::cxx::ro_string& n,
            bool start)
{
  ::xsde::cxx::parser::context& ctx = this->_context ();

  XSDE_UNUSED (ctx);

  switch (state)
  {
    case 0UL:
    {
      if (n == "Initial" && ns.empty ())
      {
        if (start)
        {
          if (this->Initial_parser_)
          {
            this->Initial_parser_->pre ();
            ctx.nested_parser (this->Initial_parser_);
          }
        }
        else
        {
          if (this->Initial_parser_ != 0)
          {
            float tmp = this->Initial_parser_->post_float ();
            this->Initial (tmp);
          }

          count = 0;
          state = 1UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = 1UL;
        // Fall through.
      }
    }
    case 1UL:
    {
      if (n == "Up" && ns.empty ())
      {
        if (start)
        {
          if (this->Up_parser_)
          {
            this->Up_parser_->pre ();
            ctx.nested_parser (this->Up_parser_);
          }
        }
        else
        {
          if (this->Up_parser_ != 0)
          {
            float tmp = this->Up_parser_->post_float ();
            this->Up (tmp);
          }

          count = 0;
          state = 2UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = 2UL;
        // Fall through.
      }
    }
    case 2UL:
    {
      if (n == "Down" && ns.empty ())
      {
        if (start)
        {
          if (this->Down_parser_)
          {
            this->Down_parser_->pre ();
            ctx.nested_parser (this->Down_parser_);
          }
        }
        else
        {
          if (this->Down_parser_ != 0)
          {
            float tmp = this->Down_parser_->post_float ();
            this->Down (tmp);
          }

          count = 0;
          state = ~0UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = ~0UL;
        // Fall through.
      }
    }
    case ~0UL:
      break;
  }
}

// Element validation and dispatch functions for WeaponDescriptionType_pskel.
//
bool WeaponDescriptionType_pskel::
_start_element_impl (const ::xsde::cxx::ro_string& ns,
                     const ::xsde::cxx::ro_string& n)
{
  ::xsde::cxx::parser::context& ctx = this->_context ();

  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_* vd = vs.data + (vs.size - 1);

  if (vd->func == 0 && vd->state == 0)
  {
    typedef ::xsde::cxx::parser::validating::complex_content base;
    if (base::_start_element_impl (ns, n))
      return true;
    else
      vd->state = 1;
  }

  while (vd->func != 0)
  {
    (this->*vd->func) (vd->state, vd->count, ns, n, true);

    vd = vs.data + (vs.size - 1);

    if (vd->state == ~0UL && !ctx.error_type ())
      vd = vs.data + (--vs.size - 1);
    else
      break;
  }

  if (vd->func == 0)
  {
    if (vd->state != ~0UL)
    {
      unsigned long s = ~0UL;

      if (n == "WeaponType" && ns.empty ())
        s = 0UL;

      if (s != ~0UL)
      {
        vd->count++;
        vd->state = ~0UL;

        vd = vs.data + vs.size++;
        vd->func = &WeaponDescriptionType_pskel::sequence_0;
        vd->state = s;
        vd->count = 0;

        this->sequence_0 (vd->state, vd->count, ns, n, true);
      }
      else
      {
        if (vd->count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          return true;
        }

        return false;
      }
    }
    else
      return false;
  }

  return true;
}

bool WeaponDescriptionType_pskel::
_end_element_impl (const ::xsde::cxx::ro_string& ns,
                   const ::xsde::cxx::ro_string& n)
{
  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_& vd = vs.data[vs.size - 1];

  if (vd.func == 0 && vd.state == 0)
  {
    typedef ::xsde::cxx::parser::validating::complex_content base;
    if (!base::_end_element_impl (ns, n))
      assert (false);
    return true;
  }

  assert (vd.func != 0);
  (this->*vd.func) (vd.state, vd.count, ns, n, false);

  if (vd.state == ~0UL)
    vs.size--;

  return true;
}

void WeaponDescriptionType_pskel::
_pre_e_validate ()
{
  this->v_state_stack_.push ();
  static_cast< v_state_* > (this->v_state_stack_.top ())->size = 0;

  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_& vd = vs.data[vs.size++];

  vd.func = 0;
  vd.state = 0;
  vd.count = 0;
}

void WeaponDescriptionType_pskel::
_post_e_validate ()
{
  ::xsde::cxx::parser::context& ctx = this->_context ();

  v_state_& vs = *static_cast< v_state_* > (this->v_state_stack_.top ());
  v_state_descr_* vd = vs.data + (vs.size - 1);

  ::xsde::cxx::ro_string empty;
  while (vd->func != 0)
  {
    (this->*vd->func) (vd->state, vd->count, empty, empty, true);

    if (ctx.error_type ())
      return;

    assert (vd->state == ~0UL);
    vd = vs.data + (--vs.size - 1);
  }

  if (vd->count < 1UL)
    this->_schema_error (::xsde::cxx::schema_error::expected_element);

  this->v_state_stack_.pop ();
}

void WeaponDescriptionType_pskel::
sequence_0 (unsigned long& state,
            unsigned long& count,
            const ::xsde::cxx::ro_string& ns,
            const ::xsde::cxx::ro_string& n,
            bool start)
{
  ::xsde::cxx::parser::context& ctx = this->_context ();

  XSDE_UNUSED (ctx);

  switch (state)
  {
    case 0UL:
    {
      if (n == "WeaponType" && ns.empty ())
      {
        if (start)
        {
          if (this->WeaponType_parser_)
          {
            this->WeaponType_parser_->pre ();
            ctx.nested_parser (this->WeaponType_parser_);
          }
        }
        else
        {
          if (this->WeaponType_parser_ != 0)
          {
            const ::WeaponTypeEnum& tmp = this->WeaponType_parser_->post_WeaponTypeEnum ();
            this->WeaponType (tmp);
          }

          count = 0;
          state = 1UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = 1UL;
        // Fall through.
      }
    }
    case 1UL:
    {
      if (n == "Icon" && ns.empty ())
      {
        if (start)
        {
          if (this->Icon_parser_)
          {
            this->Icon_parser_->pre ();
            ctx.nested_parser (this->Icon_parser_);
          }
        }
        else
        {
          if (this->Icon_parser_ != 0)
          {
            const ::std::string& tmp = this->Icon_parser_->post_string ();
            this->Icon (tmp);
          }

          count = 0;
          state = 2UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = 2UL;
        // Fall through.
      }
    }
    case 2UL:
    {
      if (n == "Mass" && ns.empty ())
      {
        if (start)
        {
          if (this->Mass_parser_)
          {
            this->Mass_parser_->pre ();
            ctx.nested_parser (this->Mass_parser_);
          }
        }
        else
        {
          if (this->Mass_parser_ != 0)
          {
            const ::RangeType& tmp = this->Mass_parser_->post_RangeType ();
            this->Mass (tmp);
          }

          count = 0;
          state = 3UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = 3UL;
        // Fall through.
      }
    }
    case 3UL:
    {
      if (n == "Speed" && ns.empty ())
      {
        if (start)
        {
          if (this->Speed_parser_)
          {
            this->Speed_parser_->pre ();
            ctx.nested_parser (this->Speed_parser_);
          }
        }
        else
        {
          if (this->Speed_parser_ != 0)
          {
            const ::RangeType& tmp = this->Speed_parser_->post_RangeType ();
            this->Speed (tmp);
          }

          count = 0;
          state = 4UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = 4UL;
        // Fall through.
      }
    }
    case 4UL:
    {
      if (n == "ProjectileCount" && ns.empty ())
      {
        if (start)
        {
          if (this->ProjectileCount_parser_)
          {
            this->ProjectileCount_parser_->pre ();
            ctx.nested_parser (this->ProjectileCount_parser_);
          }
        }
        else
        {
          if (this->ProjectileCount_parser_ != 0)
          {
            const ::RangeType& tmp = this->ProjectileCount_parser_->post_RangeType ();
            this->ProjectileCount (tmp);
          }

          count = 0;
          state = ~0UL;
        }

        break;
      }
      else
      {
        assert (start);
        if (count < 1UL)
        {
          this->_schema_error (::xsde::cxx::schema_error::expected_element);
          break;
        }

        count = 0;
        state = ~0UL;
        // Fall through.
      }
    }
    case ~0UL:
      break;
  }
}

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

