VariantParser.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 VariantParser non-inline template implementation */
16 
17 #include "VariantParser.ih"
18 
19 // Custom includes
20 #include <algorithm>
21 
22 #define prefix_
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 template <class AuxPolicy, class Parsers>
26 template <unsigned N>
27 prefix_ void senf::VariantParser<AuxPolicy,Parsers>::init()
28 {
29  size_type oldSize( bytes() );
30  typedef typename boost::mpl::at<parsers, boost::mpl::int_<N> >::type NewParser;
31 
32  if (oldSize <= senf::init_bytes<NewParser>::value) {
33  data_iterator j (i());
34  std::advance(j, oldSize);
35  std::fill(i(), j, 0u);
36  safe_data_iterator safe_i (*this);
37  typename AuxPolicy::WrapperPolicy safeAux (static_cast<AuxPolicy&>(*this));
38  data().insert(j, senf::init_bytes<NewParser>::value - oldSize, 0u);
39  safeAux.aux(N, safe_i, state());
40  NewParser( safeAux.adjust(safe_i, state()), state() ).init();
41  } else {
42  data_iterator j (i());
43  std::advance(j, senf::init_bytes<NewParser>::value);
44  data().erase(j, boost::next(i(), oldSize));
45  std::fill(i(), j, 0u);
46  AuxPolicy::aux(N, i(), state());
47  NewParser(AuxPolicy::adjust(i(), state()), state()).init();
48  }
49 }
50 
51 //-/////////////////////////////////////////////////////////////////////////////////////////////////
52 #undef prefix_
53 
54 
55 // Local Variables:
56 // mode: c++
57 // fill-column: 100
58 // comment-column: 40
59 // c-file-style: "senf"
60 // indent-tabs-mode: nil
61 // ispell-local-dictionary: "american"
62 // compile-command: "scons -u test"
63 // End: