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 VectorParser internal header */
17 #ifndef IH_SENF_Packets_VectorParser_
18 #define IH_SENF_Packets_VectorParser_ 1
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
29 template <class ElementParser, class AuxPolicy, class AuxTag>
30 struct VectorParserPolicy
33 template <class ElementParser, class AuxPolicy>
34 struct VectorParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::none>
36 typedef AuxPolicy type;
39 template <class ElementParser, class AuxPolicy, class Transform>
40 struct VectorParserPolicy<ElementParser, AuxPolicy,
41 senf::detail::auxtag::transform<Transform,
42 senf::detail::auxtag::none> >
44 typedef senf::detail::TransformAuxParserPolicy<AuxPolicy, Transform> type;
47 template <unsigned fixedSize>
48 struct VectorParserBytesTransform
50 typedef PacketParserBase::size_type value_type;
51 static value_type get(value_type v) { return v/fixedSize; }
52 static value_type set(value_type v) { return v*fixedSize; }
55 template <class ElementParser, class AuxPolicy>
56 struct VectorParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::bytes>
58 typedef senf::detail::TransformAuxParserPolicy<
60 VectorParserBytesTransform<ElementParser::fixed_bytes> > type;
63 template <class ElementParser>
64 struct VectorParserTraits
66 template <class AuxPolicy, class AuxTag>
68 typedef senf::VectorParser<
70 typename VectorParserPolicy<ElementParser, AuxPolicy, AuxTag>::type > type;
75 # define SENF_PARSER_VECTOR_I(access, name, size, elt_type) \
76 SENF_PARSER_REQUIRE_VAR(vector) \
77 SENF_PARSER_COLLECTION_I( access, \
80 senf::detail::VectorParserTraits<elt_type> )
86 //-/////////////////////////////////////////////////////////////////////////////////////////////////
94 // c-file-style: "senf"
95 // indent-tabs-mode: nil
96 // ispell-local-dictionary: "american"
97 // compile-command: "scons -u test"