4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /** \brief Example of a variant policy. ONLY FOR EXPOSITION
27 This class shows the interace which must be impemented by a variant policy. It is \e not a
28 variant policy, it is only a declaration of the interface:
30 struct ExampleVariantPolicy
32 // optional typedefs used tosimplify all other declarations
33 typedef PacketParserBase::data_iterator data_iterator;
34 typedef PacketParserBase::state_type state_type;
35 typedef PacketParserBase::size_type size_type;
38 static size_type const init_bytes = 0;
39 size_type bytes (data_iterator i, state_type s) const;
41 data_iterator begin(data_iterator i, state_type s) const;
43 unsigned variant (data_iterator i, state_type s) const;
44 void variant (unsigned v, data_iterator i, state_type s);
48 The \a VariantPolicy may define additional data members if needed. It must be either default
49 constructible or copy constructible. If a \a VariantPolicy is not default constructible, an
50 additional \a VariantPolicy argument needs to be passed to the senf::Parse_Variant
51 constructor which is used to copy-initialize the embeded policy.
53 \see senf::Parse_Variant
55 struct ExampleVariantPolicy
57 typedef PacketParserBase::data_iterator data_iterator;
58 typedef PacketParserBase::state_type state_type;
59 typedef PacketParserBase::size_type size_type;
61 static size_type const init_bytes = 0; ///< Additional initial size
62 /**< This value is added to the size of the first variant
63 sub-parser to calculate the \c init_bytes value. */
65 size_type bytes (data_iterator i, state_type s) const;
66 ///< Additional parser size
67 /**< The return value is added to the size of the current
70 data_iterator begin(data_iterator i, state_type s) const;
71 ///< Advance \a i to beginning of variant data
72 /**< This member must return the beginning of the variant's
73 data (the place, where the sub-parsers reside in the
76 unsigned variant (data_iterator i, state_type s) const;
77 ///< Get current variant index
78 /**< \returns current variant sub-parser, interpreted as
79 index into the 0-indexed list of sub-parsers. */
81 void variant (unsigned v, data_iterator i, state_type s);
82 ///< Set current variant index
83 /**< Must set the current variant to \a v which is the index
84 into the 0-index list of sub-parsers of the currently
85 active variant sub-parser.
87 This member must not process the sub-parser data (like
88 initializing the sub-parser or changing the data
99 // c-file-style: "senf"
100 // indent-tabs-mode: nil
101 // ispell-local-dictionary: "american"
102 // compile-command: "scons -u test"