Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ListNParser.ct

Go to the documentation of this file.
00001 // $Id: ListNParser.ct 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #include "ListNParser.ih"
00027 
00028 // Custom includes
00029 #include <senf/Utils/senfassert.hh>
00030 
00031 #define prefix_
00032 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00033 
00034 template <class ElementParser, class AuxPolicy>
00035 prefix_ void
00036 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::setFromPosition(container_type const & c,
00037                                                                            iterator_data & d,
00038                                                                            data_iterator p)
00039     const
00040 {
00041     if (p == c.data().end()) {
00042         d.n_ = 0;
00043         return;
00044     }
00045     d.n_ = this->aux(c.i(),c.state());
00046     data_iterator j (this->adjust(c.i(),c.state()));
00047     for (; d.n_; --d.n_, j += ElementParser(j,c.state()).bytes())
00048         if (j==p)
00049             return;
00050     SENF_ASSERT( false, "setFromPosition: position does not point to any list element" );
00051 }
00052 
00053 template <class ElementParser, class AuxPolicy>
00054 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
00055 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::raw(container_type const & c,
00056                                                                iterator_data const & d)
00057     const
00058 {
00059     if (container_type::iterator::get(d).i() != c.data().end())
00060         return container_type::iterator::get(d).i();
00061     size_type n (this->aux(c.i(),c.state()));
00062     data_iterator j (this->adjust(c.i(),c.state()));
00063     for (; n; --n)
00064         j += ElementParser(j,c.state()).bytes();
00065     return j;
00066 }
00067 
00068 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00069 #undef prefix_
00070 
00071 
00072 // Local Variables:
00073 // mode: c++
00074 // fill-column: 100
00075 // comment-column: 40
00076 // c-file-style: "senf"
00077 // indent-tabs-mode: nil
00078 // ispell-local-dictionary: "american"
00079 // compile-command: "scons -u test"
00080 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research