switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Packets / ListNParser.ih
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief ListNParser internal header */
30
31 #ifndef IH_SENF_Packets_ListNParser_
32 #define IH_SENF_Packets_ListNParser_ 1
33
34 // Custom includes
35 #include "ListParser.ih"
36
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39 namespace senf {
40 namespace detail {
41
42     /** \brief Internal: ListPolicy defining the ListNParser parser
43         \internal
44         \see \ref ListParser
45      */
46     template <class ElementParser, class AuxPolicy>
47     struct ListNParser_Policy
48         : public AuxPolicy
49     {
50         typedef ListNParser_Policy<
51             ElementParser, typename AuxPolicy::ParserPolicy> parser_policy;
52         typedef ListNParser_Policy<
53             ElementParser, typename AuxPolicy::WrapperPolicy> container_policy;
54         typedef PacketParserBase::data_iterator data_iterator;
55         typedef PacketParserBase::state_type state_type;
56         typedef PacketParserBase::size_type size_type;
57         typedef ElementParser element_type;
58         typedef ListParser<parser_policy> parser_type;
59         typedef ListParser_Container<container_policy> container_type;
60
61         static const size_type init_bytes = AuxPolicy::aux_bytes;
62
63         ListNParser_Policy();
64         template <class Arg> ListNParser_Policy(Arg const & aux);
65         ListNParser_Policy(parser_policy const & policy);
66
67         size_type bytes  (data_iterator i, state_type s) const;
68         size_type size   (data_iterator i, state_type s) const;
69         void      init   (data_iterator i, state_type s) const;
70
71         void      construct (container_type & c) const;
72         void      destruct  (container_type & c) const;
73         void      erase     (container_type & c, data_iterator p) const;
74         void      insert    (container_type & c, data_iterator p) const;
75         void      update    (container_type const & c) const;
76
77         /** Internal: ListNParser iterator specific data */
78         struct iterator_data {
79             size_type n_;
80         };
81
82         data_iterator setBegin        (container_type const & c, iterator_data & d) const;
83         data_iterator setEnd          (container_type const & c, iterator_data & d) const;
84         void          setFromPosition (container_type const & c, iterator_data & d, data_iterator p) const;
85         data_iterator next            (container_type const & c, iterator_data & d) const;
86         data_iterator raw             (container_type const & c, iterator_data const & d) const;
87     };
88
89 #ifndef DOXYGEN
90
91     template <class ElementParser, class AuxPolicy>
92     struct ListParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::none>
93     {
94         typedef ListNParser_Policy<ElementParser, AuxPolicy> type;
95     };
96
97     template <class ElementParser, class AuxPolicy, class Transform>
98     struct ListParserPolicy<ElementParser, AuxPolicy,
99                             senf::detail::auxtag::transform<Transform,
100                                                             senf::detail::auxtag::none> >
101     {
102         typedef ListNParser_Policy< ElementParser,
103                                     TransformAuxParserPolicy<AuxPolicy, Transform> > type;
104     };
105
106 #endif
107
108 }}
109
110 //-/////////////////////////////////////////////////////////////////////////////////////////////////
111 #endif
112
113 \f
114 // Local Variables:
115 // mode: c++
116 // fill-column: 100
117 // comment-column: 40
118 // c-file-style: "senf"
119 // indent-tabs-mode: nil
120 // ispell-local-dictionary: "american"
121 // compile-command: "scons -u test"
122 // End: