// $Id$ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // 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., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file \brief VariantParser inline template implementation */ #include "VariantParser.ih" // Custom includes #include "../Utils/senfassert.hh" #include #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // senf::VariantParser template prefix_ senf::VariantParser:: VariantParser(data_iterator i, state_type s) : PacketParserBase(i,s) {} template prefix_ senf::VariantParser:: VariantParser(VariantPolicy policy, data_iterator i, state_type s) : PacketParserBase(i,s), VariantPolicy(policy) {} template prefix_ senf::PacketParserBase::size_type senf::VariantParser::bytes() const { return detail::VariantBytes< VariantParser, boost::mpl::size::value - 1 > ::bytes(*this, variant()) + VariantPolicy::bytes(i(),state()); } template prefix_ void senf::VariantParser::init() { VariantPolicy::variant(0,i(),state()); get<0>().init(); } template prefix_ unsigned senf::VariantParser::variant() const { return VariantPolicy::variant(i(),state()); } template template prefix_ typename boost::mpl::at< typename senf::VariantParser::parsers, boost::mpl::int_ >::type senf::VariantParser::get() const { SENF_ASSERT( variant() == N ); return typename boost::mpl::at >::type( VariantPolicy::begin(i(), state()), state() ); } ///////////////////////////////////////////////////////////////////////// // senf::detail::VariantBytes template prefix_ senf::PacketParserBase::size_type senf::detail::VariantBytes::bytes(Variant const & v, unsigned n) { if (n == N) return senf::bytes(v.template get()); else return VariantBytes::bytes(v, n); } template prefix_ senf::PacketParserBase::size_type senf::detail::VariantBytes::bytes(Variant const & v, unsigned n) { return senf::bytes(v.template get<0>()); } ///////////////////////////////cti.e/////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // End: