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

ListBParser.cti

Go to the documentation of this file.
00001 // $Id: ListBParser.cti 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 "ListBParser.ih"
00027 
00028 // Custom includes
00029 
00030 #define prefix_ inline
00031 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00032 
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 // senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>
00035 
00036 template <class ElementParser, class AuxPolicy>
00037 prefix_ senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::ListBParser_Policy()
00038 {}
00039 
00040 template <class ElementParser, class AuxPolicy>
00041 template <class Arg>
00042 prefix_
00043 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::ListBParser_Policy(Arg const & arg)
00044     : AuxPolicy (arg)
00045 {}
00046 
00047 template <class ElementParser, class AuxPolicy>
00048 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size_type
00049 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::bytes(data_iterator i, state_type s)
00050     const
00051 {
00052     return AuxPolicy::aux(i,s) + AuxPolicy::aux_bytes;
00053 }
00054 
00055 template <class ElementParser, class AuxPolicy>
00056 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size_type
00057 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size(data_iterator i, state_type s)
00058     const
00059 {
00060     parser_type p (*this, i, s);
00061     container_type c (p);
00062     return std::distance(c.begin(),c.end());
00063 }
00064 
00065 template <class ElementParser, class AuxPolicy>
00066 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::init(data_iterator i,
00067                                                                              state_type s)
00068     const
00069 {
00070     AuxPolicy::aux(0,i,s);
00071 }
00072 
00073 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00074 // senf::detail::ListBParser_Policy<ElementParser,BytesParser>
00075 
00076 template <class ElementParser, class AuxPolicy>
00077 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size_type
00078 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::bytes(data_iterator i,
00079                                                                                    state_type s)
00080     const
00081 {
00082     return AuxPolicy::WrapperPolicy::aux(i,s) + AuxPolicy::aux_bytes;
00083 }
00084 
00085 template <class ElementParser, class AuxPolicy>
00086 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size_type
00087 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size(data_iterator i,
00088                                                                                   state_type s)
00089     const
00090 {
00091     return n_;
00092 }
00093 
00094 template <class ElementParser, class AuxPolicy>
00095 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00096 init(data_iterator i, state_type s)
00097 {
00098     n_ = 0;
00099     container_size_ = s->size();
00100     AuxPolicy::WrapperPolicy::aux(0,i,s);
00101 }
00102 
00103 template <class ElementParser, class AuxPolicy>
00104 prefix_ void
00105 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00106 construct(container_type & c)
00107     const
00108 {}
00109 
00110 template <class ElementParser, class AuxPolicy>
00111 prefix_ void
00112 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00113 destruct(container_type & c)
00114     const
00115 {}
00116 
00117 template <class ElementParser, class AuxPolicy>
00118 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00119 erase(container_type & c, data_iterator p)
00120 {
00121     size_type b (senf::bytes(ElementParser(p,c.state())));
00122     AuxPolicy::WrapperPolicy::aux(
00123         AuxPolicy::WrapperPolicy::aux(c.i(), c.state())-b, c.i(), c.state());
00124     --n_;
00125     // The container will be reduced by b bytes directly after this call
00126     container_size_ = c.data().size()-b;
00127 }
00128 
00129 template <class ElementParser, class AuxPolicy>
00130 prefix_ void
00131 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00132 insert(container_type & c, data_iterator p)
00133 {
00134     size_type b (senf::bytes(ElementParser(p,c.state())));
00135     AuxPolicy::WrapperPolicy::aux(
00136         AuxPolicy::WrapperPolicy::aux(c.i(), c.state())+b, c.i(), c.state());
00137     ++n_;
00138     container_size_ = c.data().size();
00139 }
00140 
00141 template <class ElementParser, class AuxPolicy>
00142 prefix_ void
00143 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00144 update(container_type const & c)
00145     const
00146 {
00147     if (container_size_ == c.data().size())
00148         return;
00149 #if 1
00150     data_iterator i (AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()));
00151     data_iterator j (i);
00152     for (size_type n (n_); n; --n, std::advance(j,senf::bytes(ElementParser(j,c.state())))) ;
00153     aux( std::distance(i,j), c.i(), c.state() );
00154 #else
00155     aux ( aux(c.i(),c.state()) + c.data().size() - container_size_, c.i(), c.state() );
00156 #endif
00157     container_size_ = c.data().size();
00158 }
00159 
00160 template <class ElementParser, class AuxPolicy>
00161 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
00162 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00163 setBegin(container_type const & c, iterator_data & d)
00164     const
00165 {
00166     return AuxPolicy::WrapperPolicy::adjust(c.i(), c.state());
00167 }
00168 
00169 template <class ElementParser, class AuxPolicy>
00170 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
00171 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00172 setEnd(container_type const & c, iterator_data & d)
00173     const
00174 {
00175     return boost::next(AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()),aux(c.i(),c.state()));
00176 }
00177 
00178 template <class ElementParser, class AuxPolicy>
00179 prefix_ void
00180 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00181 setFromPosition(container_type const & c, iterator_data & d, data_iterator p)
00182     const
00183 {}
00184 
00185 template <class ElementParser, class AuxPolicy>
00186 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
00187 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00188 next(container_type const & c, iterator_data & d)
00189     const
00190 {
00191     return boost::next( container_type::iterator::get(d).i(),
00192                         senf::bytes(ElementParser( container_type::iterator::get(d).i(),
00193                                                    c.state() )) );
00194 }
00195 
00196 template <class ElementParser, class AuxPolicy>
00197 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
00198 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
00199 raw(container_type const & c, iterator_data const & d)
00200     const
00201 {
00202     return container_type::iterator::get(d).i();
00203 }
00204 
00205 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00206 #undef prefix_
00207 
00208 
00209 // Local Variables:
00210 // mode: c++
00211 // fill-column: 100
00212 // comment-column: 40
00213 // c-file-style: "senf"
00214 // indent-tabs-mode: nil
00215 // ispell-local-dictionary: "american"
00216 // compile-command: "scons -u test"
00217 // End:

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