raw_stream_processor.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2018-2019 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020 Nikita Kaskov <nbering@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_HASH_RAW_STREAM_PROCESSOR_HPP
27 #define CRYPTO3_HASH_RAW_STREAM_PROCESSOR_HPP
28 
29 #include <array>
30 #include <iterator>
31 #include <type_traits>
32 
34 
35 namespace nil {
36  namespace crypto3 {
37  namespace hashes {
38 
46  template<typename Construction, typename StateAccumulator, typename Params>
48  protected:
49  typedef typename Construction::type construction_type;
50  typedef StateAccumulator accumulator_type;
51  typedef Params params_type;
52 
53  public:
54  typedef typename params_type::digest_endian endian_type;
55 
56  template<typename InputIterator>
57  inline void operator()(InputIterator b, InputIterator e) {
58  acc(b, nil::crypto3::accumulators::iterator_last = e);
59  }
60 
61  template<typename ContainerT>
62  inline void operator()(const ContainerT &c) {
63  acc(c);
64  }
65 
66  public:
68  }
69 
70  private:
71  accumulator_type &acc;
72  };
73  } // namespace hashes
74  } // namespace crypto3
75 } // namespace nil
76 
77 #endif // CRYPTO3_HASH_RAW_STREAM_PROCESSOR_HPP
Definition: raw_stream_processor.hpp:47
Construction::type construction_type
Definition: raw_stream_processor.hpp:49
params_type::digest_endian endian_type
Definition: raw_stream_processor.hpp:54
void operator()(InputIterator b, InputIterator e)
Definition: raw_stream_processor.hpp:57
raw_stream_processor(accumulator_type &acc)
Definition: raw_stream_processor.hpp:67
StateAccumulator accumulator_type
Definition: raw_stream_processor.hpp:50
void operator()(const ContainerT &c)
Definition: raw_stream_processor.hpp:62
Params params_type
Definition: raw_stream_processor.hpp:51
Definition: pair.hpp:31