X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FVectorParser.ih;h=bd46aa1161c1cfaa2834f417ae6d512dee6a2bb7;hb=fd3a0e8ac95d1158e9ea661ddf9187b67c70169f;hp=af7916844bc61149ccf86c79cd7a0be4344bfae6;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Packets/VectorParser.ih b/Packets/VectorParser.ih index af79168..bd46aa1 100644 --- a/Packets/VectorParser.ih +++ b/Packets/VectorParser.ih @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// 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 @@ -23,8 +23,8 @@ /** \file \brief VectorParser internal header */ -#ifndef IH_VectorParser_ -#define IH_VectorParser_ 1 +#ifndef IH_SENF_Packets_VectorParser_ +#define IH_SENF_Packets_VectorParser_ 1 // Custom includes @@ -33,38 +33,65 @@ namespace senf { namespace detail { - /** \brief Internal: Sizer implementing prefix sizing +#ifndef DOXYGEN - \internal + template + struct VectorParserPolicy + {}; - This is the sizer policy used by VectorNParser - */ - template - struct VectorNParser_Sizer + template + struct VectorParserPolicy { - typedef PacketParserBase::size_type size_type; - typedef PacketParserBase::data_iterator iterator; - typedef PacketParserBase::state_type state_type; + typedef AuxPolicy type; + }; - static const size_type init_bytes = 0; + template + struct VectorParserPolicy > + { + typedef senf::detail::TransformAuxParserPolicy type; + }; - size_type size (iterator i, state_type s) const; - void size (iterator i, state_type s, size_type v) const; - iterator begin (iterator i, state_type s) const; - size_type bytes (iterator i, state_type s) const; - void init (iterator i, state_type s) const; + template + struct VectorParserBytesTransform + { + typedef PacketParserBase::size_type value_type; + static value_type get(value_type v) { return v/fixedSize; } + static value_type set(value_type v) { return v*fixedSize; } }; -# define SENF_PARSER_VEC_N_I(field, name, size, elt_type) \ - typedef senf::VectorNParser< elt_type, \ - BOOST_PP_CAT(size, _t), \ - SENF_PARSER_CURRENT_FIXED_OFFSET() \ - - SENF_PARSER_FIXED_OFFSET(size) \ - >::parser BOOST_PP_CAT(name, _vec_t); \ - field( name, BOOST_PP_CAT(name, _vec_t) ) + template + struct VectorParserPolicy + { + typedef senf::detail::TransformAuxParserPolicy< + AuxPolicy, + VectorParserBytesTransform > type; + }; -}} + template + struct VectorParserTraits + { + template + struct parser { + typedef senf::VectorParser< + ElementParser, + typename VectorParserPolicy::type > type; + }; + }; + + +# define SENF_PARSER_VECTOR_I(access, name, size, elt_type) \ + SENF_PARSER_REQUIRE_VAR(vector) \ + SENF_PARSER_COLLECTION_I( access, \ + name, \ + size, \ + senf::detail::VectorParserTraits ) +#endif + +}} + ///////////////////////////////ih.e//////////////////////////////////////// #endif