ListNParser.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 ListNParser non-inline template implementation */
16 
17 #include "ListNParser.ih"
18 
19 // Custom includes
20 #include <senf/Utils/senfassert.hh>
21 
22 #define prefix_
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 template <class ElementParser, class AuxPolicy>
26 prefix_ void
27 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::setFromPosition(container_type const & c,
28  iterator_data & d,
29  data_iterator p)
30  const
31 {
32  if (p == c.data().end()) {
33  d.n_ = 0;
34  return;
35  }
36  d.n_ = this->aux(c.i(),c.state());
37  data_iterator j (this->adjust(c.i(),c.state()));
38  for (; d.n_; --d.n_, j += ElementParser(j,c.state()).bytes())
39  if (j==p)
40  return;
41  SENF_ASSERT( false, "setFromPosition: position does not point to any list element" );
42 }
43 
44 template <class ElementParser, class AuxPolicy>
45 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
46 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::raw(container_type const & c,
47  iterator_data const & d)
48  const
49 {
50  if (container_type::iterator::get(d).i() != c.data().end())
51  return container_type::iterator::get(d).i();
52  size_type n (this->aux(c.i(),c.state()));
53  data_iterator j (this->adjust(c.i(),c.state()));
54  for (; n; --n)
55  j += ElementParser(j,c.state()).bytes();
56  return j;
57 }
58 
59 //-/////////////////////////////////////////////////////////////////////////////////////////////////
60 #undef prefix_
61 
62 
63 // Local Variables:
64 // mode: c++
65 // fill-column: 100
66 // comment-column: 40
67 // c-file-style: "senf"
68 // indent-tabs-mode: nil
69 // ispell-local-dictionary: "american"
70 // compile-command: "scons -u test"
71 // End: