00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef IH_SENF_Packets_VectorParser_
00027 #define IH_SENF_Packets_VectorParser_ 1
00028
00029
00030
00031
00032
00033 namespace senf {
00034 namespace detail {
00035
00036 #ifndef DOXYGEN
00037
00038 template <class ElementParser, class AuxPolicy, class AuxTag>
00039 struct VectorParserPolicy
00040 {};
00041
00042 template <class ElementParser, class AuxPolicy>
00043 struct VectorParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::none>
00044 {
00045 typedef AuxPolicy type;
00046 };
00047
00048 template <class ElementParser, class AuxPolicy, class Transform>
00049 struct VectorParserPolicy<ElementParser, AuxPolicy,
00050 senf::detail::auxtag::transform<Transform,
00051 senf::detail::auxtag::none> >
00052 {
00053 typedef senf::detail::TransformAuxParserPolicy<AuxPolicy, Transform> type;
00054 };
00055
00056 template <unsigned fixedSize>
00057 struct VectorParserBytesTransform
00058 {
00059 typedef PacketParserBase::size_type value_type;
00060 static value_type get(value_type v) { return v/fixedSize; }
00061 static value_type set(value_type v) { return v*fixedSize; }
00062 };
00063
00064 template <class ElementParser, class AuxPolicy>
00065 struct VectorParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::bytes>
00066 {
00067 typedef senf::detail::TransformAuxParserPolicy<
00068 AuxPolicy,
00069 VectorParserBytesTransform<ElementParser::fixed_bytes> > type;
00070 };
00071
00072 template <class ElementParser>
00073 struct VectorParserTraits
00074 {
00075 template <class AuxPolicy, class AuxTag>
00076 struct parser {
00077 typedef senf::VectorParser<
00078 ElementParser,
00079 typename VectorParserPolicy<ElementParser, AuxPolicy, AuxTag>::type > type;
00080 };
00081 };
00082
00083
00084 # define SENF_PARSER_VECTOR_I(access, name, size, elt_type) \
00085 SENF_PARSER_REQUIRE_VAR(vector) \
00086 SENF_PARSER_COLLECTION_I( access, \
00087 name, \
00088 size, \
00089 senf::detail::VectorParserTraits<elt_type> )
00090
00091 #endif
00092
00093 }}
00094
00095
00096 #endif
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107