// $Id$ // // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer NETwork research (NET) // 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 ParseVariant inline template implementation */ #include "ParseVariant.ih" // Custom includes #include #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // senf::Parse_Variant template prefix_ senf::Parse_Variant:: Parse_Variant(data_iterator i, state_type s) : PacketParserBase(i,s) {} template prefix_ senf::Parse_Variant:: Parse_Variant(VariantPolicy policy, data_iterator i, state_type s) : PacketParserBase(i,s), VariantPolicy(policy) {} template prefix_ senf::PacketParserBase::size_type senf::Parse_Variant::bytes() const { return detail::VariantBytes< Parse_Variant, boost::mpl::size::value - 1 > ::bytes(*this, variant()) + VariantPolicy::bytes(i(),state()); } template prefix_ void senf::Parse_Variant::init() { VariantPolicy::variant(0,i(),state()); get<0>().init(); } template prefix_ unsigned senf::Parse_Variant::variant() const { return VariantPolicy::variant(i(),state()); } template template prefix_ typename boost::mpl::at< typename senf::Parse_Variant::parsers, boost::mpl::int_ >::type senf::Parse_Variant::get() const { BOOST_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: