Revisión | af7a39bd86ceaabc9cc13777678cc8fc5a1bc55e (tree) |
---|---|
Tiempo | 2014-05-18 02:31:02 |
Autor | wbenny <w.benny@outl...> |
Commiter | wbenny |
* ZipLib is now using "char" streams.
@@ -7,20 +7,16 @@ | ||
7 | 7 | |
8 | 8 | #include <cstdint> |
9 | 9 | |
10 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
11 | -class basic_bzip2_decoder | |
12 | - : public compression_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
10 | +class bzip2_decoder | |
11 | + : public compression_decoder_interface | |
13 | 12 | { |
14 | 13 | public: |
15 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
16 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
17 | - | |
18 | - basic_bzip2_decoder() | |
14 | + bzip2_decoder() | |
19 | 15 | { |
20 | 16 | |
21 | 17 | } |
22 | 18 | |
23 | - ~basic_bzip2_decoder() | |
19 | + ~bzip2_decoder() | |
24 | 20 | { |
25 | 21 | if (is_init()) |
26 | 22 | { |
@@ -29,13 +25,13 @@ class basic_bzip2_decoder | ||
29 | 25 | } |
30 | 26 | } |
31 | 27 | |
32 | - void init(istream_type& stream) override | |
28 | + void init(std::istream& stream) override | |
33 | 29 | { |
34 | 30 | bzip2_properties props; |
35 | 31 | init(stream, props); |
36 | 32 | } |
37 | 33 | |
38 | - void init(istream_type& stream, compression_properties_interface& props) override | |
34 | + void init(std::istream& stream, compression_properties_interface& props) override | |
39 | 35 | { |
40 | 36 | // init stream |
41 | 37 | _stream = &stream; |
@@ -49,8 +45,8 @@ class basic_bzip2_decoder | ||
49 | 45 | _bufferCapacity = bzip2Props.BufferCapacity; |
50 | 46 | |
51 | 47 | uninit_buffers(); |
52 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
53 | - _outputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
48 | + _inputBuffer = new char_type[_bufferCapacity]; | |
49 | + _outputBuffer = new char_type[_bufferCapacity]; | |
54 | 50 | |
55 | 51 | // init bzip2 |
56 | 52 | _bzstream.bzalloc = nullptr; |
@@ -71,12 +67,12 @@ class basic_bzip2_decoder | ||
71 | 67 | return (_inputBuffer != nullptr && _outputBuffer != nullptr); |
72 | 68 | } |
73 | 69 | |
74 | - ELEM_TYPE* get_buffer_begin() override | |
70 | + char_type* get_buffer_begin() override | |
75 | 71 | { |
76 | 72 | return _outputBuffer; |
77 | 73 | } |
78 | 74 | |
79 | - ELEM_TYPE* get_buffer_end() override | |
75 | + char_type* get_buffer_end() override | |
80 | 76 | { |
81 | 77 | return _outputBuffer + _outputBufferSize; |
82 | 78 | } |
@@ -123,7 +119,7 @@ class basic_bzip2_decoder | ||
123 | 119 | if (_bzstream.avail_in > 0) |
124 | 120 | { |
125 | 121 | _stream->clear(); |
126 | - _stream->seekg(-static_cast<typename istream_type::off_type>(_bzstream.avail_in), std::ios::cur); | |
122 | + _stream->seekg(-static_cast<std::istream::off_type>(_bzstream.avail_in), std::ios::cur); | |
127 | 123 | } |
128 | 124 | } |
129 | 125 |
@@ -160,16 +156,12 @@ class basic_bzip2_decoder | ||
160 | 156 | bz_stream _bzstream; // internal bzip2 structure |
161 | 157 | int _lastError = BZ_OK; // last error of bzip2 operation |
162 | 158 | |
163 | - istream_type* _stream = nullptr; | |
159 | + std::istream* _stream = nullptr; | |
164 | 160 | bool _endOfStream = false; |
165 | 161 | |
166 | 162 | size_t _bufferCapacity = 0; |
167 | 163 | size_t _inputBufferSize = 0; // how many bytes are read in the input buffer |
168 | 164 | size_t _outputBufferSize = 0; // how many bytes are written in the output buffer |
169 | - ELEM_TYPE* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
170 | - ELEM_TYPE* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
165 | + char_type* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
166 | + char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
171 | 167 | }; |
172 | - | |
173 | -typedef basic_bzip2_decoder<uint8_t, std::char_traits<uint8_t>> byte_bzip2_decoder; | |
174 | -typedef basic_bzip2_decoder<char, std::char_traits<char>> bzip2_decoder; | |
175 | -typedef basic_bzip2_decoder<wchar_t, std::char_traits<wchar_t>> wbzip2_decoder; |
@@ -7,20 +7,16 @@ | ||
7 | 7 | |
8 | 8 | #include <cstdint> |
9 | 9 | |
10 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
11 | -class basic_bzip2_encoder | |
12 | - : public compression_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
10 | +class bzip2_encoder | |
11 | + : public compression_encoder_interface | |
13 | 12 | { |
14 | 13 | public: |
15 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
16 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
17 | - | |
18 | - basic_bzip2_encoder() | |
14 | + bzip2_encoder() | |
19 | 15 | { |
20 | 16 | |
21 | 17 | } |
22 | 18 | |
23 | - ~basic_bzip2_encoder() | |
19 | + ~bzip2_encoder() | |
24 | 20 | { |
25 | 21 | if (is_init()) |
26 | 22 | { |
@@ -29,13 +25,13 @@ class basic_bzip2_encoder | ||
29 | 25 | } |
30 | 26 | } |
31 | 27 | |
32 | - void init(ostream_type& stream) override | |
28 | + void init(std::ostream& stream) override | |
33 | 29 | { |
34 | 30 | bzip2_properties props; |
35 | 31 | init(stream, props); |
36 | 32 | } |
37 | 33 | |
38 | - void init(ostream_type& stream, compression_properties_interface& props) override | |
34 | + void init(std::ostream& stream, compression_properties_interface& props) override | |
39 | 35 | { |
40 | 36 | // init stream |
41 | 37 | _stream = &stream; |
@@ -45,8 +41,8 @@ class basic_bzip2_encoder | ||
45 | 41 | _bufferCapacity = bz2Props.BufferCapacity; |
46 | 42 | |
47 | 43 | uninit_buffers(); |
48 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
49 | - _outputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
44 | + _inputBuffer = new char_type[_bufferCapacity]; | |
45 | + _outputBuffer = new char_type[_bufferCapacity]; | |
50 | 46 | |
51 | 47 | // init bzip2 |
52 | 48 | _bzstream.bzalloc = nullptr; |
@@ -66,12 +62,12 @@ class basic_bzip2_encoder | ||
66 | 62 | return _stream != nullptr; |
67 | 63 | } |
68 | 64 | |
69 | - ELEM_TYPE* get_buffer_begin() override | |
65 | + char_type* get_buffer_begin() override | |
70 | 66 | { |
71 | 67 | return _inputBuffer; |
72 | 68 | } |
73 | 69 | |
74 | - ELEM_TYPE* get_buffer_end() override | |
70 | + char_type* get_buffer_end() override | |
75 | 71 | { |
76 | 72 | return _inputBuffer + _bufferCapacity; |
77 | 73 | } |
@@ -122,13 +118,9 @@ class basic_bzip2_encoder | ||
122 | 118 | bz_stream _bzstream; // internal bzip2 structure |
123 | 119 | int _lastError = BZ_OK; // last error of bzip2 operation |
124 | 120 | |
125 | - ostream_type* _stream = nullptr; | |
121 | + std::ostream* _stream = nullptr; | |
126 | 122 | |
127 | 123 | size_t _bufferCapacity = 0; |
128 | - ELEM_TYPE* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
129 | - ELEM_TYPE* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
124 | + char_type* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
125 | + char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
130 | 126 | }; |
131 | - | |
132 | -typedef basic_bzip2_encoder<uint8_t, std::char_traits<uint8_t>> byte_bzip2_encoder; | |
133 | -typedef basic_bzip2_encoder<char, std::char_traits<char>> bzip2_encoder; | |
134 | -typedef basic_bzip2_encoder<wchar_t, std::char_traits<wchar_t>> wbzip2_encoder; |
@@ -16,56 +16,34 @@ struct compression_properties_interface | ||
16 | 16 | size_t BufferCapacity = 1 << 15; |
17 | 17 | }; |
18 | 18 | |
19 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
20 | -class compression_interface_basic | |
19 | +class compression_interface | |
21 | 20 | { |
22 | 21 | public: |
23 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
24 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
22 | + typedef char char_type; | |
25 | 23 | |
26 | - virtual ~compression_interface_basic() { } | |
24 | + virtual ~compression_interface() { } | |
27 | 25 | |
28 | 26 | virtual bool is_init() const = 0; |
29 | 27 | |
30 | - virtual ELEM_TYPE* get_buffer_begin() = 0; | |
31 | - virtual ELEM_TYPE* get_buffer_end() = 0; | |
28 | + virtual char_type* get_buffer_begin() = 0; | |
29 | + virtual char_type* get_buffer_end() = 0; | |
32 | 30 | }; |
33 | 31 | |
34 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
35 | -class compression_encoder_interface_basic | |
36 | - : public compression_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
32 | +class compression_encoder_interface | |
33 | + : public compression_interface | |
37 | 34 | { |
38 | 35 | public: |
39 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
40 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
41 | - | |
42 | - virtual void init(ostream_type& stream) = 0; | |
43 | - virtual void init(ostream_type& stream, compression_properties_interface& props) = 0; | |
36 | + virtual void init(std::ostream& stream) = 0; | |
37 | + virtual void init(std::ostream& stream, compression_properties_interface& props) = 0; | |
44 | 38 | virtual void encode_next(size_t length) = 0; |
45 | 39 | virtual void sync() = 0; |
46 | 40 | }; |
47 | 41 | |
48 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
49 | -class compression_decoder_interface_basic | |
50 | - : public compression_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
42 | +class compression_decoder_interface | |
43 | + : public compression_interface | |
51 | 44 | { |
52 | 45 | public: |
53 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
54 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
55 | - | |
56 | - virtual void init(istream_type& stream) = 0; | |
57 | - virtual void init(istream_type& stream, compression_properties_interface& props) = 0; | |
46 | + virtual void init(std::istream& stream) = 0; | |
47 | + virtual void init(std::istream& stream, compression_properties_interface& props) = 0; | |
58 | 48 | virtual size_t decode_next() = 0; |
59 | 49 | }; |
60 | - | |
61 | -typedef compression_interface_basic<uint8_t, std::char_traits<uint8_t>> byte_compression_interface; | |
62 | -typedef compression_interface_basic<char, std::char_traits<char>> compression_interface; | |
63 | -typedef compression_interface_basic<wchar_t, std::char_traits<wchar_t>> wcompression_interface; | |
64 | - | |
65 | -typedef compression_encoder_interface_basic<uint8_t, std::char_traits<uint8_t>> byte_compression_encoder_interface; | |
66 | -typedef compression_encoder_interface_basic<char, std::char_traits<char>> compression_encoder_interface; | |
67 | -typedef compression_encoder_interface_basic<wchar_t, std::char_traits<wchar_t>> wcompression_encoder_interface; | |
68 | - | |
69 | -typedef compression_decoder_interface_basic<uint8_t, std::char_traits<uint8_t>> byte_compression_decoder_interface; | |
70 | -typedef compression_decoder_interface_basic<char, std::char_traits<char>> compression_decoder_interface; | |
71 | -typedef compression_decoder_interface_basic<wchar_t, std::char_traits<wchar_t>> wcompression_decoder_interface; |
@@ -7,20 +7,16 @@ | ||
7 | 7 | |
8 | 8 | #include <cstdint> |
9 | 9 | |
10 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
11 | -class basic_deflate_decoder | |
12 | - : public compression_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
10 | +class deflate_decoder | |
11 | + : public compression_decoder_interface | |
13 | 12 | { |
14 | 13 | public: |
15 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
16 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
17 | - | |
18 | - basic_deflate_decoder() | |
14 | + deflate_decoder() | |
19 | 15 | { |
20 | 16 | |
21 | 17 | } |
22 | 18 | |
23 | - ~basic_deflate_decoder() | |
19 | + ~deflate_decoder() | |
24 | 20 | { |
25 | 21 | if (is_init()) |
26 | 22 | { |
@@ -29,13 +25,13 @@ class basic_deflate_decoder | ||
29 | 25 | } |
30 | 26 | } |
31 | 27 | |
32 | - void init(istream_type& stream) override | |
28 | + void init(std::istream& stream) override | |
33 | 29 | { |
34 | 30 | deflate_properties props; |
35 | 31 | init(stream, props); |
36 | 32 | } |
37 | 33 | |
38 | - void init(istream_type& stream, compression_properties_interface& props) override | |
34 | + void init(std::istream& stream, compression_properties_interface& props) override | |
39 | 35 | { |
40 | 36 | // init stream |
41 | 37 | _stream = &stream; |
@@ -49,8 +45,8 @@ class basic_deflate_decoder | ||
49 | 45 | _bufferCapacity = deflateProps.BufferCapacity; |
50 | 46 | |
51 | 47 | uninit_buffers(); |
52 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
53 | - _outputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
48 | + _inputBuffer = new char_type[_bufferCapacity]; | |
49 | + _outputBuffer = new char_type[_bufferCapacity]; | |
54 | 50 | |
55 | 51 | // init deflate |
56 | 52 | _zstream.zalloc = nullptr; |
@@ -70,12 +66,12 @@ class basic_deflate_decoder | ||
70 | 66 | return (_inputBuffer != nullptr && _outputBuffer != nullptr); |
71 | 67 | } |
72 | 68 | |
73 | - ELEM_TYPE* get_buffer_begin() override | |
69 | + char_type* get_buffer_begin() override | |
74 | 70 | { |
75 | 71 | return _outputBuffer; |
76 | 72 | } |
77 | 73 | |
78 | - ELEM_TYPE* get_buffer_end() override | |
74 | + char_type* get_buffer_end() override | |
79 | 75 | { |
80 | 76 | return _outputBuffer + _outputBufferSize; |
81 | 77 | } |
@@ -122,7 +118,7 @@ class basic_deflate_decoder | ||
122 | 118 | if (_zstream.avail_in > 0) |
123 | 119 | { |
124 | 120 | _stream->clear(); |
125 | - _stream->seekg(-static_cast<typename istream_type::off_type>(_zstream.avail_in), std::ios::cur); | |
121 | + _stream->seekg(-static_cast<std::istream::off_type>(_zstream.avail_in), std::ios::cur); | |
126 | 122 | } |
127 | 123 | } |
128 | 124 |
@@ -159,16 +155,12 @@ class basic_deflate_decoder | ||
159 | 155 | z_stream _zstream; // internal zlib structure |
160 | 156 | int _lastError = Z_OK; // last error of zlib operation |
161 | 157 | |
162 | - istream_type* _stream = nullptr; | |
158 | + std::istream* _stream = nullptr; | |
163 | 159 | bool _endOfStream = false; |
164 | 160 | |
165 | 161 | size_t _bufferCapacity = 0; |
166 | 162 | size_t _inputBufferSize = 0; // how many bytes are read in the input buffer |
167 | 163 | size_t _outputBufferSize = 0; // how many bytes are written in the output buffer |
168 | - ELEM_TYPE* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
169 | - ELEM_TYPE* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
164 | + char_type* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
165 | + char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
170 | 166 | }; |
171 | - | |
172 | -typedef basic_deflate_decoder<uint8_t, std::char_traits<uint8_t>> byte_deflate_decoder; | |
173 | -typedef basic_deflate_decoder<char, std::char_traits<char>> deflate_decoder; | |
174 | -typedef basic_deflate_decoder<wchar_t, std::char_traits<wchar_t>> wdeflate_decoder; |
@@ -7,20 +7,16 @@ | ||
7 | 7 | |
8 | 8 | #include <cstdint> |
9 | 9 | |
10 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
11 | -class basic_deflate_encoder | |
12 | - : public compression_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
10 | +class deflate_encoder | |
11 | + : public compression_encoder_interface | |
13 | 12 | { |
14 | 13 | public: |
15 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
16 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
17 | - | |
18 | - basic_deflate_encoder() | |
14 | + deflate_encoder() | |
19 | 15 | { |
20 | 16 | |
21 | 17 | } |
22 | 18 | |
23 | - ~basic_deflate_encoder() | |
19 | + ~deflate_encoder() | |
24 | 20 | { |
25 | 21 | if (is_init()) |
26 | 22 | { |
@@ -29,13 +25,13 @@ class basic_deflate_encoder | ||
29 | 25 | } |
30 | 26 | } |
31 | 27 | |
32 | - void init(ostream_type& stream) override | |
28 | + void init(std::ostream& stream) override | |
33 | 29 | { |
34 | 30 | deflate_properties props; |
35 | 31 | init(stream, props); |
36 | 32 | } |
37 | 33 | |
38 | - void init(ostream_type& stream, compression_properties_interface& props) override | |
34 | + void init(std::ostream& stream, compression_properties_interface& props) override | |
39 | 35 | { |
40 | 36 | // init stream |
41 | 37 | _stream = &stream; |
@@ -45,8 +41,8 @@ class basic_deflate_encoder | ||
45 | 41 | _bufferCapacity = deflateProps.BufferCapacity; |
46 | 42 | |
47 | 43 | uninit_buffers(); |
48 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
49 | - _outputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
44 | + _inputBuffer = new char_type[_bufferCapacity]; | |
45 | + _outputBuffer = new char_type[_bufferCapacity]; | |
50 | 46 | |
51 | 47 | // init deflate |
52 | 48 | _zstream.zalloc = nullptr; |
@@ -66,12 +62,12 @@ class basic_deflate_encoder | ||
66 | 62 | return _stream != nullptr; |
67 | 63 | } |
68 | 64 | |
69 | - ELEM_TYPE* get_buffer_begin() override | |
65 | + char_type* get_buffer_begin() override | |
70 | 66 | { |
71 | 67 | return _inputBuffer; |
72 | 68 | } |
73 | 69 | |
74 | - ELEM_TYPE* get_buffer_end() override | |
70 | + char_type* get_buffer_end() override | |
75 | 71 | { |
76 | 72 | return _inputBuffer + _bufferCapacity; |
77 | 73 | } |
@@ -122,13 +118,9 @@ class basic_deflate_encoder | ||
122 | 118 | z_stream _zstream; // internal zlib structure |
123 | 119 | int _lastError = Z_OK; // last error of zlib operation |
124 | 120 | |
125 | - ostream_type* _stream = nullptr; | |
121 | + std::ostream* _stream = nullptr; | |
126 | 122 | |
127 | 123 | size_t _bufferCapacity = 0; |
128 | - ELEM_TYPE* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
129 | - ELEM_TYPE* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
124 | + char_type* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
125 | + char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
130 | 126 | }; |
131 | - | |
132 | -typedef basic_deflate_encoder<uint8_t, std::char_traits<uint8_t>> byte_deflate_encoder; | |
133 | -typedef basic_deflate_encoder<char, std::char_traits<char>> deflate_encoder; | |
134 | -typedef basic_deflate_encoder<wchar_t, std::char_traits<wchar_t>> wdeflate_encoder; |
@@ -29,8 +29,7 @@ namespace detail | ||
29 | 29 | LzmaEnc_WriteProperties(handle.get_native_handle(), &_header[4], &headerSize); |
30 | 30 | } |
31 | 31 | |
32 | - template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
33 | - void write_to_stream(detail::lzma_out_stream<ELEM_TYPE, TRAITS_TYPE>& stream) | |
32 | + void write_to_stream(detail::lzma_out_stream& stream) | |
34 | 33 | { |
35 | 34 | stream.write(&_header, HEADER_SIZE); |
36 | 35 | } |
@@ -5,21 +5,19 @@ | ||
5 | 5 | #include <mutex> |
6 | 6 | |
7 | 7 | // forward declaration |
8 | -template <typename ELEM_TYPE_, typename TRAITS_TYPE_> | |
9 | -class basic_lzma_encoder; | |
8 | +class lzma_encoder; | |
10 | 9 | |
11 | 10 | namespace detail |
12 | 11 | { |
13 | - template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
14 | 12 | class lzma_in_stream |
15 | 13 | : public ISeqInStream |
16 | 14 | { |
17 | 15 | public: |
18 | - template <typename ELEM_TYPE_, typename TRAITS_TYPE_> | |
19 | - friend class ::basic_lzma_encoder; | |
16 | + friend class ::lzma_encoder; | |
20 | 17 | |
21 | - typedef std::condition_variable event_t; | |
22 | - typedef std::mutex mutex_t; | |
18 | + typedef char char_type; | |
19 | + typedef std::condition_variable event_type; | |
20 | + typedef std::mutex mutex_type; | |
23 | 21 | |
24 | 22 | lzma_in_stream() |
25 | 23 | { |
@@ -35,8 +33,8 @@ namespace detail | ||
35 | 33 | size_t lastBytesRead = _bytesRead; |
36 | 34 | |
37 | 35 | // set buffer pointer and get required size |
38 | - _internalInputBuffer = static_cast<ELEM_TYPE*>(buf); | |
39 | - _internalBufferSize = *size / sizeof(ELEM_TYPE); | |
36 | + _internalInputBuffer = static_cast<char_type*>(buf); | |
37 | + _internalBufferSize = *size / sizeof(char_type); | |
40 | 38 | |
41 | 39 | // give control back to the main thread |
42 | 40 | set_event(); |
@@ -61,13 +59,13 @@ namespace detail | ||
61 | 59 | private: |
62 | 60 | size_t _bytesRead = 0; |
63 | 61 | size_t _internalBufferSize = 0; |
64 | - ELEM_TYPE* _internalInputBuffer = nullptr; | |
65 | - event_t _event; | |
66 | - mutex_t _mutex; | |
62 | + char_type* _internalInputBuffer = nullptr; | |
63 | + event_type _event; | |
64 | + mutex_type _mutex; | |
67 | 65 | bool _endOfStream = false; |
68 | 66 | |
69 | - ELEM_TYPE* get_buffer_begin() { return _internalInputBuffer; } | |
70 | - ELEM_TYPE* get_buffer_end() { return _internalInputBuffer + _internalBufferSize; } | |
67 | + char_type* get_buffer_begin() { return _internalInputBuffer; } | |
68 | + char_type* get_buffer_end() { return _internalInputBuffer + _internalBufferSize; } | |
71 | 69 | |
72 | 70 | void set_event() |
73 | 71 | { |
@@ -76,7 +74,7 @@ namespace detail | ||
76 | 74 | |
77 | 75 | void wait_for_event() |
78 | 76 | { |
79 | - std::unique_lock<std::mutex> lk(_mutex); | |
77 | + std::unique_lock<mutex_type> lk(_mutex); | |
80 | 78 | _event.wait(lk); |
81 | 79 | } |
82 | 80 |
@@ -3,12 +3,11 @@ | ||
3 | 3 | |
4 | 4 | namespace detail |
5 | 5 | { |
6 | - template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
7 | 6 | class lzma_out_stream |
8 | 7 | : public ISeqOutStream |
9 | 8 | { |
10 | 9 | public: |
11 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
10 | + typedef char char_type; | |
12 | 11 | |
13 | 12 | lzma_out_stream() |
14 | 13 | { |
@@ -22,18 +21,18 @@ namespace detail | ||
22 | 21 | size_t write(const void* buf, size_t size) |
23 | 22 | { |
24 | 23 | auto currentPosition = _stream->tellp(); |
25 | - _stream->write(reinterpret_cast<const ELEM_TYPE*>(buf), size); | |
24 | + _stream->write(reinterpret_cast<const char_type*>(buf), size); | |
26 | 25 | |
27 | 26 | size_t delta = static_cast<size_t>(_stream->tellp()) - static_cast<size_t>(currentPosition); |
28 | 27 | |
29 | 28 | return delta; |
30 | 29 | } |
31 | 30 | |
32 | - const ostream_type& get_stream() const { return *_stream; } | |
33 | - ostream_type& get_stream() { return *_stream; } | |
34 | - void set_stream(ostream_type& stream) { _stream = &stream; } | |
31 | + const std::ostream& get_stream() const { return *_stream; } | |
32 | + std::ostream& get_stream() { return *_stream; } | |
33 | + void set_stream(std::ostream& stream) { _stream = &stream; } | |
35 | 34 | |
36 | 35 | private: |
37 | - ostream_type* _stream = nullptr; | |
36 | + std::ostream* _stream = nullptr; | |
38 | 37 | }; |
39 | 38 | } |
@@ -8,20 +8,16 @@ | ||
8 | 8 | |
9 | 9 | #include <cstdint> |
10 | 10 | |
11 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
12 | -class basic_lzma_decoder | |
13 | - : public compression_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
11 | +class lzma_decoder | |
12 | + : public compression_decoder_interface | |
14 | 13 | { |
15 | 14 | public: |
16 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
17 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
18 | - | |
19 | - basic_lzma_decoder() | |
15 | + lzma_decoder() | |
20 | 16 | { |
21 | 17 | LzmaDec_Construct(&_handle); |
22 | 18 | } |
23 | 19 | |
24 | - ~basic_lzma_decoder() | |
20 | + ~lzma_decoder() | |
25 | 21 | { |
26 | 22 | if (is_init()) |
27 | 23 | { |
@@ -30,13 +26,13 @@ class basic_lzma_decoder | ||
30 | 26 | } |
31 | 27 | } |
32 | 28 | |
33 | - void init(istream_type& stream) override | |
29 | + void init(std::istream& stream) override | |
34 | 30 | { |
35 | 31 | lzma_properties props; |
36 | 32 | init(stream, props); |
37 | 33 | } |
38 | 34 | |
39 | - void init(istream_type& stream, compression_properties_interface& props) override | |
35 | + void init(std::istream& stream, compression_properties_interface& props) override | |
40 | 36 | { |
41 | 37 | // init stream |
42 | 38 | _stream = &stream; |
@@ -50,12 +46,12 @@ class basic_lzma_decoder | ||
50 | 46 | _bufferCapacity = lzmaProps.BufferCapacity; |
51 | 47 | |
52 | 48 | uninit_buffers(); |
53 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
54 | - _outputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
49 | + _inputBuffer = new char_type[_bufferCapacity]; | |
50 | + _outputBuffer = new char_type[_bufferCapacity]; | |
55 | 51 | |
56 | 52 | // read lzma header |
57 | 53 | Byte header[LZMA_PROPS_SIZE + 4]; |
58 | - _stream->read(reinterpret_cast<ELEM_TYPE*>(header), sizeof(header) / sizeof(ELEM_TYPE)); | |
54 | + _stream->read(reinterpret_cast<char_type*>(header), sizeof(header) / sizeof(char_type)); | |
59 | 55 | |
60 | 56 | // init lzma |
61 | 57 | LzmaDec_Allocate(&_handle, &header[4], LZMA_PROPS_SIZE, &_alloc); |
@@ -67,12 +63,12 @@ class basic_lzma_decoder | ||
67 | 63 | return (_inputBuffer != nullptr && _outputBuffer != nullptr); |
68 | 64 | } |
69 | 65 | |
70 | - ELEM_TYPE* get_buffer_begin() override | |
66 | + char_type* get_buffer_begin() override | |
71 | 67 | { |
72 | 68 | return _outputBuffer; |
73 | 69 | } |
74 | 70 | |
75 | - ELEM_TYPE* get_buffer_end() override | |
71 | + char_type* get_buffer_end() override | |
76 | 72 | { |
77 | 73 | return _outputBuffer + _outputBufferSize; |
78 | 74 | } |
@@ -142,15 +138,11 @@ class basic_lzma_decoder | ||
142 | 138 | SizeT _inProcessed = 0; |
143 | 139 | SizeT _outProcessed = 0; |
144 | 140 | |
145 | - istream_type* _stream = nullptr; | |
141 | + std::istream* _stream = nullptr; | |
146 | 142 | |
147 | 143 | size_t _bufferCapacity = 0; |
148 | 144 | size_t _inputBufferSize = 0; // how many bytes are read in the input buffer |
149 | 145 | size_t _outputBufferSize = 0; // how many bytes are written in the output buffer |
150 | - ELEM_TYPE* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
151 | - ELEM_TYPE* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
146 | + char_type* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
147 | + char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
152 | 148 | }; |
153 | - | |
154 | -typedef basic_lzma_decoder<uint8_t, std::char_traits<uint8_t>> byte_lzma_decoder; | |
155 | -typedef basic_lzma_decoder<char, std::char_traits<char>> lzma_decoder; | |
156 | -typedef basic_lzma_decoder<wchar_t, std::char_traits<wchar_t>> wlzma_decoder; |
@@ -12,20 +12,16 @@ | ||
12 | 12 | #include <thread> |
13 | 13 | #include <cstdint> |
14 | 14 | |
15 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
16 | -class basic_lzma_encoder | |
17 | - : public compression_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
15 | +class lzma_encoder | |
16 | + : public compression_encoder_interface | |
18 | 17 | { |
19 | 18 | public: |
20 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
21 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
22 | - | |
23 | - basic_lzma_encoder() | |
19 | + lzma_encoder() | |
24 | 20 | { |
25 | 21 | |
26 | 22 | } |
27 | 23 | |
28 | - ~basic_lzma_encoder() | |
24 | + ~lzma_encoder() | |
29 | 25 | { |
30 | 26 | if (is_init()) |
31 | 27 | { |
@@ -33,13 +29,13 @@ class basic_lzma_encoder | ||
33 | 29 | } |
34 | 30 | } |
35 | 31 | |
36 | - void init(ostream_type& stream) override | |
32 | + void init(std::ostream& stream) override | |
37 | 33 | { |
38 | 34 | lzma_properties props; |
39 | 35 | init(stream, props); |
40 | 36 | } |
41 | 37 | |
42 | - void init(ostream_type& stream, compression_properties_interface& props) override | |
38 | + void init(std::ostream& stream, compression_properties_interface& props) override | |
43 | 39 | { |
44 | 40 | lzma_properties& lzmaProps = static_cast<lzma_properties&>(props); |
45 | 41 |
@@ -54,12 +50,12 @@ class basic_lzma_encoder | ||
54 | 50 | return &_ostream.get_stream() != nullptr; |
55 | 51 | } |
56 | 52 | |
57 | - ELEM_TYPE* get_buffer_begin() override | |
53 | + char_type* get_buffer_begin() override | |
58 | 54 | { |
59 | 55 | return _istream.get_buffer_begin(); |
60 | 56 | } |
61 | 57 | |
62 | - ELEM_TYPE* get_buffer_end() override | |
58 | + char_type* get_buffer_end() override | |
63 | 59 | { |
64 | 60 | return _istream.get_buffer_end(); |
65 | 61 | } |
@@ -84,7 +80,7 @@ class basic_lzma_encoder | ||
84 | 80 | header.apply(_handle); |
85 | 81 | header.write_to_stream(_ostream); |
86 | 82 | |
87 | - _compressionThread = std::thread(&basic_lzma_encoder::encode_threadroutine, this); | |
83 | + _compressionThread = std::thread(&lzma_encoder::encode_threadroutine, this); | |
88 | 84 | |
89 | 85 | _istream.wait_for_event(); |
90 | 86 | } |
@@ -96,12 +92,8 @@ class basic_lzma_encoder | ||
96 | 92 | |
97 | 93 | detail::lzma_handle _handle; |
98 | 94 | detail::lzma_alloc _alloc; |
99 | - detail::lzma_in_stream<ELEM_TYPE, TRAITS_TYPE> _istream; | |
100 | - detail::lzma_out_stream<ELEM_TYPE, TRAITS_TYPE> _ostream; | |
95 | + detail::lzma_in_stream _istream; | |
96 | + detail::lzma_out_stream _ostream; | |
101 | 97 | |
102 | 98 | std::thread _compressionThread; |
103 | 99 | }; |
104 | - | |
105 | -typedef basic_lzma_encoder<uint8_t, std::char_traits<uint8_t>> byte_lzma_encoder; | |
106 | -typedef basic_lzma_encoder<char, std::char_traits<char>> lzma_encoder; | |
107 | -typedef basic_lzma_encoder<wchar_t, std::char_traits<wchar_t>> wlzma_encoder; |
@@ -8,20 +8,16 @@ | ||
8 | 8 | |
9 | 9 | #include <cstdint> |
10 | 10 | |
11 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
12 | -class basic_store_decoder | |
13 | - : public compression_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
11 | +class store_decoder | |
12 | + : public compression_decoder_interface | |
14 | 13 | { |
15 | 14 | public: |
16 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
17 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
18 | - | |
19 | - basic_store_decoder() | |
15 | + store_decoder() | |
20 | 16 | { |
21 | 17 | |
22 | 18 | } |
23 | 19 | |
24 | - ~basic_store_decoder() | |
20 | + ~store_decoder() | |
25 | 21 | { |
26 | 22 | if (is_init()) |
27 | 23 | { |
@@ -29,13 +25,13 @@ class basic_store_decoder | ||
29 | 25 | } |
30 | 26 | } |
31 | 27 | |
32 | - void init(istream_type& stream) override | |
28 | + void init(std::istream& stream) override | |
33 | 29 | { |
34 | 30 | store_properties props; |
35 | 31 | init(stream, props); |
36 | 32 | } |
37 | 33 | |
38 | - void init(istream_type& stream, compression_properties_interface& props) override | |
34 | + void init(std::istream& stream, compression_properties_interface& props) override | |
39 | 35 | { |
40 | 36 | // init stream |
41 | 37 | _stream = &stream; |
@@ -48,7 +44,7 @@ class basic_store_decoder | ||
48 | 44 | _bufferCapacity = storeProps.BufferCapacity; |
49 | 45 | |
50 | 46 | uninit_buffers(); |
51 | - _outputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
47 | + _outputBuffer = new char_type[_bufferCapacity]; | |
52 | 48 | } |
53 | 49 | |
54 | 50 | bool is_init() const override |
@@ -56,12 +52,12 @@ class basic_store_decoder | ||
56 | 52 | return (_outputBuffer != nullptr); |
57 | 53 | } |
58 | 54 | |
59 | - ELEM_TYPE* get_buffer_begin() override | |
55 | + char_type* get_buffer_begin() override | |
60 | 56 | { |
61 | 57 | return _outputBuffer; |
62 | 58 | } |
63 | 59 | |
64 | - ELEM_TYPE* get_buffer_end() override | |
60 | + char_type* get_buffer_end() override | |
65 | 61 | { |
66 | 62 | return _outputBuffer + _outputBufferSize; |
67 | 63 | } |
@@ -84,13 +80,9 @@ class basic_store_decoder | ||
84 | 80 | delete[] _outputBuffer; |
85 | 81 | } |
86 | 82 | |
87 | - istream_type* _stream = nullptr; | |
83 | + std::istream* _stream = nullptr; | |
88 | 84 | |
89 | 85 | size_t _bufferCapacity = 0; |
90 | 86 | size_t _outputBufferSize = 0; // how many bytes are written in the output buffer |
91 | - ELEM_TYPE* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
87 | + char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
92 | 88 | }; |
93 | - | |
94 | -typedef basic_store_decoder<uint8_t, std::char_traits<uint8_t>> byte_store_decoder; | |
95 | -typedef basic_store_decoder<char, std::char_traits<char>> store_decoder; | |
96 | -typedef basic_store_decoder<wchar_t, std::char_traits<wchar_t>> wstore_decoder; |
@@ -8,20 +8,16 @@ | ||
8 | 8 | |
9 | 9 | #include <cstdint> |
10 | 10 | |
11 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
12 | -class basic_store_encoder | |
13 | - : public compression_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
11 | +class store_encoder | |
12 | + : public compression_encoder_interface | |
14 | 13 | { |
15 | 14 | public: |
16 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
17 | - typedef typename compression_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
18 | - | |
19 | - basic_store_encoder() | |
15 | + store_encoder() | |
20 | 16 | { |
21 | 17 | |
22 | 18 | } |
23 | 19 | |
24 | - ~basic_store_encoder() | |
20 | + ~store_encoder() | |
25 | 21 | { |
26 | 22 | if (is_init()) |
27 | 23 | { |
@@ -29,13 +25,13 @@ class basic_store_encoder | ||
29 | 25 | } |
30 | 26 | } |
31 | 27 | |
32 | - void init(ostream_type& stream) override | |
28 | + void init(std::ostream& stream) override | |
33 | 29 | { |
34 | 30 | store_properties props; |
35 | 31 | init(stream, props); |
36 | 32 | } |
37 | 33 | |
38 | - void init(ostream_type& stream, compression_properties_interface& props) override | |
34 | + void init(std::ostream& stream, compression_properties_interface& props) override | |
39 | 35 | { |
40 | 36 | // init stream |
41 | 37 | _stream = &stream; |
@@ -45,8 +41,8 @@ class basic_store_encoder | ||
45 | 41 | _bufferCapacity = storeProps.BufferCapacity; |
46 | 42 | |
47 | 43 | uninit_buffers(); |
48 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
49 | - _outputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
44 | + _inputBuffer = new char_type[_bufferCapacity]; | |
45 | + _outputBuffer = new char_type[_bufferCapacity]; | |
50 | 46 | } |
51 | 47 | |
52 | 48 | bool is_init() const override |
@@ -54,12 +50,12 @@ class basic_store_encoder | ||
54 | 50 | return _stream != nullptr; |
55 | 51 | } |
56 | 52 | |
57 | - ELEM_TYPE* get_buffer_begin() override | |
53 | + char_type* get_buffer_begin() override | |
58 | 54 | { |
59 | 55 | return _inputBuffer; |
60 | 56 | } |
61 | 57 | |
62 | - ELEM_TYPE* get_buffer_end() override | |
58 | + char_type* get_buffer_end() override | |
63 | 59 | { |
64 | 60 | return _inputBuffer + _bufferCapacity; |
65 | 61 | } |
@@ -81,13 +77,9 @@ class basic_store_encoder | ||
81 | 77 | delete[] _outputBuffer; |
82 | 78 | } |
83 | 79 | |
84 | - ostream_type* _stream = nullptr; | |
80 | + std::ostream* _stream = nullptr; | |
85 | 81 | |
86 | 82 | size_t _bufferCapacity = 0; |
87 | - ELEM_TYPE* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
88 | - ELEM_TYPE* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
83 | + char_type* _inputBuffer = nullptr; // pointer to the start of the input buffer | |
84 | + char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer | |
89 | 85 | }; |
90 | - | |
91 | -typedef basic_store_encoder<uint8_t, std::char_traits<uint8_t>> byte_store_encoder; | |
92 | -typedef basic_store_encoder<char, std::char_traits<char>> store_encoder; | |
93 | -typedef basic_store_encoder<wchar_t, std::char_traits<wchar_t>> wstore_encoder; |
@@ -6,20 +6,16 @@ | ||
6 | 6 | |
7 | 7 | #include <cstdint> |
8 | 8 | |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | -class basic_aes_decoder | |
11 | - : public encryption_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
9 | +class aes_decoder | |
10 | + : public encryption_decoder_interface | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
15 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
16 | - | |
17 | - basic_aes_decoder() | |
13 | + aes_decoder() | |
18 | 14 | { |
19 | 15 | |
20 | 16 | } |
21 | 17 | |
22 | - ~basic_aes_decoder() | |
18 | + ~aes_decoder() | |
23 | 19 | { |
24 | 20 | if (is_init()) |
25 | 21 | { |
@@ -27,20 +23,20 @@ class basic_aes_decoder | ||
27 | 23 | } |
28 | 24 | } |
29 | 25 | |
30 | - void init(istream_type& stream) override | |
26 | + void init(std::istream& stream) override | |
31 | 27 | { |
32 | 28 | aes_properties props; |
33 | 29 | init(stream, props); |
34 | 30 | } |
35 | 31 | |
36 | - void init(istream_type& stream, encryption_properties_interface& props) override | |
32 | + void init(std::istream& stream, encryption_properties_interface& props) override | |
37 | 33 | { |
38 | 34 | // init buffers |
39 | 35 | aes_properties& aesProps = static_cast<aes_properties&>(props); |
40 | 36 | _bufferCapacity = aesProps.BufferCapacity; |
41 | 37 | |
42 | 38 | uninit_buffers(); |
43 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
39 | + _inputBuffer = new char_type[_bufferCapacity]; | |
44 | 40 | |
45 | 41 | // init stream |
46 | 42 | _stream = &stream; |
@@ -65,12 +61,12 @@ class basic_aes_decoder | ||
65 | 61 | return _stream != nullptr && _encryptedStream != nullptr && _authCodeStream != nullptr; |
66 | 62 | } |
67 | 63 | |
68 | - ELEM_TYPE* get_buffer_begin() override | |
64 | + char_type* get_buffer_begin() override | |
69 | 65 | { |
70 | 66 | return _inputBuffer; |
71 | 67 | } |
72 | 68 | |
73 | - ELEM_TYPE* get_buffer_end() override | |
69 | + char_type* get_buffer_end() override | |
74 | 70 | { |
75 | 71 | return _inputBuffer + _bufferCapacity; |
76 | 72 | } |
@@ -137,10 +133,10 @@ class basic_aes_decoder | ||
137 | 133 | delete[] _inputBuffer; |
138 | 134 | } |
139 | 135 | |
140 | - ELEM_TYPE* _inputBuffer = nullptr; | |
136 | + char_type* _inputBuffer = nullptr; | |
141 | 137 | size_t _bufferCapacity = 0; |
142 | 138 | |
143 | - istream_type* _stream = nullptr; | |
139 | + std::istream* _stream = nullptr; | |
144 | 140 | std::unique_ptr<isubstream> _encryptedStream; |
145 | 141 | std::unique_ptr<isubstream> _authCodeStream; |
146 | 142 |
@@ -164,7 +160,3 @@ class basic_aes_decoder | ||
164 | 160 | bool _encryptionHeaderRead = false; |
165 | 161 | bool _encryptionFooterRead = false; |
166 | 162 | }; |
167 | - | |
168 | -typedef basic_aes_decoder<uint8_t, std::char_traits<uint8_t>> byte_aes_decoder; | |
169 | -typedef basic_aes_decoder<char, std::char_traits<char>> aes_decoder; | |
170 | -typedef basic_aes_decoder<wchar_t, std::char_traits<wchar_t>> waes_decoder; |
@@ -6,20 +6,16 @@ | ||
6 | 6 | |
7 | 7 | #include <cstdint> |
8 | 8 | |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | -class basic_aes_encoder | |
11 | - : public encryption_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
9 | +class aes_encoder | |
10 | + : public encryption_encoder_interface | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
15 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
16 | - | |
17 | - basic_aes_encoder() | |
13 | + aes_encoder() | |
18 | 14 | { |
19 | 15 | |
20 | 16 | } |
21 | 17 | |
22 | - ~basic_aes_encoder() | |
18 | + ~aes_encoder() | |
23 | 19 | { |
24 | 20 | if (is_init()) |
25 | 21 | { |
@@ -27,20 +23,20 @@ class basic_aes_encoder | ||
27 | 23 | } |
28 | 24 | } |
29 | 25 | |
30 | - void init(ostream_type& stream) override | |
26 | + void init(std::ostream& stream) override | |
31 | 27 | { |
32 | 28 | aes_properties props; |
33 | 29 | init(stream, props); |
34 | 30 | } |
35 | 31 | |
36 | - void init(ostream_type& stream, encryption_properties_interface& props) override | |
32 | + void init(std::ostream& stream, encryption_properties_interface& props) override | |
37 | 33 | { |
38 | 34 | // init buffers |
39 | 35 | aes_properties& aesProps = static_cast<aes_properties&>(props); |
40 | 36 | _bufferCapacity = aesProps.BufferCapacity; |
41 | 37 | |
42 | 38 | uninit_buffers(); |
43 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
39 | + _inputBuffer = new char_type[_bufferCapacity]; | |
44 | 40 | |
45 | 41 | // init stream |
46 | 42 | _stream = &stream; |
@@ -58,12 +54,12 @@ class basic_aes_encoder | ||
58 | 54 | return _stream != nullptr; |
59 | 55 | } |
60 | 56 | |
61 | - ELEM_TYPE* get_buffer_begin() override | |
57 | + char_type* get_buffer_begin() override | |
62 | 58 | { |
63 | 59 | return _inputBuffer; |
64 | 60 | } |
65 | 61 | |
66 | - ELEM_TYPE* get_buffer_end() override | |
62 | + char_type* get_buffer_end() override | |
67 | 63 | { |
68 | 64 | return _inputBuffer + _bufferCapacity; |
69 | 65 | } |
@@ -99,10 +95,10 @@ class basic_aes_encoder | ||
99 | 95 | delete[] _inputBuffer; |
100 | 96 | } |
101 | 97 | |
102 | - ELEM_TYPE* _inputBuffer = nullptr; | |
98 | + char_type* _inputBuffer = nullptr; | |
103 | 99 | size_t _bufferCapacity = 0; |
104 | 100 | |
105 | - ostream_type* _stream = nullptr; | |
101 | + std::ostream* _stream = nullptr; | |
106 | 102 | |
107 | 103 | struct aes_context |
108 | 104 | { |
@@ -115,7 +111,3 @@ class basic_aes_encoder | ||
115 | 111 | |
116 | 112 | bool _encryptionHeaderWritten = false; |
117 | 113 | }; |
118 | - | |
119 | -typedef basic_aes_encoder<uint8_t, std::char_traits<uint8_t>> byte_aes_encoder; | |
120 | -typedef basic_aes_encoder<char, std::char_traits<char>> aes_encoder; | |
121 | -typedef basic_aes_encoder<wchar_t, std::char_traits<wchar_t>> waes_encoder; |
@@ -18,57 +18,35 @@ struct encryption_properties_interface | ||
18 | 18 | std::string Password; |
19 | 19 | }; |
20 | 20 | |
21 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
22 | -class encryption_interface_basic | |
21 | +class encryption_interface | |
23 | 22 | { |
24 | 23 | public: |
25 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
26 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
24 | + typedef char char_type; | |
27 | 25 | |
28 | - virtual ~encryption_interface_basic() { } | |
26 | + virtual ~encryption_interface() { } | |
29 | 27 | |
30 | 28 | virtual bool is_init() const = 0; |
31 | 29 | |
32 | - virtual ELEM_TYPE* get_buffer_begin() = 0; | |
33 | - virtual ELEM_TYPE* get_buffer_end() = 0; | |
30 | + virtual char_type* get_buffer_begin() = 0; | |
31 | + virtual char_type* get_buffer_end() = 0; | |
34 | 32 | }; |
35 | 33 | |
36 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
37 | -class encryption_encoder_interface_basic | |
38 | - : public encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
34 | +class encryption_encoder_interface | |
35 | + : public encryption_interface | |
39 | 36 | { |
40 | 37 | public: |
41 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
42 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
43 | - | |
44 | - virtual void init(ostream_type& stream) = 0; | |
45 | - virtual void init(ostream_type& stream, encryption_properties_interface& props) = 0; | |
38 | + virtual void init(std::ostream& stream) = 0; | |
39 | + virtual void init(std::ostream& stream, encryption_properties_interface& props) = 0; | |
46 | 40 | virtual void encrypt_next(size_t length) = 0; |
47 | 41 | virtual void sync() = 0; |
48 | 42 | }; |
49 | 43 | |
50 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
51 | -class encryption_decoder_interface_basic | |
52 | - : public encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
44 | +class encryption_decoder_interface | |
45 | + : public encryption_interface | |
53 | 46 | { |
54 | 47 | public: |
55 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
56 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
57 | - | |
58 | - virtual void init(istream_type& stream) = 0; | |
59 | - virtual void init(istream_type& stream, encryption_properties_interface& props) = 0; | |
48 | + virtual void init(std::istream& stream) = 0; | |
49 | + virtual void init(std::istream& stream, encryption_properties_interface& props) = 0; | |
60 | 50 | virtual size_t decrypt_next() = 0; |
61 | 51 | virtual bool has_correct_password() const = 0; |
62 | 52 | }; |
63 | - | |
64 | -typedef encryption_interface_basic<uint8_t, std::char_traits<uint8_t>> byte_encryption_interface; | |
65 | -typedef encryption_interface_basic<char, std::char_traits<char>> encryption_interface; | |
66 | -typedef encryption_interface_basic<wchar_t, std::char_traits<wchar_t>> wencryption_interface; | |
67 | - | |
68 | -typedef encryption_encoder_interface_basic<uint8_t, std::char_traits<uint8_t>> byte_encryption_encoder_interface; | |
69 | -typedef encryption_encoder_interface_basic<char, std::char_traits<char>> encryption_encoder_interface; | |
70 | -typedef encryption_encoder_interface_basic<wchar_t, std::char_traits<wchar_t>> wencryption_encoder_interface; | |
71 | - | |
72 | -typedef encryption_decoder_interface_basic<uint8_t, std::char_traits<uint8_t>> byte_encryption_decoder_interface; | |
73 | -typedef encryption_decoder_interface_basic<char, std::char_traits<char>> encryption_decoder_interface; | |
74 | -typedef encryption_decoder_interface_basic<wchar_t, std::char_traits<wchar_t>> wencryption_decoder_interface; |
@@ -6,20 +6,16 @@ | ||
6 | 6 | |
7 | 7 | #include <cstdint> |
8 | 8 | |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | -class basic_zipcrypto_decoder | |
11 | - : public encryption_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
9 | +class zipcrypto_decoder | |
10 | + : public encryption_decoder_interface | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
15 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
16 | - | |
17 | - basic_zipcrypto_decoder() | |
13 | + zipcrypto_decoder() | |
18 | 14 | { |
19 | 15 | |
20 | 16 | } |
21 | 17 | |
22 | - ~basic_zipcrypto_decoder() | |
18 | + ~zipcrypto_decoder() | |
23 | 19 | { |
24 | 20 | if (is_init()) |
25 | 21 | { |
@@ -27,20 +23,20 @@ class basic_zipcrypto_decoder | ||
27 | 23 | } |
28 | 24 | } |
29 | 25 | |
30 | - void init(istream_type& stream) override | |
26 | + void init(std::istream& stream) override | |
31 | 27 | { |
32 | 28 | zipcrypto_properties props; |
33 | 29 | init(stream, props); |
34 | 30 | } |
35 | 31 | |
36 | - void init(istream_type& stream, encryption_properties_interface& props) override | |
32 | + void init(std::istream& stream, encryption_properties_interface& props) override | |
37 | 33 | { |
38 | 34 | // init buffers |
39 | 35 | zipcrypto_properties& zipcryptoProps = static_cast<zipcrypto_properties&>(props); |
40 | 36 | _bufferCapacity = zipcryptoProps.BufferCapacity; |
41 | 37 | |
42 | 38 | uninit_buffers(); |
43 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
39 | + _inputBuffer = new char_type[_bufferCapacity]; | |
44 | 40 | |
45 | 41 | // init stream |
46 | 42 | _stream = &stream; |
@@ -61,12 +57,12 @@ class basic_zipcrypto_decoder | ||
61 | 57 | return _stream != nullptr; |
62 | 58 | } |
63 | 59 | |
64 | - ELEM_TYPE* get_buffer_begin() override | |
60 | + char_type* get_buffer_begin() override | |
65 | 61 | { |
66 | 62 | return _inputBuffer; |
67 | 63 | } |
68 | 64 | |
69 | - ELEM_TYPE* get_buffer_end() override | |
65 | + char_type* get_buffer_end() override | |
70 | 66 | { |
71 | 67 | return _inputBuffer + _bufferCapacity; |
72 | 68 | } |
@@ -95,7 +91,7 @@ class basic_zipcrypto_decoder | ||
95 | 91 | void read_encryption_header() |
96 | 92 | { |
97 | 93 | _stream->read( |
98 | - reinterpret_cast<ELEM_TYPE*>(&_zipcrypto.get_encryption_header()), | |
94 | + reinterpret_cast<char_type*>(&_zipcrypto.get_encryption_header()), | |
99 | 95 | _zipcrypto.get_encryption_header_size()); |
100 | 96 | |
101 | 97 | _zipcrypto.decrypt_header(); |
@@ -107,14 +103,10 @@ class basic_zipcrypto_decoder | ||
107 | 103 | delete[] _inputBuffer; |
108 | 104 | } |
109 | 105 | |
110 | - ELEM_TYPE* _inputBuffer = nullptr; | |
106 | + char_type* _inputBuffer = nullptr; | |
111 | 107 | size_t _bufferCapacity = 0; |
112 | 108 | |
113 | - istream_type* _stream = nullptr; | |
109 | + std::istream* _stream = nullptr; | |
114 | 110 | detail::zipcrypto _zipcrypto; |
115 | 111 | bool _encryptionHeaderRead = false; |
116 | 112 | }; |
117 | - | |
118 | -typedef basic_zipcrypto_decoder<uint8_t, std::char_traits<uint8_t>> byte_zipcrypto_decoder; | |
119 | -typedef basic_zipcrypto_decoder<char, std::char_traits<char>> zipcrypto_decoder; | |
120 | -typedef basic_zipcrypto_decoder<wchar_t, std::char_traits<wchar_t>> wzipcrypto_decoder; |
@@ -5,20 +5,16 @@ | ||
5 | 5 | |
6 | 6 | #include <cstdint> |
7 | 7 | |
8 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
9 | -class basic_zipcrypto_encoder | |
10 | - : public encryption_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class zipcrypto_encoder | |
9 | + : public encryption_encoder_interface | |
11 | 10 | { |
12 | 11 | public: |
13 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
14 | - typedef typename encryption_interface_basic<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
15 | - | |
16 | - basic_zipcrypto_encoder() | |
12 | + zipcrypto_encoder() | |
17 | 13 | { |
18 | 14 | |
19 | 15 | } |
20 | 16 | |
21 | - ~basic_zipcrypto_encoder() | |
17 | + ~zipcrypto_encoder() | |
22 | 18 | { |
23 | 19 | if (is_init()) |
24 | 20 | { |
@@ -26,20 +22,20 @@ class basic_zipcrypto_encoder | ||
26 | 22 | } |
27 | 23 | } |
28 | 24 | |
29 | - void init(ostream_type& stream) override | |
25 | + void init(std::ostream& stream) override | |
30 | 26 | { |
31 | 27 | zipcrypto_properties props; |
32 | 28 | init(stream, props); |
33 | 29 | } |
34 | 30 | |
35 | - void init(ostream_type& stream, encryption_properties_interface& props) override | |
31 | + void init(std::ostream& stream, encryption_properties_interface& props) override | |
36 | 32 | { |
37 | 33 | // init buffers |
38 | 34 | zipcrypto_properties& zipcryptoProps = static_cast<zipcrypto_properties&>(props); |
39 | 35 | _bufferCapacity = zipcryptoProps.BufferCapacity; |
40 | 36 | |
41 | 37 | uninit_buffers(); |
42 | - _inputBuffer = new ELEM_TYPE[_bufferCapacity]; | |
38 | + _inputBuffer = new char_type[_bufferCapacity]; | |
43 | 39 | |
44 | 40 | // init stream |
45 | 41 | _stream = &stream; |
@@ -57,12 +53,12 @@ class basic_zipcrypto_encoder | ||
57 | 53 | return _stream != nullptr; |
58 | 54 | } |
59 | 55 | |
60 | - ELEM_TYPE* get_buffer_begin() override | |
56 | + char_type* get_buffer_begin() override | |
61 | 57 | { |
62 | 58 | return _inputBuffer; |
63 | 59 | } |
64 | 60 | |
65 | - ELEM_TYPE* get_buffer_end() override | |
61 | + char_type* get_buffer_end() override | |
66 | 62 | { |
67 | 63 | return _inputBuffer + _bufferCapacity; |
68 | 64 | } |
@@ -88,7 +84,7 @@ class basic_zipcrypto_encoder | ||
88 | 84 | { |
89 | 85 | _zipcrypto.encrypt_header(); |
90 | 86 | _stream->write( |
91 | - reinterpret_cast<const ELEM_TYPE*>(&_zipcrypto.get_encryption_header()), | |
87 | + reinterpret_cast<const char_type*>(&_zipcrypto.get_encryption_header()), | |
92 | 88 | _zipcrypto.get_encryption_header_size()); |
93 | 89 | |
94 | 90 | _encryptionHeaderWritten = true; |
@@ -99,14 +95,10 @@ class basic_zipcrypto_encoder | ||
99 | 95 | delete[] _inputBuffer; |
100 | 96 | } |
101 | 97 | |
102 | - ELEM_TYPE* _inputBuffer = nullptr; | |
98 | + char_type* _inputBuffer = nullptr; | |
103 | 99 | size_t _bufferCapacity = 0; |
104 | 100 | |
105 | - ostream_type* _stream = nullptr; | |
101 | + std::ostream* _stream = nullptr; | |
106 | 102 | detail::zipcrypto _zipcrypto; |
107 | 103 | bool _encryptionHeaderWritten = false; |
108 | 104 | }; |
109 | - | |
110 | -typedef basic_zipcrypto_encoder<uint8_t, std::char_traits<uint8_t>> byte_zipcrypto_encoder; | |
111 | -typedef basic_zipcrypto_encoder<char, std::char_traits<char>> zipcrypto_encoder; | |
112 | -typedef basic_zipcrypto_encoder<wchar_t, std::char_traits<wchar_t>> wzipcrypto_encoder; |
@@ -13,13 +13,13 @@ class CompressionMethod | ||
13 | 13 | , public std::enable_shared_from_this<CompressionMethod> |
14 | 14 | { |
15 | 15 | public: |
16 | - typedef std::shared_ptr<CompressionMethod> Ptr; | |
17 | - typedef std::shared_ptr<EncryptionMethod> EncryptionMethodPtr; | |
18 | - typedef std::shared_ptr<ZipArchiveEntry> ZipArchiveEntryPtr; | |
16 | + typedef std::shared_ptr<CompressionMethod> Ptr; | |
17 | + typedef std::shared_ptr<EncryptionMethod> EncryptionMethodPtr; | |
18 | + typedef std::shared_ptr<ZipArchiveEntry> ZipArchiveEntryPtr; | |
19 | 19 | |
20 | - typedef CompressionMethodBase::encoder_t encoder_t; | |
21 | - typedef CompressionMethodBase::decoder_t decoder_t; | |
22 | - typedef CompressionMethodBase::properties_t properties_t; | |
20 | + typedef CompressionMethodBase::encoder_type encoder_type; | |
21 | + typedef CompressionMethodBase::decoder_type decoder_type; | |
22 | + typedef CompressionMethodBase::properties_type properties_type; | |
23 | 23 | |
24 | 24 | EncryptionMethodPtr GetEncryptionMethod() const; |
25 | 25 | void SetEncryptionMethod(EncryptionMethodPtr encryptionMethod); |
@@ -18,13 +18,13 @@ class EncryptionMethod | ||
18 | 18 | friend class ZipMethodResolver; |
19 | 19 | |
20 | 20 | public: |
21 | - typedef std::shared_ptr<EncryptionMethod> Ptr; | |
22 | - typedef std::shared_ptr<CompressionMethod> CompressionMethodPtr; | |
23 | - typedef std::shared_ptr<ZipArchiveEntry> ZipArchiveEntryPtr; | |
21 | + typedef std::shared_ptr<EncryptionMethod> Ptr; | |
22 | + typedef std::shared_ptr<CompressionMethod> CompressionMethodPtr; | |
23 | + typedef std::shared_ptr<ZipArchiveEntry> ZipArchiveEntryPtr; | |
24 | 24 | |
25 | - typedef EncryptionMethodBase::encoder_t encoder_t; | |
26 | - typedef EncryptionMethodBase::decoder_t decoder_t; | |
27 | - typedef EncryptionMethodBase::properties_t properties_t; | |
25 | + typedef EncryptionMethodBase::encoder_type encoder_type; | |
26 | + typedef EncryptionMethodBase::decoder_type decoder_type; | |
27 | + typedef EncryptionMethodBase::properties_type properties_type; | |
28 | 28 | |
29 | 29 | CompressionMethodPtr GetCompressionMethod() const; |
30 | 30 |
@@ -12,10 +12,10 @@ class MethodTemplate | ||
12 | 12 | : public BASE_METHOD_CLASS |
13 | 13 | { |
14 | 14 | public: |
15 | - typedef std::shared_ptr<METHOD_CLASS> Ptr; | |
16 | - typedef typename BASE_METHOD_CLASS::encoder_t encoder_t; | |
17 | - typedef typename BASE_METHOD_CLASS::decoder_t decoder_t; | |
18 | - typedef typename BASE_METHOD_CLASS::properties_t properties_t; | |
15 | + typedef std::shared_ptr<METHOD_CLASS> Ptr; | |
16 | + typedef typename BASE_METHOD_CLASS::encoder_type encoder_type; | |
17 | + typedef typename BASE_METHOD_CLASS::decoder_type decoder_type; | |
18 | + typedef typename BASE_METHOD_CLASS::properties_type properties_type; | |
19 | 19 | |
20 | 20 | static const uint16_t CompressionMethod = COMPRESSION_METHOD; |
21 | 21 | static const uint16_t VersionNeededToExtract = VERSION_NEEDED_TO_EXTRACT; |
@@ -31,7 +31,7 @@ class MethodTemplate | ||
31 | 31 | return std::make_shared<METHOD_CLASS>(); |
32 | 32 | } |
33 | 33 | |
34 | - properties_t& GetProperties() override | |
34 | + properties_type& GetProperties() override | |
35 | 35 | { |
36 | 36 | _properties.normalize(); |
37 | 37 | return _properties; |
@@ -37,22 +37,22 @@ class ZipMethod | ||
37 | 37 | : public ZipMethodBase |
38 | 38 | { |
39 | 39 | public: |
40 | - typedef std::shared_ptr<ENCODER_TYPE> encoder_t; | |
41 | - typedef std::shared_ptr<DECODER_TYPE> decoder_t; | |
42 | - typedef PROPS_TYPE properties_t; | |
40 | + typedef std::shared_ptr<ENCODER_TYPE> encoder_type; | |
41 | + typedef std::shared_ptr<DECODER_TYPE> decoder_type; | |
42 | + typedef PROPS_TYPE properties_type; | |
43 | 43 | |
44 | - void SetEncoder(encoder_t encoder) { _encoder = encoder; } | |
45 | - void SetDecoder(decoder_t decoder) { _decoder = decoder; } | |
44 | + void SetEncoder(encoder_type encoder) { _encoder = encoder; } | |
45 | + void SetDecoder(decoder_type decoder) { _decoder = decoder; } | |
46 | 46 | |
47 | - encoder_t GetEncoder() const { return _encoder; } | |
48 | - decoder_t GetDecoder() const { return _decoder; } | |
47 | + encoder_type GetEncoder() const { return _encoder; } | |
48 | + decoder_type GetDecoder() const { return _decoder; } | |
49 | 49 | |
50 | - virtual properties_t& GetProperties() = 0; | |
50 | + virtual properties_type& GetProperties() = 0; | |
51 | 51 | |
52 | 52 | protected: |
53 | 53 | ZipMethod() { } |
54 | 54 | |
55 | 55 | private: |
56 | - encoder_t _encoder; | |
57 | - decoder_t _decoder; | |
56 | + encoder_type _encoder; | |
57 | + decoder_type _decoder; | |
58 | 58 | }; |
@@ -32,7 +32,7 @@ namespace detail { | ||
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | - byte_imemstream extraFieldDataStream(extraField.Data.data(), extraField.Data.size()); | |
35 | + imemstream extraFieldDataStream((const char*)extraField.Data.data(), extraField.Data.size()); | |
36 | 36 | |
37 | 37 | uint16_t dummyVendorID; |
38 | 38 |
@@ -49,7 +49,7 @@ namespace detail { | ||
49 | 49 | |
50 | 50 | extraField.Data.resize(SIZE_IN_BYTES); |
51 | 51 | |
52 | - byte_omemstream extraFieldDataStream(extraField.Data.data(), extraField.Data.size()); | |
52 | + omemstream extraFieldDataStream((char*)extraField.Data.data(), extraField.Data.size()); | |
53 | 53 | |
54 | 54 | serialize(extraFieldDataStream, AesVersion); |
55 | 55 | serialize(extraFieldDataStream, VendorID); |
@@ -2,27 +2,24 @@ | ||
2 | 2 | #include <iostream> |
3 | 3 | #include "streambuffs/audit_streambuf.h" |
4 | 4 | |
5 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
6 | -class basic_iauditstream | |
7 | - : public std::basic_istream<ELEM_TYPE, TRAITS_TYPE> | |
5 | +class iauditstream | |
6 | + : public std::istream | |
8 | 7 | { |
9 | 8 | public: |
10 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
11 | - | |
12 | - basic_iauditstream() | |
13 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_auditStreambuf) | |
9 | + iauditstream() | |
10 | + : std::istream(&_auditStreambuf) | |
14 | 11 | { |
15 | 12 | |
16 | 13 | } |
17 | 14 | |
18 | - basic_iauditstream(stream_type& stream) | |
19 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_auditStreambuf) | |
15 | + iauditstream(std::ios& stream) | |
16 | + : std::istream(&_auditStreambuf) | |
20 | 17 | , _auditStreambuf(stream) |
21 | 18 | { |
22 | 19 | |
23 | 20 | } |
24 | 21 | |
25 | - void set_stream(stream_type& stream) | |
22 | + void set_stream(std::ios& stream) | |
26 | 23 | { |
27 | 24 | _auditStreambuf.set_stream(stream); |
28 | 25 | } |
@@ -33,30 +30,27 @@ class basic_iauditstream | ||
33 | 30 | } |
34 | 31 | |
35 | 32 | private: |
36 | - audit_streambuf<ELEM_TYPE, TRAITS_TYPE> _auditStreambuf; | |
33 | + audit_streambuf _auditStreambuf; | |
37 | 34 | }; |
38 | 35 | |
39 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
40 | -class basic_oauditstream | |
41 | - : public std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> | |
36 | +class oauditstream | |
37 | + : public std::ostream | |
42 | 38 | { |
43 | 39 | public: |
44 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
45 | - | |
46 | - basic_oauditstream() | |
47 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_auditStreambuf) | |
40 | + oauditstream() | |
41 | + : std::ostream(&_auditStreambuf) | |
48 | 42 | { |
49 | 43 | |
50 | 44 | } |
51 | 45 | |
52 | - basic_oauditstream(stream_type& stream) | |
53 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_auditStreambuf) | |
46 | + oauditstream(std::ios& stream) | |
47 | + : std::ostream(&_auditStreambuf) | |
54 | 48 | , _auditStreambuf(stream) |
55 | 49 | { |
56 | 50 | |
57 | 51 | } |
58 | 52 | |
59 | - void set_stream(stream_type& stream) | |
53 | + void set_stream(std::ios& stream) | |
60 | 54 | { |
61 | 55 | _auditStreambuf.set_stream(stream); |
62 | 56 | } |
@@ -67,30 +61,27 @@ class basic_oauditstream | ||
67 | 61 | } |
68 | 62 | |
69 | 63 | private: |
70 | - audit_streambuf<ELEM_TYPE, TRAITS_TYPE> _auditStreambuf; | |
64 | + audit_streambuf _auditStreambuf; | |
71 | 65 | }; |
72 | 66 | |
73 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
74 | -class basic_ioauditstream | |
75 | - : public std::basic_iostream<ELEM_TYPE, TRAITS_TYPE> | |
67 | +class ioauditstream | |
68 | + : public std::iostream | |
76 | 69 | { |
77 | 70 | public: |
78 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
79 | - | |
80 | - basic_ioauditstream() | |
81 | - : std::basic_iostream<ELEM_TYPE, TRAITS_TYPE>(&_auditStreambuf) | |
71 | + ioauditstream() | |
72 | + : std::iostream(&_auditStreambuf) | |
82 | 73 | { |
83 | 74 | |
84 | 75 | } |
85 | 76 | |
86 | - basic_ioauditstream(stream_type& stream) | |
87 | - : std::basic_iostream<ELEM_TYPE, TRAITS_TYPE>(&_auditStreambuf) | |
77 | + ioauditstream(std::ios& stream) | |
78 | + : std::iostream(&_auditStreambuf) | |
88 | 79 | , _auditStreambuf(stream) |
89 | 80 | { |
90 | 81 | |
91 | 82 | } |
92 | 83 | |
93 | - void set_stream(stream_type& stream) | |
84 | + void set_stream(std::ios& stream) | |
94 | 85 | { |
95 | 86 | _auditStreambuf.set_stream(stream); |
96 | 87 | } |
@@ -106,19 +97,5 @@ class basic_ioauditstream | ||
106 | 97 | } |
107 | 98 | |
108 | 99 | private: |
109 | - audit_streambuf<ELEM_TYPE, TRAITS_TYPE> _auditStreambuf; | |
100 | + audit_streambuf _auditStreambuf; | |
110 | 101 | }; |
111 | - | |
112 | -////////////////////////////////////////////////////////////////////////// | |
113 | - | |
114 | -typedef basic_iauditstream<uint8_t, std::char_traits<uint8_t>> byte_iauditstream; | |
115 | -typedef basic_iauditstream<char, std::char_traits<char>> iauditstream; | |
116 | -typedef basic_iauditstream<wchar_t, std::char_traits<wchar_t>> wiauditstream; | |
117 | - | |
118 | -typedef basic_oauditstream<uint8_t, std::char_traits<uint8_t>> byte_oauditstream; | |
119 | -typedef basic_oauditstream<char, std::char_traits<char>> oauditstream; | |
120 | -typedef basic_oauditstream<wchar_t, std::char_traits<wchar_t>> woauditstream; | |
121 | - | |
122 | -typedef basic_ioauditstream<uint8_t, std::char_traits<uint8_t>> byte_ioauditstream; | |
123 | -typedef basic_ioauditstream<char, std::char_traits<char>> ioauditstream; | |
124 | -typedef basic_ioauditstream<wchar_t, std::char_traits<wchar_t>> wioauditstream; |
@@ -5,45 +5,40 @@ | ||
5 | 5 | /** |
6 | 6 | * \brief Basic generic compression decoder stream. |
7 | 7 | */ |
8 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
9 | -class basic_compression_decoder_stream | |
10 | - : public std::basic_istream<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class compression_decoder_stream | |
9 | + : public std::istream | |
11 | 10 | { |
12 | 11 | public: |
13 | - typedef typename compression_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
14 | - typedef typename compression_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
12 | + typedef compression_decoder_streambuf::compression_decoder_interface_ptr compression_decoder_interface_ptr; | |
15 | 13 | |
16 | - typedef typename compression_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::icompression_decoder_type icompression_decoder_type; | |
17 | - typedef typename compression_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::icompression_decoder_ptr_type icompression_decoder_ptr_type; | |
18 | - | |
19 | - basic_compression_decoder_stream() | |
20 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_compressionDecoderStreambuf) | |
14 | + compression_decoder_stream() | |
15 | + : std::istream(&_compressionDecoderStreambuf) | |
21 | 16 | { |
22 | 17 | |
23 | 18 | } |
24 | 19 | |
25 | - basic_compression_decoder_stream(icompression_decoder_ptr_type compressionDecoder, istream_type& stream) | |
26 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_compressionDecoderStreambuf) | |
20 | + compression_decoder_stream(compression_decoder_interface_ptr compressionDecoder, std::istream& stream) | |
21 | + : std::istream(&_compressionDecoderStreambuf) | |
27 | 22 | , _compressionDecoderStreambuf(compressionDecoder, stream) |
28 | 23 | { |
29 | 24 | |
30 | 25 | } |
31 | 26 | |
32 | - basic_compression_decoder_stream(icompression_decoder_ptr_type compressionDecoder, compression_properties_interface& props, istream_type& stream) | |
33 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_compressionDecoderStreambuf) | |
27 | + compression_decoder_stream(compression_decoder_interface_ptr compressionDecoder, compression_properties_interface& props, std::istream& stream) | |
28 | + : std::istream(&_compressionDecoderStreambuf) | |
34 | 29 | , _compressionDecoderStreambuf(compressionDecoder, props, stream) |
35 | 30 | { |
36 | 31 | |
37 | 32 | } |
38 | 33 | |
39 | - bool init(icompression_decoder_ptr_type compressionDecoder, istream_type& stream) | |
34 | + void init(compression_decoder_interface_ptr compressionDecoder, std::istream& stream) | |
40 | 35 | { |
41 | - return _compressionDecoderStreambuf.init(compressionDecoder, stream); | |
36 | + _compressionDecoderStreambuf.init(compressionDecoder, stream); | |
42 | 37 | } |
43 | 38 | |
44 | - bool init(icompression_decoder_ptr_type compressionDecoder, compression_properties_interface& props, istream_type& stream) | |
39 | + void init(compression_decoder_interface_ptr compressionDecoder, compression_properties_interface& props, std::istream& stream) | |
45 | 40 | { |
46 | - return _compressionDecoderStreambuf.init(compressionDecoder, props, stream); | |
41 | + _compressionDecoderStreambuf.init(compressionDecoder, props, stream); | |
47 | 42 | } |
48 | 43 | |
49 | 44 | bool is_init() const |
@@ -52,11 +47,5 @@ class basic_compression_decoder_stream | ||
52 | 47 | } |
53 | 48 | |
54 | 49 | private: |
55 | - compression_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE> _compressionDecoderStreambuf; | |
50 | + compression_decoder_streambuf _compressionDecoderStreambuf; | |
56 | 51 | }; |
57 | - | |
58 | -////////////////////////////////////////////////////////////////////////// | |
59 | - | |
60 | -typedef basic_compression_decoder_stream<uint8_t, std::char_traits<uint8_t>> byte_compression_decoder_stream; | |
61 | -typedef basic_compression_decoder_stream<char, std::char_traits<char>> compression_decoder_stream; | |
62 | -typedef basic_compression_decoder_stream<wchar_t, std::char_traits<wchar_t>> wcompression_decoder_stream; |
@@ -5,43 +5,38 @@ | ||
5 | 5 | /** |
6 | 6 | * \brief Basic generic compression encoder stream. |
7 | 7 | */ |
8 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
9 | -class basic_compression_encoder_stream | |
10 | - : public std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class compression_encoder_stream | |
9 | + : public std::ostream | |
11 | 10 | { |
12 | 11 | public: |
13 | - typedef typename compression_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
14 | - typedef typename compression_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
12 | + typedef compression_encoder_streambuf::compression_encoder_interface_ptr compression_encoder_interface_ptr; | |
15 | 13 | |
16 | - typedef typename compression_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::icompression_encoder_type icompression_encoder_type; | |
17 | - typedef typename compression_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::icompression_encoder_ptr_type icompression_encoder_ptr_type; | |
18 | - | |
19 | - basic_compression_encoder_stream() | |
20 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_compressionEncoderStreambuf) | |
14 | + compression_encoder_stream() | |
15 | + : std::ostream(&_compressionEncoderStreambuf) | |
21 | 16 | { |
22 | 17 | |
23 | 18 | } |
24 | 19 | |
25 | - basic_compression_encoder_stream(icompression_encoder_ptr_type compressionEncoder, ostream_type& stream) | |
26 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_compressionEncoderStreambuf) | |
20 | + compression_encoder_stream(compression_encoder_interface_ptr compressionEncoder, std::ostream& stream) | |
21 | + : std::ostream(&_compressionEncoderStreambuf) | |
27 | 22 | , _compressionEncoderStreambuf(compressionEncoder, stream) |
28 | 23 | { |
29 | 24 | |
30 | 25 | } |
31 | 26 | |
32 | - basic_compression_encoder_stream(icompression_encoder_ptr_type compressionEncoder, compression_properties_interface& props, ostream_type& stream) | |
33 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_compressionEncoderStreambuf) | |
27 | + compression_encoder_stream(compression_encoder_interface_ptr compressionEncoder, compression_properties_interface& props, std::ostream& stream) | |
28 | + : std::ostream(&_compressionEncoderStreambuf) | |
34 | 29 | , _compressionEncoderStreambuf(compressionEncoder, props, stream) |
35 | 30 | { |
36 | 31 | |
37 | 32 | } |
38 | 33 | |
39 | - void init(icompression_encoder_ptr_type compressionEncoder, ostream_type& stream) | |
34 | + void init(compression_encoder_interface_ptr compressionEncoder, std::ostream& stream) | |
40 | 35 | { |
41 | 36 | _compressionEncoderStreambuf.init(compressionEncoder, stream); |
42 | 37 | } |
43 | 38 | |
44 | - void init(icompression_encoder_ptr_type compressionEncoder, compression_properties_interface& props, ostream_type& stream) | |
39 | + void init(compression_encoder_interface_ptr compressionEncoder, compression_properties_interface& props, std::ostream& stream) | |
45 | 40 | { |
46 | 41 | _compressionEncoderStreambuf.init(compressionEncoder, props, stream); |
47 | 42 | } |
@@ -52,11 +47,5 @@ class basic_compression_encoder_stream | ||
52 | 47 | } |
53 | 48 | |
54 | 49 | private: |
55 | - compression_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE> _compressionEncoderStreambuf; | |
50 | + compression_encoder_streambuf _compressionEncoderStreambuf; | |
56 | 51 | }; |
57 | - | |
58 | -////////////////////////////////////////////////////////////////////////// | |
59 | - | |
60 | -typedef basic_compression_encoder_stream<uint8_t, std::char_traits<uint8_t>> byte_compression_encoder_stream; | |
61 | -typedef basic_compression_encoder_stream<char, std::char_traits<char>> compression_encoder_stream; | |
62 | -typedef basic_compression_encoder_stream<wchar_t, std::char_traits<wchar_t>> wcompression_encoder_stream; |
@@ -5,25 +5,24 @@ | ||
5 | 5 | /** |
6 | 6 | * \brief Basic CRC32 output stream. Computes CRC32 of input data. |
7 | 7 | */ |
8 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
9 | -class basic_crc32stream | |
10 | - : public std::basic_istream<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class crc32stream | |
9 | + : public std::istream | |
11 | 10 | { |
12 | 11 | public: |
13 | - basic_crc32stream() | |
14 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_crc32Streambuf) | |
12 | + crc32stream() | |
13 | + : std::istream(&_crc32Streambuf) | |
15 | 14 | { |
16 | 15 | |
17 | 16 | } |
18 | 17 | |
19 | - basic_crc32stream(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>* stream) | |
20 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_crc32Streambuf) | |
18 | + crc32stream(std::istream& stream) | |
19 | + : std::istream(&_crc32Streambuf) | |
21 | 20 | , _crc32Streambuf(stream) |
22 | 21 | { |
23 | 22 | |
24 | 23 | } |
25 | 24 | |
26 | - void init(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& stream) | |
25 | + void init(std::istream& stream) | |
27 | 26 | { |
28 | 27 | _crc32Streambuf.init(stream); |
29 | 28 | } |
@@ -34,11 +33,5 @@ class basic_crc32stream | ||
34 | 33 | } |
35 | 34 | |
36 | 35 | private: |
37 | - crc32_streambuf<ELEM_TYPE, TRAITS_TYPE> _crc32Streambuf; | |
36 | + crc32_streambuf _crc32Streambuf; | |
38 | 37 | }; |
39 | - | |
40 | -////////////////////////////////////////////////////////////////////////// | |
41 | - | |
42 | -typedef basic_crc32stream<uint8_t, std::char_traits<uint8_t>> byte_crc32stream; | |
43 | -typedef basic_crc32stream<char, std::char_traits<char>> crc32stream; | |
44 | -typedef basic_crc32stream<wchar_t, std::char_traits<wchar_t>> wcrc32stream; |
@@ -5,45 +5,40 @@ | ||
5 | 5 | /** |
6 | 6 | * \brief Basic generic encryption decoder stream. |
7 | 7 | */ |
8 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
9 | -class basic_encryption_decoder_stream | |
10 | - : public std::basic_istream<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class encryption_decoder_stream | |
9 | + : public std::istream | |
11 | 10 | { |
12 | 11 | public: |
13 | - typedef typename encryption_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
14 | - typedef typename encryption_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
12 | + typedef encryption_decoder_streambuf::encryption_decoder_interface_ptr encryption_decoder_interface_ptr; | |
15 | 13 | |
16 | - typedef typename encryption_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::iencryption_decoder_type iencryption_decoder_type; | |
17 | - typedef typename encryption_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::iencryption_decoder_ptr_type iencryption_decoder_ptr_type; | |
18 | - | |
19 | - basic_encryption_decoder_stream() | |
20 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_encryptionDecoderStreambuf) | |
14 | + encryption_decoder_stream() | |
15 | + : std::istream(&_encryptionDecoderStreambuf) | |
21 | 16 | { |
22 | 17 | |
23 | 18 | } |
24 | 19 | |
25 | - basic_encryption_decoder_stream(iencryption_decoder_ptr_type encryptionDecoder, istream_type& stream) | |
26 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_encryptionDecoderStreambuf) | |
20 | + encryption_decoder_stream(encryption_decoder_interface_ptr encryptionDecoder, std::istream& stream) | |
21 | + : std::istream(&_encryptionDecoderStreambuf) | |
27 | 22 | , _encryptionDecoderStreambuf(encryptionDecoder, stream) |
28 | 23 | { |
29 | 24 | |
30 | 25 | } |
31 | 26 | |
32 | - basic_encryption_decoder_stream(iencryption_decoder_ptr_type encryptionDecoder, encryption_properties_interface& props, istream_type& stream) | |
33 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_encryptionDecoderStreambuf) | |
27 | + encryption_decoder_stream(encryption_decoder_interface_ptr encryptionDecoder, encryption_properties_interface& props, std::istream& stream) | |
28 | + : std::istream(&_encryptionDecoderStreambuf) | |
34 | 29 | , _encryptionDecoderStreambuf(encryptionDecoder, props, stream) |
35 | 30 | { |
36 | 31 | |
37 | 32 | } |
38 | 33 | |
39 | - bool init(iencryption_decoder_ptr_type encryptionDecoder, istream_type& stream) | |
34 | + void init(encryption_decoder_interface_ptr encryptionDecoder, std::istream& stream) | |
40 | 35 | { |
41 | - return _encryptionDecoderStreambuf.init(encryptionDecoder, stream); | |
36 | + _encryptionDecoderStreambuf.init(encryptionDecoder, stream); | |
42 | 37 | } |
43 | 38 | |
44 | - bool init(iencryption_decoder_ptr_type encryptionDecoder, encryption_properties_interface& props, istream_type& stream) | |
39 | + void init(encryption_decoder_interface_ptr encryptionDecoder, encryption_properties_interface& props, std::istream& stream) | |
45 | 40 | { |
46 | - return _encryptionDecoderStreambuf.init(encryptionDecoder, props, stream); | |
41 | + _encryptionDecoderStreambuf.init(encryptionDecoder, props, stream); | |
47 | 42 | } |
48 | 43 | |
49 | 44 | bool is_init() const |
@@ -52,11 +47,5 @@ class basic_encryption_decoder_stream | ||
52 | 47 | } |
53 | 48 | |
54 | 49 | private: |
55 | - encryption_decoder_streambuf<ELEM_TYPE, TRAITS_TYPE> _encryptionDecoderStreambuf; | |
50 | + encryption_decoder_streambuf _encryptionDecoderStreambuf; | |
56 | 51 | }; |
57 | - | |
58 | -////////////////////////////////////////////////////////////////////////// | |
59 | - | |
60 | -typedef basic_encryption_decoder_stream<uint8_t, std::char_traits<uint8_t>> byte_encryption_decoder_stream; | |
61 | -typedef basic_encryption_decoder_stream<char, std::char_traits<char>> encryption_decoder_stream; | |
62 | -typedef basic_encryption_decoder_stream<wchar_t, std::char_traits<wchar_t>> wencryption_decoder_stream; |
@@ -5,43 +5,38 @@ | ||
5 | 5 | /** |
6 | 6 | * \brief Basic generic encryption encoder stream. |
7 | 7 | */ |
8 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
9 | -class basic_encryption_encoder_stream | |
10 | - : public std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class encryption_encoder_stream | |
9 | + : public std::ostream | |
11 | 10 | { |
12 | 11 | public: |
13 | - typedef typename encryption_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::istream_type istream_type; | |
14 | - typedef typename encryption_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::ostream_type ostream_type; | |
12 | + typedef encryption_encoder_streambuf::encryption_encoder_interface_ptr encryption_encoder_interface_ptr; | |
15 | 13 | |
16 | - typedef typename encryption_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::iencryption_encoder_type iencryption_encoder_type; | |
17 | - typedef typename encryption_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE>::iencryption_encoder_ptr_type iencryption_encoder_ptr_type; | |
18 | - | |
19 | - basic_encryption_encoder_stream() | |
20 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_encryptionEncoderStreambuf) | |
14 | + encryption_encoder_stream() | |
15 | + : std::ostream(&_encryptionEncoderStreambuf) | |
21 | 16 | { |
22 | 17 | |
23 | 18 | } |
24 | 19 | |
25 | - basic_encryption_encoder_stream(iencryption_encoder_ptr_type encryptionEncoder, ostream_type& stream) | |
26 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_encryptionEncoderStreambuf) | |
20 | + encryption_encoder_stream(encryption_encoder_interface_ptr encryptionEncoder, std::ostream& stream) | |
21 | + : std::ostream(&_encryptionEncoderStreambuf) | |
27 | 22 | , _encryptionEncoderStreambuf(encryptionEncoder, stream) |
28 | 23 | { |
29 | 24 | |
30 | 25 | } |
31 | 26 | |
32 | - basic_encryption_encoder_stream(iencryption_encoder_ptr_type encryptionEncoder, encryption_properties_interface& props, ostream_type& stream) | |
33 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_encryptionEncoderStreambuf) | |
27 | + encryption_encoder_stream(encryption_encoder_interface_ptr encryptionEncoder, encryption_properties_interface& props, std::ostream& stream) | |
28 | + : std::ostream(&_encryptionEncoderStreambuf) | |
34 | 29 | , _encryptionEncoderStreambuf(encryptionEncoder, props, stream) |
35 | 30 | { |
36 | 31 | |
37 | 32 | } |
38 | 33 | |
39 | - void init(iencryption_encoder_ptr_type encryptionEncoder, ostream_type& stream) | |
34 | + void init(encryption_encoder_interface_ptr encryptionEncoder, std::ostream& stream) | |
40 | 35 | { |
41 | 36 | _encryptionEncoderStreambuf.init(encryptionEncoder, stream); |
42 | 37 | } |
43 | 38 | |
44 | - void init(iencryption_encoder_ptr_type encryptionEncoder, encryption_properties_interface& props, ostream_type& stream) | |
39 | + void init(encryption_encoder_interface_ptr encryptionEncoder, encryption_properties_interface& props, std::ostream& stream) | |
45 | 40 | { |
46 | 41 | _encryptionEncoderStreambuf.init(encryptionEncoder, props, stream); |
47 | 42 | } |
@@ -52,11 +47,5 @@ class basic_encryption_encoder_stream | ||
52 | 47 | } |
53 | 48 | |
54 | 49 | private: |
55 | - encryption_encoder_streambuf<ELEM_TYPE, TRAITS_TYPE> _encryptionEncoderStreambuf; | |
50 | + encryption_encoder_streambuf _encryptionEncoderStreambuf; | |
56 | 51 | }; |
57 | - | |
58 | -////////////////////////////////////////////////////////////////////////// | |
59 | - | |
60 | -typedef basic_encryption_encoder_stream<uint8_t, std::char_traits<uint8_t>> byte_encryption_encoder_stream; | |
61 | -typedef basic_encryption_encoder_stream<char, std::char_traits<char>> encryption_encoder_stream; | |
62 | -typedef basic_encryption_encoder_stream<wchar_t, std::char_traits<wchar_t>> wencryption_encoder_stream; |
@@ -9,27 +9,26 @@ | ||
9 | 9 | * Supports seeking. |
10 | 10 | * Returns EOF when stream seeks behind the size of buffer. |
11 | 11 | */ |
12 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
13 | -class basic_imemstream | |
14 | - : public std::basic_istream<ELEM_TYPE, TRAITS_TYPE> | |
12 | +class imemstream | |
13 | + : public std::istream | |
15 | 14 | { |
16 | 15 | public: |
17 | - basic_imemstream(const ELEM_TYPE* buffer, size_t length) | |
18 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_memStreambuf) | |
19 | - , _memStreambuf(const_cast<ELEM_TYPE*>(buffer), length) | |
16 | + imemstream(const char_type* buffer, size_t length) | |
17 | + : std::istream(&_memStreambuf) | |
18 | + , _memStreambuf(const_cast<char_type*>(buffer), length) | |
20 | 19 | { |
21 | 20 | |
22 | 21 | } |
23 | 22 | |
24 | 23 | template <size_t N> |
25 | - basic_imemstream(const ELEM_TYPE (&buffer)[N]) | |
26 | - : basic_imemstream(buffer, N) | |
24 | + imemstream(const char_type (&buffer)[N]) | |
25 | + : imemstream(buffer, N) | |
27 | 26 | { |
28 | 27 | |
29 | 28 | } |
30 | 29 | |
31 | 30 | private: |
32 | - mem_streambuf<ELEM_TYPE, TRAITS_TYPE> _memStreambuf; | |
31 | + mem_streambuf _memStreambuf; | |
33 | 32 | }; |
34 | 33 | |
35 | 34 | /** |
@@ -38,28 +37,27 @@ class basic_imemstream | ||
38 | 37 | * Supports seeking. |
39 | 38 | * Sets badbit if the stream wants to write behind the buffer size. |
40 | 39 | */ |
41 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
42 | -class basic_omemstream | |
43 | - : public std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> | |
40 | +class omemstream | |
41 | + : public std::ostream | |
44 | 42 | { |
45 | 43 | public: |
46 | - basic_omemstream(ELEM_TYPE* buffer, size_t length) | |
44 | + omemstream(char_type* buffer, size_t length) | |
47 | 45 | : _memStreambuf(buffer, length) |
48 | - , std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_memStreambuf) | |
46 | + , std::ostream(&_memStreambuf) | |
49 | 47 | { |
50 | 48 | |
51 | 49 | } |
52 | 50 | |
53 | 51 | template <size_t N> |
54 | - basic_omemstream(ELEM_TYPE (&buffer)[N]) | |
52 | + omemstream(char_type (&buffer)[N]) | |
55 | 53 | : _memStreambuf(buffer, N) |
56 | - , std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_memStreambuf) | |
54 | + , std::ostream(&_memStreambuf) | |
57 | 55 | { |
58 | 56 | |
59 | 57 | } |
60 | 58 | |
61 | 59 | private: |
62 | - mem_streambuf<ELEM_TYPE, TRAITS_TYPE> _memStreambuf; | |
60 | + mem_streambuf _memStreambuf; | |
63 | 61 | }; |
64 | 62 | |
65 | 63 | /** |
@@ -70,40 +68,25 @@ class basic_omemstream | ||
70 | 68 | * Returns EOF when stream seeks behind the size of buffer. |
71 | 69 | * Sets badbit if the stream wants to write behind the buffer size. |
72 | 70 | */ |
73 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
74 | -class basic_iomemstream | |
75 | - : public std::basic_iostream<ELEM_TYPE, TRAITS_TYPE> | |
71 | +class iomemstream | |
72 | + : public std::iostream | |
76 | 73 | { |
77 | 74 | public: |
78 | - basic_iomemstream(ELEM_TYPE* buffer, size_t length) | |
75 | + iomemstream(char_type* buffer, size_t length) | |
79 | 76 | : _memStreambuf(buffer, length) |
80 | - , std::basic_iostream<ELEM_TYPE, TRAITS_TYPE>(&_memStreambuf) | |
77 | + , std::iostream(&_memStreambuf) | |
81 | 78 | { |
82 | 79 | |
83 | 80 | } |
84 | 81 | |
85 | 82 | template <size_t N> |
86 | - basic_iomemstream(ELEM_TYPE (&buffer)[N]) | |
83 | + iomemstream(char_type (&buffer)[N]) | |
87 | 84 | : _memStreambuf(buffer, N) |
88 | - , std::basic_iostream<ELEM_TYPE, TRAITS_TYPE>(&_memStreambuf) | |
85 | + , std::iostream(&_memStreambuf) | |
89 | 86 | { |
90 | 87 | |
91 | 88 | } |
92 | 89 | |
93 | 90 | private: |
94 | - mem_streambuf<ELEM_TYPE, TRAITS_TYPE> _memStreambuf; | |
91 | + mem_streambuf _memStreambuf; | |
95 | 92 | }; |
96 | - | |
97 | -////////////////////////////////////////////////////////////////////////// | |
98 | - | |
99 | -typedef basic_imemstream<uint8_t, std::char_traits<uint8_t>> byte_imemstream; | |
100 | -typedef basic_imemstream<char, std::char_traits<char>> imemstream; | |
101 | -typedef basic_imemstream<wchar_t, std::char_traits<wchar_t>> wimemstream; | |
102 | - | |
103 | -typedef basic_omemstream<uint8_t, std::char_traits<uint8_t>> byte_omemstream; | |
104 | -typedef basic_omemstream<char, std::char_traits<char>> omemstream; | |
105 | -typedef basic_omemstream<wchar_t, std::char_traits<wchar_t>> womemstream; | |
106 | - | |
107 | -typedef basic_iomemstream<uint8_t, std::char_traits<uint8_t>> byte_iomemstream; | |
108 | -typedef basic_iomemstream<char, std::char_traits<char>> iomemstream; | |
109 | -typedef basic_iomemstream<wchar_t, std::char_traits<wchar_t>> wiomemstream; |
@@ -1,28 +1,20 @@ | ||
1 | 1 | #pragma once |
2 | 2 | #include <iostream> |
3 | -#include <cstdint> | |
4 | 3 | #include "streambuffs/null_streambuf.h" |
5 | 4 | |
6 | 5 | /** |
7 | 6 | * \brief Basic null stream. |
8 | 7 | */ |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | -class basic_nullstream | |
11 | - : public std::basic_iostream<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class nullstream | |
9 | + : public std::iostream | |
12 | 10 | { |
13 | 11 | public: |
14 | - basic_nullstream() | |
15 | - : std::basic_iostream<ELEM_TYPE, TRAITS_TYPE>(&_nullStreambuf) | |
12 | + nullstream() | |
13 | + : std::iostream(&_nullStreambuf) | |
16 | 14 | { |
17 | 15 | |
18 | 16 | } |
19 | 17 | |
20 | 18 | private: |
21 | - null_streambuf<ELEM_TYPE, TRAITS_TYPE> _nullStreambuf; | |
19 | + null_streambuf _nullStreambuf; | |
22 | 20 | }; |
23 | - | |
24 | -////////////////////////////////////////////////////////////////////////// | |
25 | - | |
26 | -typedef basic_nullstream<uint8_t, std::char_traits<uint8_t>> byte_nullstream; | |
27 | -typedef basic_nullstream<char, std::char_traits<char>> nullstream; | |
28 | -typedef basic_nullstream<wchar_t, std::char_traits<wchar_t>> wnullstream; |
@@ -204,4 +204,4 @@ template <typename ELEM_TYPE, typename TRAITS_TYPE, typename ARRAY_ELEM_TYPE, si | ||
204 | 204 | std::ios::pos_type deserialize(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& stream, std::array<ARRAY_ELEM_TYPE, ARRAY_SIZE>& out) |
205 | 205 | { |
206 | 206 | return detail::deserialize_stl_container(stream, out, out.size()); |
207 | -} | |
207 | +} | |
\ No newline at end of file |
@@ -3,37 +3,22 @@ | ||
3 | 3 | #include <cstdint> |
4 | 4 | #include <cassert> |
5 | 5 | |
6 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
7 | 6 | class audit_streambuf |
8 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
7 | + : public std::streambuf | |
9 | 8 | { |
10 | 9 | public: |
11 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
12 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
13 | - | |
14 | - typedef typename base_type::char_type char_type; | |
15 | - typedef typename base_type::int_type int_type; | |
16 | - typedef typename base_type::pos_type pos_type; | |
17 | - typedef typename base_type::off_type off_type; | |
18 | - | |
19 | - typedef base_type streambuf_type; | |
20 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
21 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
22 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
23 | - | |
24 | - | |
25 | 10 | audit_streambuf() |
26 | 11 | { |
27 | 12 | |
28 | 13 | } |
29 | 14 | |
30 | - audit_streambuf(stream_type& stream) | |
15 | + audit_streambuf(std::ios& stream) | |
31 | 16 | : _streambuf(stream.rdbuf()) |
32 | 17 | { |
33 | 18 | |
34 | 19 | } |
35 | 20 | |
36 | - void set_stream(stream_type& stream) | |
21 | + void set_stream(std::ios& stream) | |
37 | 22 | { |
38 | 23 | _streambuf = stream.rdbuf(); |
39 | 24 | } |
@@ -71,7 +56,7 @@ class audit_streambuf | ||
71 | 56 | return n; |
72 | 57 | } |
73 | 58 | |
74 | - std::streamsize xsputn(const ELEM_TYPE* ptr, std::streamsize count) override | |
59 | + std::streamsize xsputn(const char_type* ptr, std::streamsize count) override | |
75 | 60 | { |
76 | 61 | auto n = _streambuf->sputn(ptr, count); |
77 | 62 | _bytesWritten += static_cast<size_t>(n); |
@@ -84,7 +69,7 @@ class audit_streambuf | ||
84 | 69 | } |
85 | 70 | |
86 | 71 | private: |
87 | - streambuf_type* _streambuf = nullptr; | |
72 | + std::streambuf* _streambuf = nullptr; | |
88 | 73 | size_t _bytesRead = 0; |
89 | 74 | size_t _bytesWritten = 0; |
90 | 75 | }; |
@@ -6,42 +6,28 @@ | ||
6 | 6 | |
7 | 7 | #include "../../compression/compression_interface.h" |
8 | 8 | |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | 9 | class compression_decoder_streambuf |
11 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
10 | + : public std::streambuf | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
15 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
16 | - | |
17 | - typedef typename base_type::char_type char_type; | |
18 | - typedef typename base_type::int_type int_type; | |
19 | - typedef typename base_type::pos_type pos_type; | |
20 | - typedef typename base_type::off_type off_type; | |
21 | - | |
22 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
23 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
24 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
25 | - | |
26 | - typedef compression_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> icompression_decoder_type; | |
27 | - typedef std::shared_ptr<icompression_decoder_type> icompression_decoder_ptr_type; | |
13 | + typedef std::shared_ptr<compression_decoder_interface> compression_decoder_interface_ptr; | |
28 | 14 | |
29 | 15 | compression_decoder_streambuf() |
30 | 16 | { |
31 | 17 | |
32 | 18 | } |
33 | 19 | |
34 | - compression_decoder_streambuf(icompression_decoder_ptr_type compressionDecoder, istream_type& stream) | |
20 | + compression_decoder_streambuf(compression_decoder_interface_ptr compressionDecoder, std::istream& stream) | |
35 | 21 | { |
36 | 22 | init(compressionDecoder, stream); |
37 | 23 | } |
38 | 24 | |
39 | - compression_decoder_streambuf(icompression_decoder_ptr_type compressionDecoder, compression_properties_interface& props, istream_type& stream) | |
25 | + compression_decoder_streambuf(compression_decoder_interface_ptr compressionDecoder, compression_properties_interface& props, std::istream& stream) | |
40 | 26 | { |
41 | 27 | init(compressionDecoder, props, stream); |
42 | 28 | } |
43 | 29 | |
44 | - void init(icompression_decoder_ptr_type compressionDecoder, istream_type& stream) | |
30 | + void init(compression_decoder_interface_ptr compressionDecoder, std::istream& stream) | |
45 | 31 | { |
46 | 32 | _compressionDecoder = compressionDecoder; |
47 | 33 |
@@ -52,7 +38,7 @@ class compression_decoder_streambuf | ||
52 | 38 | this->setg(_compressionDecoder->get_buffer_end(), _compressionDecoder->get_buffer_end(), _compressionDecoder->get_buffer_end()); |
53 | 39 | } |
54 | 40 | |
55 | - void init(icompression_decoder_ptr_type compressionDecoder, compression_properties_interface& props, istream_type& stream) | |
41 | + void init(compression_decoder_interface_ptr compressionDecoder, compression_properties_interface& props, std::istream& stream) | |
56 | 42 | { |
57 | 43 | _compressionDecoder = compressionDecoder; |
58 | 44 |
@@ -74,7 +60,7 @@ class compression_decoder_streambuf | ||
74 | 60 | // buffer exhausted |
75 | 61 | if (this->gptr() >= this->egptr()) |
76 | 62 | { |
77 | - ELEM_TYPE* base = _compressionDecoder->get_buffer_begin(); | |
63 | + char_type* base = _compressionDecoder->get_buffer_begin(); | |
78 | 64 | |
79 | 65 | // how many bytes has been read |
80 | 66 | size_t n = _compressionDecoder->decode_next(); |
@@ -92,5 +78,5 @@ class compression_decoder_streambuf | ||
92 | 78 | } |
93 | 79 | |
94 | 80 | private: |
95 | - icompression_decoder_ptr_type _compressionDecoder; | |
81 | + compression_decoder_interface_ptr _compressionDecoder; | |
96 | 82 | }; |
@@ -6,37 +6,23 @@ | ||
6 | 6 | |
7 | 7 | #include "../../compression/compression_interface.h" |
8 | 8 | |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | 9 | class compression_encoder_streambuf |
11 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
10 | + : public std::streambuf | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
15 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
16 | - | |
17 | - typedef typename base_type::char_type char_type; | |
18 | - typedef typename base_type::int_type int_type; | |
19 | - typedef typename base_type::pos_type pos_type; | |
20 | - typedef typename base_type::off_type off_type; | |
21 | - | |
22 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
23 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
24 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
25 | - | |
26 | - typedef compression_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> icompression_encoder_type; | |
27 | - typedef std::shared_ptr<icompression_encoder_type> icompression_encoder_ptr_type; | |
13 | + typedef std::shared_ptr<compression_encoder_interface> compression_encoder_interface_ptr; | |
28 | 14 | |
29 | 15 | compression_encoder_streambuf() |
30 | 16 | { |
31 | 17 | |
32 | 18 | } |
33 | 19 | |
34 | - compression_encoder_streambuf(icompression_encoder_ptr_type compressionEncoder, ostream_type& stream) | |
20 | + compression_encoder_streambuf(compression_encoder_interface_ptr compressionEncoder, std::ostream& stream) | |
35 | 21 | { |
36 | 22 | init(compressionEncoder, stream); |
37 | 23 | } |
38 | 24 | |
39 | - compression_encoder_streambuf(icompression_encoder_ptr_type compressionEncoder, compression_properties_interface& props, ostream_type& stream) | |
25 | + compression_encoder_streambuf(compression_encoder_interface_ptr compressionEncoder, compression_properties_interface& props, std::ostream& stream) | |
40 | 26 | { |
41 | 27 | init(compressionEncoder, props, stream); |
42 | 28 | } |
@@ -46,7 +32,7 @@ class compression_encoder_streambuf | ||
46 | 32 | sync(); |
47 | 33 | } |
48 | 34 | |
49 | - void init(icompression_encoder_ptr_type compressionEncoder, ostream_type& stream) | |
35 | + void init(compression_encoder_interface_ptr compressionEncoder, std::ostream& stream) | |
50 | 36 | { |
51 | 37 | _compressionEncoder = compressionEncoder; |
52 | 38 |
@@ -57,7 +43,7 @@ class compression_encoder_streambuf | ||
57 | 43 | this->setp(_compressionEncoder->get_buffer_begin(), _compressionEncoder->get_buffer_end() - 1); |
58 | 44 | } |
59 | 45 | |
60 | - void init(icompression_encoder_ptr_type compressionEncoder, compression_properties_interface& props, ostream_type& stream) | |
46 | + void init(compression_encoder_interface_ptr compressionEncoder, compression_properties_interface& props, std::ostream& stream) | |
61 | 47 | { |
62 | 48 | _compressionEncoder = compressionEncoder; |
63 | 49 |
@@ -115,5 +101,5 @@ class compression_encoder_streambuf | ||
115 | 101 | this->setp(_compressionEncoder->get_buffer_begin(), _compressionEncoder->get_buffer_end() - 1); |
116 | 102 | } |
117 | 103 | |
118 | - icompression_encoder_ptr_type _compressionEncoder; | |
104 | + compression_encoder_interface_ptr _compressionEncoder; | |
119 | 105 | }; |
@@ -5,38 +5,25 @@ | ||
5 | 5 | #include "../substream.h" |
6 | 6 | #include "../../extlibs/zlib/zlib.h" |
7 | 7 | |
8 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
9 | 8 | class crc32_streambuf |
10 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
9 | + : public std::streambuf | |
11 | 10 | { |
12 | 11 | public: |
13 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
14 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
15 | - | |
16 | - typedef typename base_type::char_type char_type; | |
17 | - typedef typename base_type::int_type int_type; | |
18 | - typedef typename base_type::pos_type pos_type; | |
19 | - typedef typename base_type::off_type off_type; | |
20 | - | |
21 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
22 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
23 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
24 | - | |
25 | 12 | crc32_streambuf() |
26 | 13 | { |
27 | 14 | |
28 | 15 | } |
29 | 16 | |
30 | - crc32_streambuf(istream_type& input) | |
17 | + crc32_streambuf(std::istream& input) | |
31 | 18 | { |
32 | 19 | init(input); |
33 | 20 | } |
34 | 21 | |
35 | - void init(istream_type& input) | |
22 | + void init(std::istream& input) | |
36 | 23 | { |
37 | 24 | _inputStream = &input; |
38 | 25 | |
39 | - ELEM_TYPE* endOfBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
26 | + char_type* endOfBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
40 | 27 | this->setg(endOfBuffer, endOfBuffer, endOfBuffer); |
41 | 28 | } |
42 | 29 |
@@ -69,13 +56,13 @@ class crc32_streambuf | ||
69 | 56 | } |
70 | 57 | |
71 | 58 | // set buffer pointers, increment current position |
72 | - ELEM_TYPE* base = _internalBufferPosition++; | |
59 | + char_type* base = _internalBufferPosition++; | |
73 | 60 | |
74 | 61 | // setting all pointers to the same position forces calling of this method each time, |
75 | 62 | // so crc32 really represents the checksum of what really has been read |
76 | 63 | this->setg(base, base, base + 1); |
77 | 64 | |
78 | - _crc32 = crc32(_crc32, reinterpret_cast<Bytef*>(this->gptr()), static_cast<uInt>(sizeof(ELEM_TYPE))); | |
65 | + _crc32 = crc32(_crc32, reinterpret_cast<Bytef*>(this->gptr()), static_cast<uInt>(sizeof(char_type))); | |
79 | 66 | |
80 | 67 | return traits_type::to_int_type(*this->gptr()); |
81 | 68 | } |
@@ -86,10 +73,10 @@ class crc32_streambuf | ||
86 | 73 | INTERNAL_BUFFER_SIZE = 1 << 15 |
87 | 74 | }; |
88 | 75 | |
89 | - ELEM_TYPE _internalBuffer[INTERNAL_BUFFER_SIZE]; | |
90 | - ELEM_TYPE* _internalBufferPosition = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
91 | - ELEM_TYPE* _internalBufferEnd = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
76 | + char_type _internalBuffer[INTERNAL_BUFFER_SIZE]; | |
77 | + char_type* _internalBufferPosition = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
78 | + char_type* _internalBufferEnd = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
92 | 79 | |
93 | - istream_type* _inputStream = nullptr; | |
80 | + std::istream* _inputStream = nullptr; | |
94 | 81 | uint32_t _crc32 = 0; |
95 | 82 | }; |
@@ -6,42 +6,28 @@ | ||
6 | 6 | |
7 | 7 | #include "../../encryption/encryption_interface.h" |
8 | 8 | |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | 9 | class encryption_decoder_streambuf |
11 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
10 | + : public std::streambuf | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
15 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
16 | - | |
17 | - typedef typename base_type::char_type char_type; | |
18 | - typedef typename base_type::int_type int_type; | |
19 | - typedef typename base_type::pos_type pos_type; | |
20 | - typedef typename base_type::off_type off_type; | |
21 | - | |
22 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
23 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
24 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
25 | - | |
26 | - typedef encryption_decoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> iencryption_decoder_type; | |
27 | - typedef std::shared_ptr<iencryption_decoder_type> iencryption_decoder_ptr_type; | |
13 | + typedef std::shared_ptr<encryption_decoder_interface> encryption_decoder_interface_ptr; | |
28 | 14 | |
29 | 15 | encryption_decoder_streambuf() |
30 | 16 | { |
31 | 17 | |
32 | 18 | } |
33 | 19 | |
34 | - encryption_decoder_streambuf(iencryption_decoder_ptr_type encryptionDecoder, istream_type& stream) | |
20 | + encryption_decoder_streambuf(encryption_decoder_interface_ptr encryptionDecoder, std::istream& stream) | |
35 | 21 | { |
36 | 22 | init(encryptionDecoder, stream); |
37 | 23 | } |
38 | 24 | |
39 | - encryption_decoder_streambuf(iencryption_decoder_ptr_type encryptionDecoder, encryption_properties_interface& props, istream_type& stream) | |
25 | + encryption_decoder_streambuf(encryption_decoder_interface_ptr encryptionDecoder, encryption_properties_interface& props, std::istream& stream) | |
40 | 26 | { |
41 | 27 | init(encryptionDecoder, props, stream); |
42 | 28 | } |
43 | 29 | |
44 | - void init(iencryption_decoder_ptr_type encryptionDecoder, istream_type& stream) | |
30 | + void init(encryption_decoder_interface_ptr encryptionDecoder, std::istream& stream) | |
45 | 31 | { |
46 | 32 | _encryptionDecoder = encryptionDecoder; |
47 | 33 |
@@ -52,7 +38,7 @@ class encryption_decoder_streambuf | ||
52 | 38 | this->setg(_encryptionDecoder->get_buffer_end(), _encryptionDecoder->get_buffer_end(), _encryptionDecoder->get_buffer_end()); |
53 | 39 | } |
54 | 40 | |
55 | - void init(iencryption_decoder_ptr_type encryptionDecoder, encryption_properties_interface& props, istream_type& stream) | |
41 | + void init(encryption_decoder_interface_ptr encryptionDecoder, encryption_properties_interface& props, std::istream& stream) | |
56 | 42 | { |
57 | 43 | _encryptionDecoder = encryptionDecoder; |
58 | 44 |
@@ -74,7 +60,7 @@ class encryption_decoder_streambuf | ||
74 | 60 | // buffer exhausted |
75 | 61 | if (this->gptr() >= this->egptr()) |
76 | 62 | { |
77 | - ELEM_TYPE* base = _encryptionDecoder->get_buffer_begin(); | |
63 | + char_type* base = _encryptionDecoder->get_buffer_begin(); | |
78 | 64 | |
79 | 65 | // how many bytes has been read |
80 | 66 | size_t n = _encryptionDecoder->decrypt_next(); |
@@ -92,5 +78,5 @@ class encryption_decoder_streambuf | ||
92 | 78 | } |
93 | 79 | |
94 | 80 | private: |
95 | - iencryption_decoder_ptr_type _encryptionDecoder; | |
81 | + encryption_decoder_interface_ptr _encryptionDecoder; | |
96 | 82 | }; |
@@ -6,37 +6,23 @@ | ||
6 | 6 | |
7 | 7 | #include "../../encryption/encryption_interface.h" |
8 | 8 | |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | 9 | class encryption_encoder_streambuf |
11 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
10 | + : public std::streambuf | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
15 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
16 | - | |
17 | - typedef typename base_type::char_type char_type; | |
18 | - typedef typename base_type::int_type int_type; | |
19 | - typedef typename base_type::pos_type pos_type; | |
20 | - typedef typename base_type::off_type off_type; | |
21 | - | |
22 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
23 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
24 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
25 | - | |
26 | - typedef encryption_encoder_interface_basic<ELEM_TYPE, TRAITS_TYPE> iencryption_encoder_type; | |
27 | - typedef std::shared_ptr<iencryption_encoder_type> iencryption_encoder_ptr_type; | |
13 | + typedef std::shared_ptr<encryption_encoder_interface> encryption_encoder_interface_ptr; | |
28 | 14 | |
29 | 15 | encryption_encoder_streambuf() |
30 | 16 | { |
31 | 17 | |
32 | 18 | } |
33 | 19 | |
34 | - encryption_encoder_streambuf(iencryption_encoder_ptr_type encryptionEncoder, ostream_type& stream) | |
20 | + encryption_encoder_streambuf(encryption_encoder_interface_ptr encryptionEncoder, std::ostream& stream) | |
35 | 21 | { |
36 | 22 | init(encryptionEncoder, stream); |
37 | 23 | } |
38 | 24 | |
39 | - encryption_encoder_streambuf(iencryption_encoder_ptr_type encryptionEncoder, encryption_properties_interface& props, ostream_type& stream) | |
25 | + encryption_encoder_streambuf(encryption_encoder_interface_ptr encryptionEncoder, encryption_properties_interface& props, std::ostream& stream) | |
40 | 26 | { |
41 | 27 | init(encryptionEncoder, props, stream); |
42 | 28 | } |
@@ -46,7 +32,7 @@ class encryption_encoder_streambuf | ||
46 | 32 | sync(); |
47 | 33 | } |
48 | 34 | |
49 | - void init(iencryption_encoder_ptr_type encryptionEncoder, ostream_type& stream) | |
35 | + void init(encryption_encoder_interface_ptr encryptionEncoder, std::ostream& stream) | |
50 | 36 | { |
51 | 37 | _encryptionEncoder = encryptionEncoder; |
52 | 38 |
@@ -57,7 +43,7 @@ class encryption_encoder_streambuf | ||
57 | 43 | this->setp(_encryptionEncoder->get_buffer_begin(), _encryptionEncoder->get_buffer_end() - 1); |
58 | 44 | } |
59 | 45 | |
60 | - void init(iencryption_encoder_ptr_type encryptionEncoder, encryption_properties_interface& props, ostream_type& stream) | |
46 | + void init(encryption_encoder_interface_ptr encryptionEncoder, encryption_properties_interface& props, std::ostream& stream) | |
61 | 47 | { |
62 | 48 | _encryptionEncoder = encryptionEncoder; |
63 | 49 |
@@ -115,5 +101,5 @@ class encryption_encoder_streambuf | ||
115 | 101 | this->setp(_encryptionEncoder->get_buffer_begin(), _encryptionEncoder->get_buffer_end() - 1); |
116 | 102 | } |
117 | 103 | |
118 | - iencryption_encoder_ptr_type _encryptionEncoder; | |
104 | + encryption_encoder_interface_ptr _encryptionEncoder; | |
119 | 105 | }; |
@@ -3,27 +3,14 @@ | ||
3 | 3 | #include <cstdint> |
4 | 4 | #include <cassert> |
5 | 5 | |
6 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
7 | 6 | class mem_streambuf |
8 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
7 | + : public std::streambuf | |
9 | 8 | { |
10 | 9 | public: |
11 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
12 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
13 | - | |
14 | - typedef typename base_type::char_type char_type; | |
15 | - typedef typename base_type::int_type int_type; | |
16 | - typedef typename base_type::pos_type pos_type; | |
17 | - typedef typename base_type::off_type off_type; | |
18 | - | |
19 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
20 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
21 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
22 | - | |
23 | - mem_streambuf(ELEM_TYPE* buffer, size_t length) | |
10 | + mem_streambuf(char_type* buffer, size_t length) | |
24 | 11 | { |
25 | 12 | // set stream buffer |
26 | - ELEM_TYPE* endOfBuffer = buffer + length; | |
13 | + char_type* endOfBuffer = buffer + length; | |
27 | 14 | this->setg(buffer, buffer, endOfBuffer); |
28 | 15 | this->setp(buffer, buffer, endOfBuffer); |
29 | 16 | } |
@@ -198,9 +185,9 @@ class mem_streambuf | ||
198 | 185 | } |
199 | 186 | |
200 | 187 | private: |
201 | - void setp(ELEM_TYPE* first, ELEM_TYPE* next, ELEM_TYPE* last) | |
188 | + void setp(char_type* first, char_type* next, char_type* last) | |
202 | 189 | { |
203 | - this->std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::setp(first, last); | |
190 | + this->std::streambuf::setp(first, last); | |
204 | 191 | this->pbump(static_cast<int>(next - first)); |
205 | 192 | } |
206 | 193 | }; |
@@ -1,23 +1,10 @@ | ||
1 | 1 | #pragma once |
2 | 2 | #include <streambuf> |
3 | 3 | |
4 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
5 | 4 | class null_streambuf |
6 | - : public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
5 | + : public std::streambuf | |
7 | 6 | { |
8 | 7 | public: |
9 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
10 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
11 | - | |
12 | - typedef typename base_type::char_type char_type; | |
13 | - typedef typename base_type::int_type int_type; | |
14 | - typedef typename base_type::pos_type pos_type; | |
15 | - typedef typename base_type::off_type off_type; | |
16 | - | |
17 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
18 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
19 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
20 | - | |
21 | 8 | null_streambuf() |
22 | 9 | { |
23 | 10 |
@@ -29,7 +16,7 @@ class null_streambuf | ||
29 | 16 | return 0; |
30 | 17 | } |
31 | 18 | |
32 | - std::streamsize xsputn(const ELEM_TYPE* ptr, std::streamsize count) override | |
19 | + std::streamsize xsputn(const char_type* ptr, std::streamsize count) override | |
33 | 20 | { |
34 | 21 | return count; |
35 | 22 | } |
@@ -3,43 +3,30 @@ | ||
3 | 3 | #include <istream> |
4 | 4 | #include <cstdint> |
5 | 5 | |
6 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
7 | -class sub_streambuf : | |
8 | - public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
6 | +class sub_streambuf | |
7 | + : public std::streambuf | |
9 | 8 | { |
10 | 9 | public: |
11 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
12 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
13 | - | |
14 | - typedef typename base_type::char_type char_type; | |
15 | - typedef typename base_type::int_type int_type; | |
16 | - typedef typename base_type::pos_type pos_type; | |
17 | - typedef typename base_type::off_type off_type; | |
18 | - | |
19 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
20 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
21 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
22 | - | |
23 | 10 | sub_streambuf() |
24 | 11 | { |
25 | 12 | |
26 | 13 | } |
27 | 14 | |
28 | - sub_streambuf(istream_type& input, pos_type startOffset, size_t length) | |
15 | + sub_streambuf(std::istream& input, pos_type startOffset, size_t length) | |
29 | 16 | { |
30 | 17 | init(input, startOffset, length); |
31 | 18 | } |
32 | 19 | |
33 | - void init(istream_type& input, pos_type startOffset, size_t length) | |
20 | + void init(std::istream& input, pos_type startOffset, size_t length) | |
34 | 21 | { |
35 | 22 | _inputStream = &input; |
36 | 23 | _startPosition = startOffset; |
37 | 24 | _currentPosition = startOffset; |
38 | 25 | _endPosition = startOffset + static_cast<pos_type>(length); |
39 | - _internalBuffer = new ELEM_TYPE[INTERNAL_BUFFER_SIZE]; | |
26 | + _internalBuffer = new char_type[INTERNAL_BUFFER_SIZE]; | |
40 | 27 | |
41 | 28 | // set stream buffer |
42 | - ELEM_TYPE* endOfOutputBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
29 | + char_type* endOfOutputBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
43 | 30 | this->setg(endOfOutputBuffer, endOfOutputBuffer, endOfOutputBuffer); |
44 | 31 | } |
45 | 32 |
@@ -59,7 +46,7 @@ class sub_streambuf : | ||
59 | 46 | // buffer exhausted |
60 | 47 | if (this->gptr() >= this->egptr()) |
61 | 48 | { |
62 | - ELEM_TYPE* base = _internalBuffer; | |
49 | + char_type* base = _internalBuffer; | |
63 | 50 | |
64 | 51 | _inputStream->seekg(_currentPosition, std::ios::beg); |
65 | 52 | _inputStream->read(_internalBuffer, std::min(static_cast<size_t>(INTERNAL_BUFFER_SIZE), static_cast<size_t>(_endPosition - _currentPosition))); |
@@ -92,7 +79,7 @@ class sub_streambuf : | ||
92 | 79 | _currentPosition = _startPosition + pos; |
93 | 80 | |
94 | 81 | // invalidate stream buffer |
95 | - ELEM_TYPE* endOfOutputBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
82 | + char_type* endOfOutputBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
96 | 83 | this->setg(endOfOutputBuffer, endOfOutputBuffer, endOfOutputBuffer); |
97 | 84 | |
98 | 85 | return pos_type(_inputStream->rdbuf()->pubseekpos(_startPosition + pos, which) - _startPosition); |
@@ -114,7 +101,7 @@ class sub_streambuf : | ||
114 | 101 | dir == std::ios::end ? _endPosition : 0; |
115 | 102 | |
116 | 103 | // invalidate stream buffer |
117 | - ELEM_TYPE* endOfOutputBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
104 | + char_type* endOfOutputBuffer = _internalBuffer + INTERNAL_BUFFER_SIZE; | |
118 | 105 | this->setg(endOfOutputBuffer, endOfOutputBuffer, endOfOutputBuffer); |
119 | 106 | |
120 | 107 | // set new current position |
@@ -129,10 +116,10 @@ class sub_streambuf : | ||
129 | 116 | INTERNAL_BUFFER_SIZE = 1 << 15 |
130 | 117 | }; |
131 | 118 | |
132 | - ELEM_TYPE* _internalBuffer = nullptr; | |
119 | + char_type* _internalBuffer = nullptr; | |
133 | 120 | |
134 | - istream_type* _inputStream = nullptr; | |
135 | - pos_type _startPosition = 0; | |
136 | - pos_type _currentPosition = 0; | |
137 | - pos_type _endPosition = 0; | |
121 | + std::istream* _inputStream = nullptr; | |
122 | + pos_type _startPosition = 0; | |
123 | + pos_type _currentPosition = 0; | |
124 | + pos_type _endPosition = 0; | |
138 | 125 | }; |
@@ -1,31 +1,19 @@ | ||
1 | 1 | #pragma once |
2 | 2 | #include <streambuf> |
3 | 3 | #include <algorithm> |
4 | +#include <vector> | |
4 | 5 | |
5 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
6 | -class tee_streambuf: | |
7 | - public std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> | |
6 | +class tee_streambuf | |
7 | + : public std::streambuf | |
8 | 8 | { |
9 | 9 | public: |
10 | - typedef std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE> base_type; | |
11 | - typedef typename std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>::traits_type traits_type; | |
12 | - | |
13 | - typedef typename base_type::char_type char_type; | |
14 | - typedef typename base_type::int_type int_type; | |
15 | - typedef typename base_type::pos_type pos_type; | |
16 | - typedef typename base_type::off_type off_type; | |
17 | - | |
18 | - typedef std::basic_ios<ELEM_TYPE, TRAITS_TYPE> stream_type; | |
19 | - typedef std::basic_istream<ELEM_TYPE, TRAITS_TYPE> istream_type; | |
20 | - typedef std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> ostream_type; | |
21 | - | |
22 | - tee_streambuf& bind(base_type* sb) | |
10 | + tee_streambuf& bind(std::streambuf* sb) | |
23 | 11 | { |
24 | 12 | _sbCollection.push_back(sb); |
25 | 13 | return *this; |
26 | 14 | } |
27 | 15 | |
28 | - tee_streambuf& bind(ostream_type& stream) | |
16 | + tee_streambuf& bind(std::ostream& stream) | |
29 | 17 | { |
30 | 18 | _sbCollection.push_back(stream.rdbuf()); |
31 | 19 | return *this; |
@@ -63,5 +51,5 @@ class tee_streambuf: | ||
63 | 51 | } |
64 | 52 | |
65 | 53 | private: |
66 | - std::vector<base_type*> _sbCollection; | |
54 | + std::vector<std::streambuf*> _sbCollection; | |
67 | 55 | }; |
@@ -6,39 +6,36 @@ | ||
6 | 6 | * \brief Basic input substream. Creates a virtual stream over an existing input stream. |
7 | 7 | * The substream starts at the position 0 and continues until EOF or the specified length. |
8 | 8 | */ |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | -class basic_isubstream | |
11 | - : public std::basic_istream<ELEM_TYPE, TRAITS_TYPE> | |
9 | +class isubstream | |
10 | + : public std::istream | |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef typename std::basic_istream<ELEM_TYPE, TRAITS_TYPE>::pos_type pos_type; | |
15 | - | |
16 | - basic_isubstream() | |
17 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_subStreambuf) | |
13 | + isubstream() | |
14 | + : std::istream(&_subStreambuf) | |
18 | 15 | { |
19 | 16 | |
20 | 17 | } |
21 | 18 | |
22 | - basic_isubstream(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& input, pos_type startOffset = 0) | |
23 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_subStreambuf) | |
19 | + isubstream(std::istream& input, pos_type startOffset = 0) | |
20 | + : std::istream(&_subStreambuf) | |
24 | 21 | , _subStreambuf(input, startOffset, static_cast<size_t>(-1)) |
25 | 22 | { |
26 | 23 | |
27 | 24 | } |
28 | 25 | |
29 | - basic_isubstream(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& input, pos_type startOffset, size_t length) | |
30 | - : std::basic_istream<ELEM_TYPE, TRAITS_TYPE>(&_subStreambuf) | |
26 | + isubstream(std::istream& input, pos_type startOffset, size_t length) | |
27 | + : std::istream(&_subStreambuf) | |
31 | 28 | , _subStreambuf(input, startOffset, length) |
32 | 29 | { |
33 | 30 | |
34 | 31 | } |
35 | 32 | |
36 | - void init(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& input, pos_type startOffset = 0) | |
33 | + void init(std::istream& input, pos_type startOffset = 0) | |
37 | 34 | { |
38 | 35 | _subStreambuf.init(input, startOffset, static_cast<size_t>(-1)); |
39 | 36 | } |
40 | 37 | |
41 | - void init(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& input, pos_type startOffset, size_t length) | |
38 | + void init(std::istream& input, pos_type startOffset, size_t length) | |
42 | 39 | { |
43 | 40 | _subStreambuf.init(input, startOffset, length); |
44 | 41 | } |
@@ -49,11 +46,5 @@ class basic_isubstream | ||
49 | 46 | } |
50 | 47 | |
51 | 48 | private: |
52 | - sub_streambuf<ELEM_TYPE, TRAITS_TYPE> _subStreambuf; | |
49 | + sub_streambuf _subStreambuf; | |
53 | 50 | }; |
54 | - | |
55 | -////////////////////////////////////////////////////////////////////////// | |
56 | - | |
57 | -typedef basic_isubstream<uint8_t, std::char_traits<uint8_t>> byte_isubstream; | |
58 | -typedef basic_isubstream<char, std::char_traits<char>> isubstream; | |
59 | -typedef basic_isubstream<wchar_t, std::char_traits<wchar_t>> wisubstream; |
@@ -1,55 +1,47 @@ | ||
1 | 1 | #pragma once |
2 | 2 | #include <ostream> |
3 | -#include <cstdint> | |
4 | 3 | #include "streambuffs/tee_streambuff.h" |
5 | 4 | |
6 | 5 | /** |
7 | 6 | * \brief Basic teestream. Distributes the input data into every bound output stream. |
8 | 7 | */ |
9 | -template <typename ELEM_TYPE, typename TRAITS_TYPE> | |
10 | -class basic_teestream | |
11 | - : public std::basic_ostream<ELEM_TYPE, TRAITS_TYPE> | |
8 | +class teestream | |
9 | + : public std::ostream | |
12 | 10 | { |
13 | 11 | public: |
14 | - basic_teestream() | |
15 | - : std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>(&_teeStreambuf) | |
12 | + teestream() | |
13 | + : std::ostream(&_teeStreambuf) | |
16 | 14 | { |
17 | 15 | |
18 | 16 | } |
19 | 17 | |
20 | - basic_teestream(basic_teestream<ELEM_TYPE, TRAITS_TYPE>&& other) | |
21 | - : basic_teestream() | |
18 | + teestream(teestream&& other) | |
19 | + : teestream() | |
22 | 20 | { |
23 | 21 | _teeStreambuf = std::move(other._teeStreambuf); |
24 | 22 | this->swap(other); |
25 | 23 | } |
26 | 24 | |
27 | - basic_teestream& bind(std::basic_streambuf<ELEM_TYPE, TRAITS_TYPE>* sb) | |
25 | + teestream& bind(std::streambuf* sb) | |
28 | 26 | { |
29 | 27 | _teeStreambuf.bind(sb); |
30 | 28 | return *this; |
31 | 29 | } |
32 | 30 | |
33 | - basic_teestream& bind(std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>& stream) | |
31 | + teestream& bind(std::ostream& stream) | |
34 | 32 | { |
35 | 33 | _teeStreambuf.bind(stream); |
36 | 34 | return *this; |
37 | 35 | } |
38 | 36 | |
39 | - basic_teestream move() | |
37 | + teestream move() | |
40 | 38 | { |
41 | 39 | return std::move(*this); |
42 | 40 | } |
43 | 41 | |
44 | 42 | private: |
45 | - basic_teestream(const basic_teestream&) = delete; | |
46 | - basic_teestream& operator = (const basic_teestream&) = delete; | |
43 | + teestream(const teestream&) = delete; | |
44 | + teestream& operator = (const teestream&) = delete; | |
47 | 45 | |
48 | - tee_streambuf<ELEM_TYPE, TRAITS_TYPE> _teeStreambuf; | |
46 | + tee_streambuf _teeStreambuf; | |
49 | 47 | }; |
50 | - | |
51 | -////////////////////////////////////////////////////////////////////////// | |
52 | - | |
53 | -typedef basic_teestream<uint8_t, std::char_traits<uint8_t>> byte_teestream; | |
54 | -typedef basic_teestream<char, std::char_traits<char>> teestream; | |
55 | -typedef basic_teestream<wchar_t, std::char_traits<wchar_t>> wteestream; |