INet6Address.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 INet6Address non-inline template implementation */
16 
17 #include "INet6Address.ih"
18 
19 // Custom includes
20 
21 #define prefix_
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::INet6Address
26 
27 template <class InputIterator>
28 prefix_ senf::INet6Address senf::INet6Address::from_data(InputIterator i)
29 {
30  INet6Address addr (senf::noinit);
31  iterator j (addr.begin());
32  iterator const j_end (addr.end());
33  for (;j!=j_end;++j,++i)
34  *j = *i;
35  return addr;
36 }
37 
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // namespace senf::detail members
40 
41 template <class ForwardIterator, class Function>
42 prefix_ void senf::detail::apply_mask(unsigned bits, ForwardIterator b, ForwardIterator e,
43  Function fn)
44 {
45  for (; bits>8 && b != e; bits -= 8, ++b)
46  fn(*b, boost::lambda::make_const(0xFFu));
47  if (bits > 0 && b != e)
48  fn( *(b++), boost::lambda::make_const(~ low_bits_mask(8-bits)));
49  for (; b != e; ++b)
50  fn(*b, boost::lambda::make_const(0u));
51 }
52 
53 template <class ForwardIterator1, class ForwardIterator2, class Function>
54 prefix_ ForwardIterator1 senf::detail::find_if_mask(unsigned bits, ForwardIterator1 b1,
55  ForwardIterator1 e1, ForwardIterator2 b2,
56  Function fn)
57 {
58  for (; bits>8 && b1 != e1; bits -= 8, ++b1, ++b2)
59  if (fn(*b1, *b2, boost::lambda::make_const(0xFFu)))
60  return b1;
61  if (bits > 0 && b1 != e1)
62  if (fn(*b1, *b2, boost::lambda::make_const(~ low_bits_mask(8-bits))))
63  return b1;
64  for (++b1, ++b2; b1 != e1; ++b1, ++b2)
65  if (fn(*b1, *b2, boost::lambda::make_const(0u)))
66  return b1;
67  return e1;
68 }
69 
70 //-/////////////////////////////////////////////////////////////////////////////////////////////////
71 #undef prefix_
72 
73 
74 // Local Variables:
75 // mode: c++
76 // fill-column: 100
77 // comment-column: 40
78 // c-file-style: "senf"
79 // indent-tabs-mode: nil
80 // ispell-local-dictionary: "american"
81 // compile-command: "scons -u test"
82 // End: