00001 // $Id: ArrayParser.ih 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 #ifndef IH_SENF_Packets_ArrayParser_ 00027 #define IH_SENF_Packets_ArrayParser_ 1 00028 00029 // Custom includes 00030 #include <boost/iterator/iterator_facade.hpp> 00031 00032 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00033 00041 template <class ElementParser> 00042 class senf::detail::ArrayParser_iterator 00043 : public boost::iterator_facade< ArrayParser_iterator<ElementParser>, 00044 ElementParser, 00045 boost::random_access_traversal_tag, 00046 ElementParser > 00047 { 00048 public: 00049 ArrayParser_iterator(); 00050 ArrayParser_iterator(PacketParserBase::data_iterator const & i, 00051 PacketParserBase::state_type s); 00052 00053 // Needed to elide the []-proxy of iterator_facade 00054 ElementParser operator[](int i) const; 00055 00056 PacketParserBase::data_iterator raw() const; 00057 00060 protected: 00061 00062 private: 00063 friend class boost::iterator_core_access; 00064 00065 // iterator_facade interface 00066 00067 ElementParser dereference() const; 00068 bool equal(ArrayParser_iterator const & other) const; 00069 int distance_to(ArrayParser_iterator const & other) const; 00070 void increment(); 00071 void decrement(); 00072 void advance(int n); 00073 00074 PacketParserBase::data_iterator i_; 00075 PacketParserBase::state_type s_; 00076 }; 00077 00078 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00079 #endif 00080 00081 00082 // Local Variables: 00083 // mode: c++ 00084 // fill-column: 100 00085 // c-file-style: "senf" 00086 // indent-tabs-mode: nil 00087 // ispell-local-dictionary: "american" 00088 // compile-command: "scons -u test" 00089 // comment-column: 40 00090 // End: