algorithms.hh
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 
17 #ifndef HH_SENF_Packets_algorithms_
18 #define HH_SENF_Packets_algorithms_ 1
19 
20 // Custom includes
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 namespace senf {
25 
26  template<class CollectionParser>
28  : public std::iterator<std::output_iterator_tag, void, void, void, void>
29  {
30  public:
31  back_insert_iterator(CollectionParser const & parser)
32  : container_(parser)
33  {}
34 
35  template<class Value>
36  back_insert_iterator & operator=(Value const & value)
37  {
38  container_.push_back(value);
39  return *this;
40  }
41 
42  back_insert_iterator & operator*() { return *this; }
43  back_insert_iterator & operator++() { return *this; }
44  back_insert_iterator & operator++(int){ return *this; }
45 
46  private:
47  typename CollectionParser::container_type container_;
48  };
49 
50  template<class CollectionParser>
51  inline back_insert_iterator<CollectionParser> back_inserter(CollectionParser const & parser)
52  {
54  }
55 
56 
57  template <class ListPolicy, class OutputIterator>
58  void copy(ListParser<ListPolicy> const & listParser, OutputIterator result)
59  {
60  typename ListParser<ListPolicy>::container_type container (listParser);
61  std::copy( container.begin(), container.end(), result);
62  }
63 
64 }
65 
66 //-/////////////////////////////////////////////////////////////////////////////////////////////////
67 //#include "algorithms.cci"
68 //#include "algorithms.ct"
69 //#include "algorithms.cti"
70 #endif
71 
72 
73 // Local Variables:
74 // mode: c++
75 // fill-column: 100
76 // c-file-style: "senf"
77 // indent-tabs-mode: nil
78 // ispell-local-dictionary: "american"
79 // compile-command: "scons -u test"
80 // comment-column: 40
81 // End:
back_insert_iterator & operator=(Value const &value)
Definition: algorithms.hh:36
ListPolicy::container_type container_type
Definition: ListParser.hh:87
back_insert_iterator< CollectionParser > back_inserter(CollectionParser const &parser)
Definition: algorithms.hh:51
void copy(ListParser< ListPolicy > const &listParser, OutputIterator result)
Definition: algorithms.hh:58
back_insert_iterator & operator++()
Definition: algorithms.hh:43
back_insert_iterator(CollectionParser const &parser)
Definition: algorithms.hh:31
raw_container::iterator iterator
Definition: PacketTypes.hh:69
Arbitrary sequential element collection.
Definition: ListParser.hh:65
back_insert_iterator & operator++(int)
Definition: algorithms.hh:44
back_insert_iterator & operator*()
Definition: algorithms.hh:42