X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseVec.ct;h=d76caf3ef71ff3a2c819542bb03620c9a8dd9f2b;hb=81ffa1c459b96dd44472bcef37e1e373934ee138;hp=a34f1c9aefe33b051d2a501cc8f37ef1f44e7b92;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Packets/ParseVec.ct b/Packets/ParseVec.ct index a34f1c9..d76caf3 100644 --- a/Packets/ParseVec.ct +++ b/Packets/ParseVec.ct @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund @@ -20,55 +20,100 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline template funPacketRegistry.ons +/** \file + \brief ParseVec non-inline template implementation */ -//#include "ParseVec.ih" +#include "ParseVec.ih" // Custom includes #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// -template -template -prefix_ void -satcom::pkf::Parse_Vector_wrapper::insert(iterator pos, - Value const & t) +/////////////////////////////////////////////////////////////////////////// +// senf::Parse_Vector + +template +prefix_ void senf::Parse_Vector::init() + const +{ + sizer_.init(i(),state()); + iterator i (begin()); + iterator const e (end()); + for (; i!=e; ++i) + i->init(); +} + +/////////////////////////////////////////////////////////////////////////// +// senf::Parse_Vector_Container + +template +prefix_ void senf::Parse_Vector_Container::init() + const +{ + iterator i (begin()); + iterator const e (end()); + for (; i!=e; ++i) + i->init(); +} + +// Mutators + +template +prefix_ typename senf::Parse_Vector_Container::iterator +senf::Parse_Vector_Container::shift(iterator pos, size_type n) { - size_type ix(pos.raw()-container_.begin()); - shift(pos); - Parser(container_.begin()+ix).value(t); + size_type ix (std::distance(data().begin(),pos.raw())); + data().insert(pos.raw(),n*ElementParser::fixed_bytes,0); + setSize(size()+n); + return iterator(boost::next(data().begin(),ix),state()); } -template +template template -prefix_ void -satcom::pkf::Parse_Vector_wrapper::insert(iterator pos, +prefix_ void senf::Parse_Vector_Container::insert(iterator pos, size_type n, Value const & t) { - size_type ix(pos.raw()-container_.begin()); - shift(pos,n); - typename Container::iterator j (container_.begin()+ix); - for (; n; --n, j+=Parser::bytes()) - Parser(j).value(t); + for (iterator j (shift(pos,n)); n; --n, ++j) + *j << t; +} + +#ifndef DOXYGEN +template +template +prefix_ void senf::Parse_Vector_Container:: +insert(iterator pos, ForwardIterator f, ForwardIterator l, + typename boost::disable_if< boost::is_convertible >::type *) +{ + for (iterator j (shift(pos,std::distance(f,l))); f!=l; ++f,++j) + *j << *f; } +#else +template +template +prefix_ void senf::Parse_Vector_Container:: +insert(iterator pos, ForwardIterator f, ForwardIterator l) +{} +#endif -template -template -prefix_ void -satcom::pkf::Parse_Vector_wrapper::insert(iterator pos, - InputIterator f, - InputIterator l) +template +prefix_ void senf::Parse_Vector_Container::resize(size_type n) +{ + if (size()>=n) + erase(boost::next(begin(),n),end()); + else + push_back_space(n-size()); +} + +template +template +prefix_ void senf::Parse_Vector_Container::resize(size_type n, Value value) { - // FIXME: This is HORRIBLY inefficient ... we need to specialize - // for random_aPacketRegistry.ess and forward iterators, where we can count the distance - - size_type ix(pos.raw()-container_.begin()); - for (;f!=l;++f) { - insert(container_.begin()+ix,*f); - ix += Parser::bytes(); - } + if (size()>=n) + erase(boost::next(begin(),n),end()); + else + push_back(value,n-size()); } ///////////////////////////////ct.e//////////////////////////////////////// @@ -77,5 +122,10 @@ satcom::pkf::Parse_Vector_wrapper::insert(iterator // Local Variables: // mode: c++ -// c-file-style: "satcom" +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: