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

VectorParser.ct

Go to the documentation of this file.
00001 // $Id: VectorParser.ct 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2006
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 "VectorParser.ih"
00027 
00028 // Custom includes
00029 
00030 #define prefix_
00031 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00032 
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 // senf::VectorParser<ElementParser,AuxPolicy>
00035 
00036 template <class ElementParser, class AuxPolicy>
00037 prefix_ void senf::VectorParser<ElementParser,AuxPolicy>::init()
00038     const
00039 {
00040     aux(0, i(), state());
00041     iterator i (begin());
00042     iterator const e (end());
00043     for (; i!=e; ++i)
00044         i->init();
00045 }
00046 
00047 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00048 // senf::VectorParser_Container<ElementParser,AuxPolicy>
00049 
00050 template <class ElementParser, class AuxPolicy>
00051 prefix_ void senf::VectorParser_Container<ElementParser,AuxPolicy>::init()
00052     const
00053 {
00054     iterator i (begin());
00055     iterator const e (end());
00056     for (; i!=e; ++i)
00057         i->init();
00058 }
00059 
00060 // Mutators
00061 
00062 template <class ElementParser, class AuxPolicy>
00063 prefix_ typename senf::VectorParser_Container<ElementParser,AuxPolicy>::iterator
00064 senf::VectorParser_Container<ElementParser,AuxPolicy>::shift(iterator pos, size_type n)
00065 {
00066     size_type ix (std::distance(data().begin(),pos.raw()));
00067     setSize(size()+n);
00068     data().insert(pos.raw(),n*ElementParser::fixed_bytes,0);
00069     return iterator(boost::next(data().begin(),ix),state());
00070 }
00071 
00072 template <class ElementParser, class AuxPolicy>
00073 template <class Value>
00074 prefix_ void senf::VectorParser_Container<ElementParser,AuxPolicy>::insert(iterator pos,
00075                                                                        size_type n,
00076                                                                        Value const & t)
00077 {
00078     for (iterator j (shift(pos,n)); n; --n, ++j)
00079         *j << t;
00080 }
00081 
00082 #ifndef DOXYGEN
00083 template <class ElementParser, class AuxPolicy>
00084 template <class ForwardIterator>
00085 prefix_ void senf::VectorParser_Container<ElementParser,AuxPolicy>::
00086 insert(iterator pos, ForwardIterator f, ForwardIterator l,
00087        typename boost::disable_if< boost::is_convertible<ForwardIterator,size_type> >::type *)
00088 {
00089     for (iterator j (shift(pos,std::distance(f,l))); f!=l; ++f,++j)
00090         *j << *f;
00091 }
00092 #else
00093 template <class ElementParser, class AuxPolicy>
00094 template <class ForwardIterator>
00095 prefix_ void senf::VectorParser_Container<ElementParser,AuxPolicy>::
00096 insert(iterator pos, ForwardIterator f, ForwardIterator l)
00097 {}
00098 #endif
00099 
00100 template <class ElementParser, class AuxPolicy>
00101 prefix_ void senf::VectorParser_Container<ElementParser,AuxPolicy>::resize(size_type n)
00102 {
00103     if (size()>=n)
00104         erase(boost::next(begin(),n),end());
00105     else
00106         push_back_space(n-size());
00107 }
00108 
00109 template <class ElementParser, class AuxPolicy>
00110 template <class Value>
00111 prefix_ void senf::VectorParser_Container<ElementParser,AuxPolicy>::resize(size_type n,
00112                                                                            Value value)
00113 {
00114     if (size()>=n)
00115         erase(boost::next(begin(),n),end());
00116     else
00117         push_back(value,n-size());
00118 }
00119 
00120 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00121 #undef prefix_
00122 
00123 
00124 // Local Variables:
00125 // mode: c++
00126 // fill-column: 100
00127 // c-file-style: "senf"
00128 // indent-tabs-mode: nil
00129 // ispell-local-dictionary: "american"
00130 // compile-command: "scons -u test"
00131 // comment-column: 40
00132 // End:

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