X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseVec.ct;h=de1f131c767ed5587b58a759f5dbfd0109a09f75;hb=2d6585ff852e9d282c17003ba1db0b73eb3a8500;hp=a34f1c9aefe33b051d2a501cc8f37ef1f44e7b92;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Packets/ParseVec.ct b/Packets/ParseVec.ct index a34f1c9..de1f131 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 @@ -22,53 +22,89 @@ // Definition of non-inline template funPacketRegistry.ons -//#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; +} + +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; } -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 +113,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: