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 PacketParser non-inline template implementation */
17 #include "PacketParser.ih"
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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)
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()) );
43 template <class Parser>
44 prefix_ Parser senf::operator<<(Parser const & target, Parser const & source)
48 // Why is this function reported as not inlineable ?
50 template <class Parser>
51 prefix_ senf::PacketParserBase::size_type senf::detail::packetParserSize(Parser const & p, ...)
53 return Parser::fixed_bytes;
56 //-/////////////////////////////////////////////////////////////////////////////////////////////////
64 // c-file-style: "senf"
65 // indent-tabs-mode: nil
66 // ispell-local-dictionary: "american"
67 // compile-command: "scons -u test"