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

ListParser.ih

Go to the documentation of this file.
00001 // $Id: ListParser.ih 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 #ifndef IH_SENF_Packets_ListParser_
00027 #define IH_SENF_Packets_ListParser_ 1
00028 
00029 // Custom includes
00030 #include <boost/iterator/iterator_facade.hpp>
00031 
00032 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00033 
00034 namespace senf {
00035 namespace detail {
00036 
00041     template <class Container>
00042     class ListParser_Iterator
00043         : public boost::iterator_facade< ListParser_Iterator<Container>,
00044                                          typename Container::value_type,
00045                                          boost::forward_traversal_tag,
00046                                          typename Container::value_type >,
00047 #ifndef DOXYGEN
00048           private Container::policy::iterator_data
00049 #endif
00050     {
00051     public:
00052         typedef typename Container::value_type value_type;
00053 
00054         ListParser_Iterator();
00055         explicit ListParser_Iterator(Container const & c);
00056 
00057         PacketParserBase::data_iterator raw() const;
00058         PacketParserBase::data_iterator i() const;
00059 
00060         static ListParser_Iterator & get(typename Container::policy::iterator_data & d);
00061         static ListParser_Iterator const & get(typename Container::policy::iterator_data const & d);
00062 
00063     private:
00064         friend class boost::iterator_core_access;
00065         template <class P> friend class ListParser_Container;
00066 
00067         value_type dereference() const;
00068         bool equal(ListParser_Iterator const & other) const;
00069         void increment();
00070 
00071         PacketParserBase::data_iterator i_;
00072         Container const * c_;
00073     };
00074 
00075 #ifndef DOXYGEN
00076 
00077     template <class ElementParser, class AuxPolicy, class AuxTag>
00078     struct ListParserPolicy
00079     {};
00080 
00081     template <class ElementParser>
00082     struct ListParserTraits
00083     {
00084         template <class AuxPolicy, class AuxTag>
00085         struct parser {
00086             typedef senf::ListParser<
00087                 typename ListParserPolicy<ElementParser, AuxPolicy, AuxTag>::type > type;
00088         };
00089     };
00090 
00091 #   define SENF_PARSER_LIST_I(access, name, size, elt_type)                                       \
00092         SENF_PARSER_REQUIRE_VAR(list)                                                             \
00093             SENF_PARSER_COLLECTION_I( access,                                                     \
00094                                       name,                                                       \
00095                                       size,                                                       \
00096                                       senf::detail::ListParserTraits<elt_type> )
00097 
00098 #endif
00099 
00100 }}
00101 
00102 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00103 #endif
00104 
00105 
00106 // Local Variables:
00107 // mode: c++
00108 // fill-column: 100
00109 // comment-column: 40
00110 // c-file-style: "senf"
00111 // indent-tabs-mode: nil
00112 // ispell-local-dictionary: "american"
00113 // compile-command: "scons -u test"
00114 // End:

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