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 PacketData inline non-template implementation */
18 #include <senf/Utils/senfassert.hh>
20 #include "PacketImpl.hh"
21 // #include "PacketParser.hh"
23 #define prefix_ inline
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
29 prefix_ senf::detail::PacketImpl & senf::PacketData::impl()
34 "Internal failure: PacketData (PacketInterpreter) instance not part of any Packet?");
38 prefix_ senf::PacketData::iterator senf::PacketData::begin()
41 SENF_ASSERT(begin_ <= impl().size(),
42 "Internal failure: PacketInterpreter range outside of data container");
43 return boost::next(impl().begin(),begin_);
46 prefix_ senf::PacketData::iterator senf::PacketData::end()
49 SENF_ASSERT(end_ <= impl().size(),
50 "Internal failure: PacketInterpreter range outside of data container");
51 return boost::next(impl().begin(),end_);
54 prefix_ senf::PacketData::size_type senf::PacketData::size()
60 prefix_ bool senf::PacketData::empty()
63 return begin_ == end_;
66 prefix_ senf::PacketData::byte senf::PacketData::operator[](size_type n)
69 SENF_ASSERT( n < size(), "Access out of container range" );
70 return *( boost::next(begin(),n) );
73 prefix_ senf::PacketData::byte & senf::PacketData::operator[](size_type n)
75 SENF_ASSERT( n < size(), "Access out of container range" );
76 return *( boost::next(begin(),n) );
79 // Modifying the raw packet data
81 prefix_ void senf::PacketData::insert(iterator pos, byte v)
83 impl().insert(this,pos,v);
86 prefix_ void senf::PacketData::insert(iterator pos, size_type n, byte v)
88 impl().insert(this,pos,n,v);
91 prefix_ void senf::PacketData::erase(iterator pos)
93 impl().erase(this,pos);
96 prefix_ void senf::PacketData::erase(iterator first, iterator last)
98 impl().erase(this,first,last);
101 prefix_ void senf::PacketData::clear()
106 prefix_ void senf::PacketData::zero(iterator first, iterator last)
108 ::memset(first, 0, last-first);
111 prefix_ bool senf::PacketData::usingExternalMemory()
114 return impl().usingExternalMemory();
117 prefix_ void senf::PacketData::releaseExternalMemory()
119 impl().releaseExternalMemory();
122 prefix_ bool senf::PacketData::valid()
129 prefix_ senf::PacketData::PacketData(size_type b, size_type e)
130 : impl_(), begin_(b), end_(e)
133 //-/////////////////////////////////////////////////////////////////////////////////////////////////
140 // c-file-style: "senf"
141 // indent-tabs-mode: nil
142 // ispell-local-dictionary: "american"
143 // compile-command: "scons -u test"
144 // comment-column: 40