2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief GenericTLV internal header */
17 #ifndef IH_SENF_Packets_GenericTLV_
18 #define IH_SENF_Packets_GenericTLV_ 1
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 class GenericTLVParserBase;
29 template <class ListPolicy>
34 template <class BaseParser>
35 struct GenericTLVParserRegistry_EntryBase {
36 virtual ~GenericTLVParserRegistry_EntryBase() {}
37 virtual void dump(GenericTLVParserBase<BaseParser> const & parser, std::ostream & os) const = 0;
38 virtual PacketParserBase::size_type bytes(GenericTLVParserBase<BaseParser> const & parser) const = 0;
39 virtual std::string name() const = 0;
42 template <class BaseParser, class Parser>
43 struct GenericTLVParserRegistry_Entry
44 : GenericTLVParserRegistry_EntryBase<BaseParser>
46 virtual void dump(GenericTLVParserBase<BaseParser> const & parser, std::ostream & os) const;
47 virtual PacketParserBase::size_type bytes(GenericTLVParserBase<BaseParser> const & parser) const;
48 virtual std::string name() const;
52 // Helper Functor for STL-compatible predicate (E.g. find_if, for_each ...)
53 template <class BaseParser, class Parser>
56 bool operator() (BaseParser const & p) const {
57 return p.template is<Parser>();
61 struct GenericTLVParserBaseTag {};
63 template <class TLVParser>
64 struct ListParserTraits<TLVParser, typename boost::enable_if<boost::is_base_of<GenericTLVParserBaseTag, TLVParser> >::type>
66 template <class AuxPolicy, class AuxTag>
68 typedef senf::TLVListParser<
69 typename ListParserPolicy<TLVParser, AuxPolicy, AuxTag>::type> type;
76 //-/////////////////////////////////////////////////////////////////////////////////////////////////
84 // c-file-style: "senf"
85 // indent-tabs-mode: nil
86 // ispell-local-dictionary: "american"
87 // compile-command: "scons -u test"