Kagome
Polkadot Runtime Engine in C++17
buffer_back_insert_iterator.hpp
Go to the documentation of this file.
1 
6 #include "common/buffer.hpp"
7 
8 /*
9  * std::back_insert_iterator is an output iterator
10  * that appends to a container for which it was constructed.
11  */
12 template <size_t MaxSize>
13 class std::back_insert_iterator<kagome::common::SLBuffer<MaxSize>> {
15 
16  public:
17  using value_type = typename Container::value_type;
18  using difference_type = typename Container::difference_type;
19  using pointer = typename Container::pointer;
20  using reference = typename Container::reference;
21  using iterator_category = std::random_access_iterator_tag;
22 
23  constexpr explicit back_insert_iterator(Container &c) : buf_{c} {}
24 
25  back_insert_iterator<Container> &operator=(uint8_t value) {
26  buf_.putUint8(value);
27  return *this;
28  }
29 
30  back_insert_iterator<Container> &operator=(uint32_t value) {
31  buf_.putUint32(value);
32  return *this;
33  }
34 
35  back_insert_iterator<Container> &operator=(uint64_t value) {
36  buf_.putUint64(value);
37  return *this;
38  }
39 
40  back_insert_iterator<Container> &operator=(std::string_view value) {
41  buf_.put(value);
42  return *this;
43  }
44 
45  back_insert_iterator<Container> &operator=(gsl::span<const uint8_t> s) {
46  buf_.put(s);
47  return *this;
48  }
49 
50  back_insert_iterator<Container> &operator=(const std::vector<uint8_t> &v) {
51  buf_.put(v);
52  return *this;
53  }
54 
55  constexpr back_insert_iterator &operator*() {
56  return *this;
57  }
58 
59  constexpr back_insert_iterator &operator++() {
60  return *this;
61  }
62 
63  constexpr back_insert_iterator &operator++(int) {
64  return *this;
65  }
66 
67  private:
69 };
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
back_insert_iterator< Container > & operator=(std::string_view value)
back_insert_iterator< Container > & operator=(uint64_t value)
back_insert_iterator< Container > & operator=(uint32_t value)
back_insert_iterator< Container > & operator=(gsl::span< const uint8_t > s)
back_insert_iterator< Container > & operator=(const std::vector< uint8_t > &v)