PacketParser.ct
Go to the documentation of this file.
1 //
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
6 //
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
11 //
12 
13 
14 /** \file
15  \brief PacketParser non-inline template implementation */
16 
17 #include "PacketParser.ih"
18 
19 // Custom includes
20 
21 #define prefix_
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 #ifndef DOXYGEN
25 template <class Parser>
26 prefix_ typename boost::enable_if_c<
27  boost::is_base_of<senf::PacketParserBase, Parser>::value && ! senf::is_fixed<Parser>::value, Parser >::type
28  senf::operator<<(Parser const & target, Parser const & source)
29 {
30  PacketParserBase::size_type target_sz (bytes(target));
31  PacketParserBase::size_type source_sz (bytes(source));
32  SafePacketParserWrapper<Parser> safe_target (target);
33  if (target_sz > source_sz)
34  target.data().erase(boost::next(target.i(),source_sz),boost::next(target.i(),target_sz));
35  else if (target_sz < source_sz)
36  target.data().insert(boost::next(target.i(),target_sz),source_sz-target_sz,0u);
37  Parser new_target (*safe_target);
38  std::copy( source.i(), boost::next(source.i(),source_sz),
39  PacketParserBase::data_iterator(new_target.i()) );
40  return new_target;
41 }
42 #else
43 template <class Parser>
44 prefix_ Parser senf::operator<<(Parser const & target, Parser const & source)
45 {}
46 #endif
47 
48 // Why is this function reported as not inlineable ?
49 
50 template <class Parser>
51 prefix_ senf::PacketParserBase::size_type senf::detail::packetParserSize(Parser const & p, ...)
52 {
53  return Parser::fixed_bytes;
54 }
55 
56 //-/////////////////////////////////////////////////////////////////////////////////////////////////
57 #undef prefix_
58 
59 
60 // Local Variables:
61 // mode: c++
62 // fill-column: 100
63 // comment-column: 40
64 // c-file-style: "senf"
65 // indent-tabs-mode: nil
66 // ispell-local-dictionary: "american"
67 // compile-command: "scons -u test"
68 // End: