• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision78e54ff3437b86dd432f10cda34a481e95961d22 (tree)
Zeit2014-05-19 05:10:30
Autorwbenny <w.benny@outl...>
Commiterwbenny

Log Message

* Remove dependency on char_type in non-stream classes and use uint8_t instead.
* Move serialize/deserialize functions into utils::stream namespace.

Ändern Zusammenfassung

Diff

--- a/Source/Sample/Main.cpp
+++ b/Source/Sample/Main.cpp
@@ -114,7 +114,7 @@ TEST_METHOD(Sample_ZipArchive_Stream_Deferred_Comment)
114114 //// this method is only useful for password protected files
115115 //entry->UseDataDescriptor();
116116
117- StoreMethod::Ptr ctx = StoreMethod::Create();
117+ LzmaMethod::Ptr ctx = LzmaMethod::Create();
118118 AesCryptoMethod::Ptr encryptionCtx = AesCryptoMethod::Create();
119119 encryptionCtx->SetPassword("gogo");
120120 ctx->SetEncryptionMethod(encryptionCtx);
--- a/Source/Sample/Sample.vcxproj
+++ b/Source/Sample/Sample.vcxproj
@@ -94,7 +94,7 @@
9494 <Optimization>Disabled</Optimization>
9595 <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9696 <DisableSpecificWarnings>4250;4996</DisableSpecificWarnings>
97- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
97+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
9898 </ClCompile>
9999 <Link>
100100 <SubSystem>Console</SubSystem>
@@ -110,6 +110,7 @@
110110 <Optimization>Disabled</Optimization>
111111 <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112112 <DisableSpecificWarnings>4250;4996</DisableSpecificWarnings>
113+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
113114 </ClCompile>
114115 <Link>
115116 <SubSystem>Console</SubSystem>
--- a/Source/ZipLib/ZipArchive.cpp
+++ b/Source/ZipLib/ZipArchive.cpp
@@ -1,5 +1,5 @@
11 #include "ZipArchive.h"
2-#include "streams/serialization.h"
2+#include "utils/stream/serialization.h"
33
44 #include <algorithm>
55 #include <cassert>
@@ -197,7 +197,7 @@ bool ZipArchive::SeekToSignature(uint32_t signature, SeekDirection direction)
197197
198198 while (!_zipStream->eof() && !_zipStream->fail())
199199 {
200- deserialize(*_zipStream, buffer);
200+ utils::stream::deserialize(*_zipStream, buffer);
201201
202202 if (buffer == signature)
203203 {
--- a/Source/ZipLib/ZipLib.vcxproj
+++ b/Source/ZipLib/ZipLib.vcxproj
@@ -79,7 +79,6 @@
7979 <ClInclude Include="streams\encryption_encoder_stream.h" />
8080 <ClInclude Include="streams\memstream.h" />
8181 <ClInclude Include="streams\nullstream.h" />
82- <ClInclude Include="streams\serialization.h" />
8382 <ClInclude Include="streams\streambuffs\audit_streambuf.h" />
8483 <ClInclude Include="streams\streambuffs\compression_decoder_streambuf.h" />
8584 <ClInclude Include="streams\streambuffs\compression_encoder_streambuf.h" />
@@ -93,6 +92,8 @@
9392 <ClInclude Include="streams\substream.h" />
9493 <ClInclude Include="streams\teestream.h" />
9594 <ClInclude Include="utils\enum_utils.h" />
95+ <ClInclude Include="utils\stream\copy.h" />
96+ <ClInclude Include="utils\stream\serialization.h" />
9697 <ClInclude Include="utils\stream_utils.h" />
9798 <ClInclude Include="utils\time_utils.h" />
9899 <ClInclude Include="ZipArchive.h" />
@@ -197,6 +198,7 @@
197198 <Optimization>Disabled</Optimization>
198199 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
199200 <DisableSpecificWarnings>4996</DisableSpecificWarnings>
201+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
200202 </ClCompile>
201203 <Link>
202204 <SubSystem>Windows</SubSystem>
@@ -211,6 +213,7 @@
211213 <Optimization>Disabled</Optimization>
212214 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
213215 <DisableSpecificWarnings>4996</DisableSpecificWarnings>
216+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
214217 </ClCompile>
215218 <Link>
216219 <SubSystem>Windows</SubSystem>
--- a/Source/ZipLib/ZipLib.vcxproj.filters
+++ b/Source/ZipLib/ZipLib.vcxproj.filters
@@ -85,6 +85,9 @@
8585 <Filter Include="Header Files\methods\encryption\detail">
8686 <UniqueIdentifier>{fdd8531d-8da9-439a-bde5-24b55515a5c9}</UniqueIdentifier>
8787 </Filter>
88+ <Filter Include="Header Files\utils\stream">
89+ <UniqueIdentifier>{7aa687c2-d8de-4cdb-a3fb-20076486838b}</UniqueIdentifier>
90+ </Filter>
8891 </ItemGroup>
8992 <ItemGroup>
9093 <ClInclude Include="ZipFile.h">
@@ -135,9 +138,6 @@
135138 <ClInclude Include="streams\memstream.h">
136139 <Filter>Header Files\streams</Filter>
137140 </ClInclude>
138- <ClInclude Include="streams\serialization.h">
139- <Filter>Header Files\streams</Filter>
140- </ClInclude>
141141 <ClInclude Include="streams\substream.h">
142142 <Filter>Header Files\streams</Filter>
143143 </ClInclude>
@@ -324,6 +324,12 @@
324324 <ClInclude Include="compression\bzip2\bzip2_properties.h">
325325 <Filter>Header Files\compression\bzip2</Filter>
326326 </ClInclude>
327+ <ClInclude Include="utils\stream\copy.h">
328+ <Filter>Header Files\utils\stream</Filter>
329+ </ClInclude>
330+ <ClInclude Include="utils\stream\serialization.h">
331+ <Filter>Header Files\utils\stream</Filter>
332+ </ClInclude>
327333 </ItemGroup>
328334 <ItemGroup>
329335 <ClCompile Include="ZipFile.cpp">
--- a/Source/ZipLib/compression/bzip2/bzip2_decoder.h
+++ b/Source/ZipLib/compression/bzip2/bzip2_decoder.h
@@ -1,8 +1,7 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
42 #include "bzip2_properties.h"
5-
3+#include "../compression_interface.h"
4+#include "../../utils/stream/serialization.h"
65 #include "../../extlibs/bzip2/bzlib.h"
76
87 #include <cstdint>
@@ -45,17 +44,17 @@ class bzip2_decoder
4544 _bufferCapacity = bzip2Props.BufferCapacity;
4645
4746 uninit_buffers();
48- _inputBuffer = new char_type[_bufferCapacity];
49- _outputBuffer = new char_type[_bufferCapacity];
47+ _inputBuffer = new uint8_t[_bufferCapacity];
48+ _outputBuffer = new uint8_t[_bufferCapacity];
5049
5150 // init bzip2
52- _bzstream.bzalloc = nullptr;
53- _bzstream.bzfree = nullptr;
54- _bzstream.opaque = nullptr;
51+ _bzstream.bzalloc = nullptr;
52+ _bzstream.bzfree = nullptr;
53+ _bzstream.opaque = nullptr;
5554
56- _bzstream.next_in = nullptr;
57- _bzstream.next_out = nullptr;
58- _bzstream.avail_in = 0;
55+ _bzstream.next_in = nullptr;
56+ _bzstream.next_out = nullptr;
57+ _bzstream.avail_in = 0;
5958 _bzstream.avail_out = (unsigned int)-1; // force first load of data
6059
6160 // no verbosity & do not use small memory model
@@ -67,12 +66,12 @@ class bzip2_decoder
6766 return (_inputBuffer != nullptr && _outputBuffer != nullptr);
6867 }
6968
70- char_type* get_buffer_begin() override
69+ uint8_t* get_buffer_begin() override
7170 {
7271 return _outputBuffer;
7372 }
7473
75- char_type* get_buffer_end() override
74+ uint8_t* get_buffer_end() override
7675 {
7776 return _outputBuffer + _outputBufferSize;
7877 }
@@ -139,7 +138,7 @@ class bzip2_decoder
139138 void read_next()
140139 {
141140 // read next bytes from input stream
142- _stream->read(_inputBuffer, _bufferCapacity);
141+ utils::stream::deserialize(*_stream, _inputBuffer, _bufferCapacity);
143142
144143 // set the size of buffer
145144 _inputBufferSize = static_cast<size_t>(_stream->gcount());
@@ -162,6 +161,6 @@ class bzip2_decoder
162161 size_t _bufferCapacity = 0;
163162 size_t _inputBufferSize = 0; // how many bytes are read in the input buffer
164163 size_t _outputBufferSize = 0; // how many bytes are written in 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
164+ uint8_t* _inputBuffer = nullptr; // pointer to the start of the input buffer
165+ uint8_t* _outputBuffer = nullptr; // pointer to the start of the output buffer
167166 };
--- a/Source/ZipLib/compression/bzip2/bzip2_encoder.h
+++ b/Source/ZipLib/compression/bzip2/bzip2_encoder.h
@@ -1,8 +1,7 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
42 #include "bzip2_properties.h"
5-
3+#include "../compression_interface.h"
4+#include "../../utils/stream/serialization.h"
65 #include "../../extlibs/bzip2/bzlib.h"
76
87 #include <cstdint>
@@ -41,17 +40,17 @@ class bzip2_encoder
4140 _bufferCapacity = bz2Props.BufferCapacity;
4241
4342 uninit_buffers();
44- _inputBuffer = new char_type[_bufferCapacity];
45- _outputBuffer = new char_type[_bufferCapacity];
43+ _inputBuffer = new uint8_t[_bufferCapacity];
44+ _outputBuffer = new uint8_t[_bufferCapacity];
4645
4746 // init bzip2
48- _bzstream.bzalloc = nullptr;
49- _bzstream.bzfree = nullptr;
50- _bzstream.opaque = nullptr;
47+ _bzstream.bzalloc = nullptr;
48+ _bzstream.bzfree = nullptr;
49+ _bzstream.opaque = nullptr;
5150
52- _bzstream.next_in = nullptr;
53- _bzstream.next_out = nullptr;
54- _bzstream.avail_in = 0;
51+ _bzstream.next_in = nullptr;
52+ _bzstream.next_out = nullptr;
53+ _bzstream.avail_in = 0;
5554 _bzstream.avail_out = 0;
5655
5756 _lastError = BZ2_bzCompressInit(&_bzstream, bz2Props.BlockSize, 0, bz2Props.WorkFactor);
@@ -62,12 +61,12 @@ class bzip2_encoder
6261 return _stream != nullptr;
6362 }
6463
65- char_type* get_buffer_begin() override
64+ uint8_t* get_buffer_begin() override
6665 {
6766 return _inputBuffer;
6867 }
6968
70- char_type* get_buffer_end() override
69+ uint8_t* get_buffer_end() override
7170 {
7271 return _inputBuffer + _bufferCapacity;
7372 }
@@ -93,7 +92,7 @@ class bzip2_encoder
9392
9493 if (have > 0)
9594 {
96- _stream->write(_outputBuffer, have);
95+ utils::stream::serialize(*_stream, _outputBuffer, have);
9796 }
9897 } while (_bzstream.avail_out == 0);
9998 }
@@ -121,6 +120,6 @@ class bzip2_encoder
121120 std::ostream* _stream = nullptr;
122121
123122 size_t _bufferCapacity = 0;
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
123+ uint8_t* _inputBuffer = nullptr; // pointer to the start of the input buffer
124+ uint8_t* _outputBuffer = nullptr; // pointer to the start of the output buffer
126125 };
--- a/Source/ZipLib/compression/compression_interface.h
+++ b/Source/ZipLib/compression/compression_interface.h
@@ -19,14 +19,12 @@ struct compression_properties_interface
1919 class compression_interface
2020 {
2121 public:
22- typedef char char_type;
23-
2422 virtual ~compression_interface() { }
2523
2624 virtual bool is_init() const = 0;
2725
28- virtual char_type* get_buffer_begin() = 0;
29- virtual char_type* get_buffer_end() = 0;
26+ virtual uint8_t* get_buffer_begin() = 0;
27+ virtual uint8_t* get_buffer_end() = 0;
3028 };
3129
3230 class compression_encoder_interface
--- a/Source/ZipLib/compression/deflate/deflate_decoder.h
+++ b/Source/ZipLib/compression/deflate/deflate_decoder.h
@@ -1,9 +1,8 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
42 #include "deflate_properties.h"
5-
6-#include "../../extlibs/zlib/zlib.h"
3+#include "../compression_interface.h"
4+#include "../../utils/stream/serialization.h"
5+#include "../../extlibs/zlib/zlib.h"
76
87 #include <cstdint>
98
@@ -45,18 +44,18 @@ class deflate_decoder
4544 _bufferCapacity = deflateProps.BufferCapacity;
4645
4746 uninit_buffers();
48- _inputBuffer = new char_type[_bufferCapacity];
49- _outputBuffer = new char_type[_bufferCapacity];
47+ _inputBuffer = new uint8_t[_bufferCapacity];
48+ _outputBuffer = new uint8_t[_bufferCapacity];
5049
5150 // init deflate
52- _zstream.zalloc = nullptr;
53- _zstream.zfree = nullptr;
54- _zstream.opaque = nullptr;
51+ _zstream.zalloc = nullptr;
52+ _zstream.zfree = nullptr;
53+ _zstream.opaque = nullptr;
5554
56- _zstream.next_in = nullptr;
57- _zstream.next_out = nullptr;
58- _zstream.avail_in = 0;
59- _zstream.avail_out = uInt(-1); // force first load of data
55+ _zstream.next_in = nullptr;
56+ _zstream.next_out = nullptr;
57+ _zstream.avail_in = 0;
58+ _zstream.avail_out = uInt(-1); // force first load of data
6059
6160 inflateInit2(&_zstream, -MAX_WBITS);
6261 }
@@ -66,12 +65,12 @@ class deflate_decoder
6665 return (_inputBuffer != nullptr && _outputBuffer != nullptr);
6766 }
6867
69- char_type* get_buffer_begin() override
68+ uint8_t* get_buffer_begin() override
7069 {
7170 return _outputBuffer;
7271 }
7372
74- char_type* get_buffer_end() override
73+ uint8_t* get_buffer_end() override
7574 {
7675 return _outputBuffer + _outputBufferSize;
7776 }
@@ -138,7 +137,7 @@ class deflate_decoder
138137 void read_next()
139138 {
140139 // read next bytes from input stream
141- _stream->read(_inputBuffer, _bufferCapacity);
140+ utils::stream::deserialize(*_stream, _inputBuffer, _bufferCapacity);
142141
143142 // set the size of buffer
144143 _inputBufferSize = static_cast<size_t>(_stream->gcount());
@@ -161,6 +160,6 @@ class deflate_decoder
161160 size_t _bufferCapacity = 0;
162161 size_t _inputBufferSize = 0; // how many bytes are read in the input buffer
163162 size_t _outputBufferSize = 0; // how many bytes are written in 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
163+ uint8_t* _inputBuffer = nullptr; // pointer to the start of the input buffer
164+ uint8_t* _outputBuffer = nullptr; // pointer to the start of the output buffer
166165 };
--- a/Source/ZipLib/compression/deflate/deflate_encoder.h
+++ b/Source/ZipLib/compression/deflate/deflate_encoder.h
@@ -1,8 +1,7 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
42 #include "deflate_properties.h"
5-
3+#include "../compression_interface.h"
4+#include "../../utils/stream/serialization.h"
65 #include "../../extlibs/zlib/zlib.h"
76
87 #include <cstdint>
@@ -41,18 +40,18 @@ class deflate_encoder
4140 _bufferCapacity = deflateProps.BufferCapacity;
4241
4342 uninit_buffers();
44- _inputBuffer = new char_type[_bufferCapacity];
45- _outputBuffer = new char_type[_bufferCapacity];
43+ _inputBuffer = new uint8_t[_bufferCapacity];
44+ _outputBuffer = new uint8_t[_bufferCapacity];
4645
4746 // init deflate
48- _zstream.zalloc = nullptr;
49- _zstream.zfree = nullptr;
50- _zstream.opaque = nullptr;
47+ _zstream.zalloc = nullptr;
48+ _zstream.zfree = nullptr;
49+ _zstream.opaque = nullptr;
5150
52- _zstream.next_in = nullptr;
53- _zstream.next_out = nullptr;
54- _zstream.avail_in = 0;
55- _zstream.avail_out = 0;
51+ _zstream.next_in = nullptr;
52+ _zstream.next_out = nullptr;
53+ _zstream.avail_in = 0;
54+ _zstream.avail_out = 0;
5655
5756 deflateInit2(&_zstream, deflateProps.CompressionLevel, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
5857 }
@@ -62,12 +61,12 @@ class deflate_encoder
6261 return _stream != nullptr;
6362 }
6463
65- char_type* get_buffer_begin() override
64+ uint8_t* get_buffer_begin() override
6665 {
6766 return _inputBuffer;
6867 }
6968
70- char_type* get_buffer_end() override
69+ uint8_t* get_buffer_end() override
7170 {
7271 return _inputBuffer + _bufferCapacity;
7372 }
@@ -93,7 +92,7 @@ class deflate_encoder
9392
9493 if (have > 0)
9594 {
96- _stream->write(_outputBuffer, have);
95+ utils::stream::serialize(*_stream, _outputBuffer, have);
9796 }
9897 } while (_zstream.avail_out == 0);
9998 }
@@ -121,6 +120,6 @@ class deflate_encoder
121120 std::ostream* _stream = nullptr;
122121
123122 size_t _bufferCapacity = 0;
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
123+ uint8_t* _inputBuffer = nullptr; // pointer to the start of the input buffer
124+ uint8_t* _outputBuffer = nullptr; // pointer to the start of the output buffer
126125 };
--- a/Source/ZipLib/compression/lzma/detail/lzma_in_stream.h
+++ b/Source/ZipLib/compression/lzma/detail/lzma_in_stream.h
@@ -15,7 +15,6 @@ namespace detail
1515 public:
1616 friend class ::lzma_encoder;
1717
18- typedef char char_type;
1918 typedef std::condition_variable event_type;
2019 typedef std::mutex mutex_type;
2120
@@ -33,8 +32,8 @@ namespace detail
3332 size_t lastBytesRead = _bytesRead;
3433
3534 // set buffer pointer and get required size
36- _internalInputBuffer = static_cast<char_type*>(buf);
37- _internalBufferSize = *size / sizeof(char_type);
35+ _internalInputBuffer = static_cast<uint8_t*>(buf);
36+ _internalBufferSize = *size;
3837
3938 // give control back to the main thread
4039 set_event();
@@ -59,13 +58,13 @@ namespace detail
5958 private:
6059 size_t _bytesRead = 0;
6160 size_t _internalBufferSize = 0;
62- char_type* _internalInputBuffer = nullptr;
61+ uint8_t* _internalInputBuffer = nullptr;
6362 event_type _event;
6463 mutex_type _mutex;
6564 bool _endOfStream = false;
6665
67- char_type* get_buffer_begin() { return _internalInputBuffer; }
68- char_type* get_buffer_end() { return _internalInputBuffer + _internalBufferSize; }
66+ uint8_t* get_buffer_begin() { return _internalInputBuffer; }
67+ uint8_t* get_buffer_end() { return _internalInputBuffer + _internalBufferSize; }
6968
7069 void set_event()
7170 {
--- a/Source/ZipLib/compression/lzma/detail/lzma_out_stream.h
+++ b/Source/ZipLib/compression/lzma/detail/lzma_out_stream.h
@@ -1,4 +1,5 @@
11 #pragma once
2+#include "../../../utils/stream/serialization.h"
23 #include "../../../extlibs/lzma/Types.h"
34
45 namespace detail
@@ -7,8 +8,6 @@ namespace detail
78 : public ISeqOutStream
89 {
910 public:
10- typedef char char_type;
11-
1211 lzma_out_stream()
1312 {
1413 this->Write = [](void* p, const void* buf, size_t size)
@@ -21,7 +20,7 @@ namespace detail
2120 size_t write(const void* buf, size_t size)
2221 {
2322 auto currentPosition = _stream->tellp();
24- _stream->write(reinterpret_cast<const char_type*>(buf), size);
23+ utils::stream::serialize(*_stream, buf, size);
2524
2625 size_t delta = static_cast<size_t>(_stream->tellp()) - static_cast<size_t>(currentPosition);
2726
--- a/Source/ZipLib/compression/lzma/lzma_decoder.h
+++ b/Source/ZipLib/compression/lzma/lzma_decoder.h
@@ -1,9 +1,8 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
4-#include "detail/lzma_alloc.h"
52 #include "lzma_properties.h"
6-
3+#include "detail/lzma_alloc.h"
4+#include "../compression_interface.h"
5+#include "../../utils/stream/serialization.h"
76 #include "../../extlibs/lzma/LzmaDec.h"
87
98 #include <cstdint>
@@ -46,12 +45,12 @@ class lzma_decoder
4645 _bufferCapacity = lzmaProps.BufferCapacity;
4746
4847 uninit_buffers();
49- _inputBuffer = new char_type[_bufferCapacity];
50- _outputBuffer = new char_type[_bufferCapacity];
48+ _inputBuffer = new uint8_t[_bufferCapacity];
49+ _outputBuffer = new uint8_t[_bufferCapacity];
5150
5251 // read lzma header
53- Byte header[LZMA_PROPS_SIZE + 4];
54- _stream->read(reinterpret_cast<char_type*>(header), sizeof(header) / sizeof(char_type));
52+ Byte header[detail::lzma_header::HEADER_SIZE];
53+ utils::stream::deserialize(*_stream, header);
5554
5655 // init lzma
5756 LzmaDec_Allocate(&_handle, &header[4], LZMA_PROPS_SIZE, &_alloc);
@@ -63,12 +62,12 @@ class lzma_decoder
6362 return (_inputBuffer != nullptr && _outputBuffer != nullptr);
6463 }
6564
66- char_type* get_buffer_begin() override
65+ uint8_t* get_buffer_begin() override
6766 {
6867 return _outputBuffer;
6968 }
7069
71- char_type* get_buffer_end() override
70+ uint8_t* get_buffer_end() override
7271 {
7372 return _outputBuffer + _outputBufferSize;
7473 }
@@ -122,7 +121,7 @@ class lzma_decoder
122121 void read_next()
123122 {
124123 // read next bytes from input stream
125- _stream->read(_inputBuffer, _bufferCapacity);
124+ utils::stream::deserialize(*_stream, _inputBuffer, _bufferCapacity);
126125
127126 // set the size of buffer
128127 _inputBufferSize = static_cast<size_t>(_stream->gcount());
@@ -143,6 +142,6 @@ class lzma_decoder
143142 size_t _bufferCapacity = 0;
144143 size_t _inputBufferSize = 0; // how many bytes are read in the input buffer
145144 size_t _outputBufferSize = 0; // how many bytes are written in 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
145+ uint8_t* _inputBuffer = nullptr; // pointer to the start of the input buffer
146+ uint8_t* _outputBuffer = nullptr; // pointer to the start of the output buffer
148147 };
--- a/Source/ZipLib/compression/lzma/lzma_encoder.h
+++ b/Source/ZipLib/compression/lzma/lzma_encoder.h
@@ -1,13 +1,15 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
42 #include "lzma_properties.h"
3+
54 #include "detail/lzma_alloc.h"
65 #include "detail/lzma_handle.h"
76 #include "detail/lzma_header.h"
87 #include "detail/lzma_in_stream.h"
98 #include "detail/lzma_out_stream.h"
109
10+#include "../compression_interface.h"
11+#include "../../utils/stream/serialization.h"
12+
1113 #include <ostream>
1214 #include <thread>
1315 #include <cstdint>
@@ -50,12 +52,12 @@ class lzma_encoder
5052 return &_ostream.get_stream() != nullptr;
5153 }
5254
53- char_type* get_buffer_begin() override
55+ uint8_t* get_buffer_begin() override
5456 {
5557 return _istream.get_buffer_begin();
5658 }
5759
58- char_type* get_buffer_end() override
60+ uint8_t* get_buffer_end() override
5961 {
6062 return _istream.get_buffer_end();
6163 }
--- a/Source/ZipLib/compression/store/store_decoder.h
+++ b/Source/ZipLib/compression/store/store_decoder.h
@@ -1,9 +1,8 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
42 #include "store_properties.h"
5-
3+#include "../compression_interface.h"
64 #include "../../streams/crc32stream.h"
5+#include "../../utils/stream/serialization.h"
76 #include "../../extlibs/zlib/zlib.h"
87
98 #include <cstdint>
@@ -44,7 +43,7 @@ class store_decoder
4443 _bufferCapacity = storeProps.BufferCapacity;
4544
4645 uninit_buffers();
47- _outputBuffer = new char_type[_bufferCapacity];
46+ _outputBuffer = new uint8_t[_bufferCapacity];
4847 }
4948
5049 bool is_init() const override
@@ -52,12 +51,12 @@ class store_decoder
5251 return (_outputBuffer != nullptr);
5352 }
5453
55- char_type* get_buffer_begin() override
54+ uint8_t* get_buffer_begin() override
5655 {
5756 return _outputBuffer;
5857 }
5958
60- char_type* get_buffer_end() override
59+ uint8_t* get_buffer_end() override
6160 {
6261 return _outputBuffer + _outputBufferSize;
6362 }
@@ -65,7 +64,7 @@ class store_decoder
6564 size_t decode_next() override
6665 {
6766 // read next bytes from input stream
68- _stream->read(_outputBuffer, _bufferCapacity);
67+ utils::stream::deserialize(*_stream, _outputBuffer, _bufferCapacity);
6968
7069 // set the size of buffer
7170 _outputBufferSize = static_cast<size_t>(_stream->gcount());
@@ -84,5 +83,5 @@ class store_decoder
8483
8584 size_t _bufferCapacity = 0;
8685 size_t _outputBufferSize = 0; // how many bytes are written in the output buffer
87- char_type* _outputBuffer = nullptr; // pointer to the start of the output buffer
86+ uint8_t* _outputBuffer = nullptr; // pointer to the start of the output buffer
8887 };
--- a/Source/ZipLib/compression/store/store_encoder.h
+++ b/Source/ZipLib/compression/store/store_encoder.h
@@ -1,9 +1,8 @@
11 #pragma once
2-#include "../compression_interface.h"
3-
42 #include "store_properties.h"
5-
3+#include "../compression_interface.h"
64 #include "../../streams/crc32stream.h"
5+#include "../../utils/stream/serialization.h"
76 #include "../../extlibs/zlib/zlib.h"
87
98 #include <cstdint>
@@ -41,8 +40,8 @@ class store_encoder
4140 _bufferCapacity = storeProps.BufferCapacity;
4241
4342 uninit_buffers();
44- _inputBuffer = new char_type[_bufferCapacity];
45- _outputBuffer = new char_type[_bufferCapacity];
43+ _inputBuffer = new uint8_t[_bufferCapacity];
44+ _outputBuffer = new uint8_t[_bufferCapacity];
4645 }
4746
4847 bool is_init() const override
@@ -50,19 +49,19 @@ class store_encoder
5049 return _stream != nullptr;
5150 }
5251
53- char_type* get_buffer_begin() override
52+ uint8_t* get_buffer_begin() override
5453 {
5554 return _inputBuffer;
5655 }
5756
58- char_type* get_buffer_end() override
57+ uint8_t* get_buffer_end() override
5958 {
6059 return _inputBuffer + _bufferCapacity;
6160 }
6261
6362 void encode_next(size_t length) override
6463 {
65- _stream->write(_inputBuffer, length);
64+ utils::stream::serialize(*_stream, _inputBuffer, length);
6665 }
6766
6867 void sync() override
@@ -80,6 +79,6 @@ class store_encoder
8079 std::ostream* _stream = nullptr;
8180
8281 size_t _bufferCapacity = 0;
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
82+ uint8_t* _inputBuffer = nullptr; // pointer to the start of the input buffer
83+ uint8_t* _outputBuffer = nullptr; // pointer to the start of the output buffer
8584 };
--- a/Source/ZipLib/detail/EndOfCentralDirectoryBlock.cpp
+++ b/Source/ZipLib/detail/EndOfCentralDirectoryBlock.cpp
@@ -1,5 +1,5 @@
11 #include "EndOfCentralDirectoryBlock.h"
2-#include "../streams/serialization.h"
2+#include "../utils/stream/serialization.h"
33 #include <cstring>
44
55 namespace detail {
@@ -15,21 +15,21 @@ bool EndOfCentralDirectoryBlock::Deserialize(std::istream& stream)
1515 // this condition should be optimized out :)
1616 if (sizeof(EndOfCentralDirectoryBlockBase) == EndOfCentralDirectoryBlockBase::SIZE_IN_BYTES)
1717 {
18- deserialize<EndOfCentralDirectoryBlockBase>(stream, *this);
18+ utils::stream::deserialize<EndOfCentralDirectoryBlockBase>(stream, *this);
1919 }
2020 else
2121 {
22- deserialize(stream, Signature);
23- deserialize(stream, NumberOfThisDisk);
24- deserialize(stream, NumberOfTheDiskWithTheStartOfTheCentralDirectory);
25- deserialize(stream, NumberOfEntriesInTheCentralDirectoryOnThisDisk);
26- deserialize(stream, NumberOfEntriesInTheCentralDirectory);
27- deserialize(stream, SizeOfCentralDirectory);
28- deserialize(stream, OffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber);
29- deserialize(stream, CommentLength);
22+ utils::stream::deserialize(stream, Signature);
23+ utils::stream::deserialize(stream, NumberOfThisDisk);
24+ utils::stream::deserialize(stream, NumberOfTheDiskWithTheStartOfTheCentralDirectory);
25+ utils::stream::deserialize(stream, NumberOfEntriesInTheCentralDirectoryOnThisDisk);
26+ utils::stream::deserialize(stream, NumberOfEntriesInTheCentralDirectory);
27+ utils::stream::deserialize(stream, SizeOfCentralDirectory);
28+ utils::stream::deserialize(stream, OffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber);
29+ utils::stream::deserialize(stream, CommentLength);
3030 }
3131
32- deserialize(stream, Comment, CommentLength);
32+ utils::stream::deserialize(stream, Comment, CommentLength);
3333
3434 return true;
3535 }
@@ -40,21 +40,21 @@ void EndOfCentralDirectoryBlock::Serialize(std::ostream& stream)
4040
4141 if (sizeof(EndOfCentralDirectoryBlockBase) == EndOfCentralDirectoryBlockBase::SIZE_IN_BYTES)
4242 {
43- serialize<EndOfCentralDirectoryBlockBase>(stream, *this);
43+ utils::stream::serialize<EndOfCentralDirectoryBlockBase>(stream, *this);
4444 }
4545 else
4646 {
47- serialize(stream, Signature);
48- serialize(stream, NumberOfThisDisk);
49- serialize(stream, NumberOfTheDiskWithTheStartOfTheCentralDirectory);
50- serialize(stream, NumberOfEntriesInTheCentralDirectoryOnThisDisk);
51- serialize(stream, NumberOfEntriesInTheCentralDirectory);
52- serialize(stream, SizeOfCentralDirectory);
53- serialize(stream, OffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber);
54- serialize(stream, CommentLength);
47+ utils::stream::serialize(stream, Signature);
48+ utils::stream::serialize(stream, NumberOfThisDisk);
49+ utils::stream::serialize(stream, NumberOfTheDiskWithTheStartOfTheCentralDirectory);
50+ utils::stream::serialize(stream, NumberOfEntriesInTheCentralDirectoryOnThisDisk);
51+ utils::stream::serialize(stream, NumberOfEntriesInTheCentralDirectory);
52+ utils::stream::serialize(stream, SizeOfCentralDirectory);
53+ utils::stream::serialize(stream, OffsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber);
54+ utils::stream::serialize(stream, CommentLength);
5555 }
5656
57- serialize(stream, Comment);
57+ utils::stream::serialize(stream, Comment);
5858 }
5959
6060 }
--- a/Source/ZipLib/detail/ZipCentralDirectoryFileHeader.cpp
+++ b/Source/ZipLib/detail/ZipCentralDirectoryFileHeader.cpp
@@ -1,7 +1,7 @@
11 #include "ZipCentralDirectoryFileHeader.h"
22 #include "ZipLocalFileHeader.h"
33
4-#include "../streams/serialization.h"
4+#include "../utils/stream/serialization.h"
55
66 #include <cstring>
77 #include <ctime>
@@ -28,27 +28,27 @@ bool ZipCentralDirectoryFileHeader::Deserialize(std::istream& stream)
2828 {
2929 if (sizeof(ZipCentralDirectoryFileHeaderBase) == ZipCentralDirectoryFileHeaderBase::SIZE_IN_BYTES)
3030 {
31- deserialize<ZipCentralDirectoryFileHeaderBase>(stream, *this);
31+ utils::stream::deserialize<ZipCentralDirectoryFileHeaderBase>(stream, *this);
3232 }
3333 else
3434 {
35- deserialize(stream, Signature);
36- deserialize(stream, VersionMadeBy);
37- deserialize(stream, VersionNeededToExtract);
38- deserialize(stream, GeneralPurposeBitFlag);
39- deserialize(stream, CompressionMethod);
40- deserialize(stream, LastModificationTime);
41- deserialize(stream, LastModificationDate);
42- deserialize(stream, Crc32);
43- deserialize(stream, CompressedSize);
44- deserialize(stream, UncompressedSize);
45- deserialize(stream, FilenameLength);
46- deserialize(stream, ExtraFieldLength);
47- deserialize(stream, FileCommentLength);
48- deserialize(stream, DiskNumberStart);
49- deserialize(stream, InternalFileAttributes);
50- deserialize(stream, ExternalFileAttributes);
51- deserialize(stream, RelativeOffsetOfLocalHeader);
35+ utils::stream::deserialize(stream, Signature);
36+ utils::stream::deserialize(stream, VersionMadeBy);
37+ utils::stream::deserialize(stream, VersionNeededToExtract);
38+ utils::stream::deserialize(stream, GeneralPurposeBitFlag);
39+ utils::stream::deserialize(stream, CompressionMethod);
40+ utils::stream::deserialize(stream, LastModificationTime);
41+ utils::stream::deserialize(stream, LastModificationDate);
42+ utils::stream::deserialize(stream, Crc32);
43+ utils::stream::deserialize(stream, CompressedSize);
44+ utils::stream::deserialize(stream, UncompressedSize);
45+ utils::stream::deserialize(stream, FilenameLength);
46+ utils::stream::deserialize(stream, ExtraFieldLength);
47+ utils::stream::deserialize(stream, FileCommentLength);
48+ utils::stream::deserialize(stream, DiskNumberStart);
49+ utils::stream::deserialize(stream, InternalFileAttributes);
50+ utils::stream::deserialize(stream, ExternalFileAttributes);
51+ utils::stream::deserialize(stream, RelativeOffsetOfLocalHeader);
5252 }
5353
5454 // If there is not any other entry.
@@ -59,7 +59,7 @@ bool ZipCentralDirectoryFileHeader::Deserialize(std::istream& stream)
5959 return false;
6060 }
6161
62- deserialize(stream, Filename, FilenameLength);
62+ utils::stream::deserialize(stream, Filename, FilenameLength);
6363
6464 if (ExtraFieldLength > 0)
6565 {
@@ -73,7 +73,7 @@ bool ZipCentralDirectoryFileHeader::Deserialize(std::istream& stream)
7373 }
7474 }
7575
76- deserialize(stream, FileComment, FileCommentLength);
76+ utils::stream::deserialize(stream, FileComment, FileCommentLength);
7777
7878 return true;
7979 }
@@ -91,30 +91,30 @@ void ZipCentralDirectoryFileHeader::Serialize(std::ostream& stream)
9191
9292 if (sizeof(ZipCentralDirectoryFileHeaderBase) == ZipCentralDirectoryFileHeaderBase::SIZE_IN_BYTES)
9393 {
94- serialize<ZipCentralDirectoryFileHeaderBase>(stream, *this);
94+ utils::stream::serialize<ZipCentralDirectoryFileHeaderBase>(stream, *this);
9595 }
9696 else
9797 {
98- serialize(stream, Signature);
99- serialize(stream, VersionMadeBy);
100- serialize(stream, VersionNeededToExtract);
101- serialize(stream, GeneralPurposeBitFlag);
102- serialize(stream, CompressionMethod);
103- serialize(stream, LastModificationTime);
104- serialize(stream, LastModificationDate);
105- serialize(stream, Crc32);
106- serialize(stream, CompressedSize);
107- serialize(stream, UncompressedSize);
108- serialize(stream, FilenameLength);
109- serialize(stream, ExtraFieldLength);
110- serialize(stream, FileCommentLength);
111- serialize(stream, DiskNumberStart);
112- serialize(stream, InternalFileAttributes);
113- serialize(stream, ExternalFileAttributes);
114- serialize(stream, RelativeOffsetOfLocalHeader);
98+ utils::stream::serialize(stream, Signature);
99+ utils::stream::serialize(stream, VersionMadeBy);
100+ utils::stream::serialize(stream, VersionNeededToExtract);
101+ utils::stream::serialize(stream, GeneralPurposeBitFlag);
102+ utils::stream::serialize(stream, CompressionMethod);
103+ utils::stream::serialize(stream, LastModificationTime);
104+ utils::stream::serialize(stream, LastModificationDate);
105+ utils::stream::serialize(stream, Crc32);
106+ utils::stream::serialize(stream, CompressedSize);
107+ utils::stream::serialize(stream, UncompressedSize);
108+ utils::stream::serialize(stream, FilenameLength);
109+ utils::stream::serialize(stream, ExtraFieldLength);
110+ utils::stream::serialize(stream, FileCommentLength);
111+ utils::stream::serialize(stream, DiskNumberStart);
112+ utils::stream::serialize(stream, InternalFileAttributes);
113+ utils::stream::serialize(stream, ExternalFileAttributes);
114+ utils::stream::serialize(stream, RelativeOffsetOfLocalHeader);
115115 }
116116
117- serialize(stream, Filename);
117+ utils::stream::serialize(stream, Filename);
118118
119119 if (ExtraFieldLength > 0)
120120 {
@@ -124,7 +124,7 @@ void ZipCentralDirectoryFileHeader::Serialize(std::ostream& stream)
124124 }
125125 }
126126
127- serialize(stream, FileComment);
127+ utils::stream::serialize(stream, FileComment);
128128 }
129129
130130 }
--- a/Source/ZipLib/detail/ZipGenericExtraField.cpp
+++ b/Source/ZipLib/detail/ZipGenericExtraField.cpp
@@ -1,5 +1,5 @@
11 #include "ZipGenericExtraField.h"
2-#include "../streams/serialization.h"
2+#include "../utils/stream/serialization.h"
33
44 namespace detail {
55
@@ -10,15 +10,15 @@ bool ZipGenericExtraField::Deserialize(std::istream& stream, std::istream::pos_t
1010 return false;
1111 }
1212
13- deserialize(stream, Tag);
14- deserialize(stream, Size);
13+ utils::stream::deserialize(stream, Tag);
14+ utils::stream::deserialize(stream, Size);
1515
1616 if ((extraFieldEnd - stream.tellg()) < Size)
1717 {
1818 return false;
1919 }
2020
21- deserialize(stream, Data, Size);
21+ utils::stream::deserialize(stream, Data, Size);
2222
2323 return true;
2424 }
@@ -27,9 +27,9 @@ void ZipGenericExtraField::Serialize(std::ostream& stream)
2727 {
2828 Size = static_cast<uint16_t>(Data.size());
2929
30- serialize(stream, Tag);
31- serialize(stream, Size);
32- serialize(stream, Data);
30+ utils::stream::serialize(stream, Tag);
31+ utils::stream::serialize(stream, Size);
32+ utils::stream::serialize(stream, Data);
3333 }
3434
3535 }
--- a/Source/ZipLib/detail/ZipLocalFileHeader.cpp
+++ b/Source/ZipLib/detail/ZipLocalFileHeader.cpp
@@ -1,7 +1,7 @@
11 #include "ZipLocalFileHeader.h"
22 #include "ZipCentralDirectoryFileHeader.h"
33
4-#include "../streams/serialization.h"
4+#include "../utils/stream/serialization.h"
55
66 #include <cstring>
77
@@ -32,21 +32,21 @@ bool ZipLocalFileHeader::Deserialize(std::istream& stream)
3232 {
3333 if (sizeof(ZipLocalFileHeaderBase) == ZipLocalFileHeaderBase::SIZE_IN_BYTES)
3434 {
35- deserialize<ZipLocalFileHeaderBase>(stream, *this);
35+ utils::stream::deserialize<ZipLocalFileHeaderBase>(stream, *this);
3636 }
3737 else
3838 {
39- deserialize(stream, Signature);
40- deserialize(stream, VersionNeededToExtract);
41- deserialize(stream, GeneralPurposeBitFlag);
42- deserialize(stream, CompressionMethod);
43- deserialize(stream, LastModificationTime);
44- deserialize(stream, LastModificationDate);
45- deserialize(stream, Crc32);
46- deserialize(stream, CompressedSize);
47- deserialize(stream, UncompressedSize);
48- deserialize(stream, FilenameLength);
49- deserialize(stream, ExtraFieldLength);
39+ utils::stream::deserialize(stream, Signature);
40+ utils::stream::deserialize(stream, VersionNeededToExtract);
41+ utils::stream::deserialize(stream, GeneralPurposeBitFlag);
42+ utils::stream::deserialize(stream, CompressionMethod);
43+ utils::stream::deserialize(stream, LastModificationTime);
44+ utils::stream::deserialize(stream, LastModificationDate);
45+ utils::stream::deserialize(stream, Crc32);
46+ utils::stream::deserialize(stream, CompressedSize);
47+ utils::stream::deserialize(stream, UncompressedSize);
48+ utils::stream::deserialize(stream, FilenameLength);
49+ utils::stream::deserialize(stream, ExtraFieldLength);
5050 }
5151
5252 // If there is not any other entry.
@@ -57,7 +57,7 @@ bool ZipLocalFileHeader::Deserialize(std::istream& stream)
5757 return false;
5858 }
5959
60- deserialize(stream, Filename, FilenameLength);
60+ utils::stream::deserialize(stream, Filename, FilenameLength);
6161
6262 if (ExtraFieldLength > 0)
6363 {
@@ -86,24 +86,24 @@ void ZipLocalFileHeader::Serialize(std::ostream& stream)
8686
8787 if (sizeof(ZipLocalFileHeaderBase) == ZipLocalFileHeaderBase::SIZE_IN_BYTES)
8888 {
89- serialize<ZipLocalFileHeaderBase>(stream, *this);
89+ utils::stream::serialize<ZipLocalFileHeaderBase>(stream, *this);
9090 }
9191 else
9292 {
93- serialize(stream, Signature);
94- serialize(stream, VersionNeededToExtract);
95- serialize(stream, GeneralPurposeBitFlag);
96- serialize(stream, CompressionMethod);
97- serialize(stream, LastModificationTime);
98- serialize(stream, LastModificationDate);
99- serialize(stream, Crc32);
100- serialize(stream, CompressedSize);
101- serialize(stream, UncompressedSize);
102- serialize(stream, FilenameLength);
103- serialize(stream, ExtraFieldLength);
93+ utils::stream::serialize(stream, Signature);
94+ utils::stream::serialize(stream, VersionNeededToExtract);
95+ utils::stream::serialize(stream, GeneralPurposeBitFlag);
96+ utils::stream::serialize(stream, CompressionMethod);
97+ utils::stream::serialize(stream, LastModificationTime);
98+ utils::stream::serialize(stream, LastModificationDate);
99+ utils::stream::serialize(stream, Crc32);
100+ utils::stream::serialize(stream, CompressedSize);
101+ utils::stream::serialize(stream, UncompressedSize);
102+ utils::stream::serialize(stream, FilenameLength);
103+ utils::stream::serialize(stream, ExtraFieldLength);
104104 }
105105
106- serialize(stream, Filename);
106+ utils::stream::serialize(stream, Filename);
107107
108108 if (ExtraFieldLength > 0)
109109 {
@@ -117,29 +117,29 @@ void ZipLocalFileHeader::Serialize(std::ostream& stream)
117117 void ZipLocalFileHeader::DeserializeAsDataDescriptor(std::istream& stream)
118118 {
119119 uint32_t firstWord;
120- deserialize(stream, firstWord);
120+ utils::stream::deserialize(stream, firstWord);
121121
122122 // the signature is optional, if it's missing,
123123 // we're starting with crc32
124124 if (firstWord != DataDescriptorSignature)
125125 {
126- deserialize(stream, Crc32);
126+ utils::stream::deserialize(stream, Crc32);
127127 }
128128 else
129129 {
130130 Crc32 = firstWord;
131131 }
132132
133- deserialize(stream, CompressedSize);
134- deserialize(stream, UncompressedSize);
133+ utils::stream::deserialize(stream, CompressedSize);
134+ utils::stream::deserialize(stream, UncompressedSize);
135135 }
136136
137137 void ZipLocalFileHeader::SerializeAsDataDescriptor(std::ostream& stream)
138138 {
139- serialize(stream, DataDescriptorSignature);
140- serialize(stream, Crc32);
141- serialize(stream, CompressedSize);
142- serialize(stream, UncompressedSize);
139+ utils::stream::serialize(stream, DataDescriptorSignature);
140+ utils::stream::serialize(stream, Crc32);
141+ utils::stream::serialize(stream, CompressedSize);
142+ utils::stream::serialize(stream, UncompressedSize);
143143 }
144144
145145 }
--- a/Source/ZipLib/encryption/aes/aes_decoder.h
+++ b/Source/ZipLib/encryption/aes/aes_decoder.h
@@ -1,8 +1,8 @@
11 #pragma once
2-#include "../encryption_interface.h"
3-#include "../../streams/serialization.h"
42 #include "aes_properties.h"
53 #include "detail/aes_impl.h"
4+#include "../encryption_interface.h"
5+#include "../../utils/stream/serialization.h"
66
77 #include <cstdint>
88
@@ -36,7 +36,7 @@ class aes_decoder
3636 _bufferCapacity = aesProps.BufferCapacity;
3737
3838 uninit_buffers();
39- _inputBuffer = new char_type[_bufferCapacity];
39+ _inputBuffer = new uint8_t[_bufferCapacity];
4040
4141 // init stream
4242 _stream = &stream;
@@ -61,22 +61,22 @@ class aes_decoder
6161 return _stream != nullptr && _encryptedStream != nullptr && _authCodeStream != nullptr;
6262 }
6363
64- char_type* get_buffer_begin() override
64+ uint8_t* get_buffer_begin() override
6565 {
6666 return _inputBuffer;
6767 }
6868
69- char_type* get_buffer_end() override
69+ uint8_t* get_buffer_end() override
7070 {
7171 return _inputBuffer + _bufferCapacity;
7272 }
7373
7474 size_t decrypt_next() override
7575 {
76- _encryptedStream->read(_inputBuffer, _bufferCapacity);
76+ utils::stream::deserialize(*_encryptedStream, _inputBuffer, _bufferCapacity);
7777
7878 size_t n = static_cast<size_t>(_encryptedStream->gcount());
79- _aes.decrypt(reinterpret_cast<uint8_t*>(_inputBuffer), n);
79+ _aes.decrypt(_inputBuffer, n);
8080
8181 _aesContext.authcode = _aes.finish();
8282
@@ -115,15 +115,15 @@ class aes_decoder
115115
116116 void read_encryption_header()
117117 {
118- deserialize(*_encryptedStream, _aesStoredContext.salt.data(), _aesStoredContext.salt.size());
119- deserialize(*_encryptedStream, _aesStoredContext.passverify);
118+ utils::stream::deserialize(*_encryptedStream, _aesStoredContext.salt.data(), _aesStoredContext.salt.size());
119+ utils::stream::deserialize(*_encryptedStream, _aesStoredContext.passverify);
120120
121121 _encryptionHeaderRead = true;
122122 }
123123
124124 void read_encryption_footer()
125125 {
126- deserialize(*_authCodeStream, _aesStoredContext.authcode);
126+ utils::stream::deserialize(*_authCodeStream, _aesStoredContext.authcode);
127127
128128 _encryptionFooterRead = true;
129129 }
@@ -133,10 +133,10 @@ class aes_decoder
133133 delete[] _inputBuffer;
134134 }
135135
136- char_type* _inputBuffer = nullptr;
137- size_t _bufferCapacity = 0;
136+ uint8_t* _inputBuffer = nullptr;
137+ size_t _bufferCapacity = 0;
138138
139- std::istream* _stream = nullptr;
139+ std::istream* _stream = nullptr;
140140 std::unique_ptr<isubstream> _encryptedStream;
141141 std::unique_ptr<isubstream> _authCodeStream;
142142
@@ -157,6 +157,6 @@ class aes_decoder
157157 aes_context _aesContext;
158158 aes_stored_context _aesStoredContext;
159159
160- bool _encryptionHeaderRead = false;
161- bool _encryptionFooterRead = false;
160+ bool _encryptionHeaderRead = false;
161+ bool _encryptionFooterRead = false;
162162 };
--- a/Source/ZipLib/encryption/aes/aes_encoder.h
+++ b/Source/ZipLib/encryption/aes/aes_encoder.h
@@ -1,8 +1,8 @@
11 #pragma once
2-#include "../encryption_interface.h"
3-#include "../../streams/serialization.h"
42 #include "aes_properties.h"
53 #include "detail/aes_impl.h"
4+#include "../encryption_interface.h"
5+#include "../../utils/stream/serialization.h"
66
77 #include <cstdint>
88
@@ -36,7 +36,7 @@ class aes_encoder
3636 _bufferCapacity = aesProps.BufferCapacity;
3737
3838 uninit_buffers();
39- _inputBuffer = new char_type[_bufferCapacity];
39+ _inputBuffer = new uint8_t[_bufferCapacity];
4040
4141 // init stream
4242 _stream = &stream;
@@ -54,12 +54,12 @@ class aes_encoder
5454 return _stream != nullptr;
5555 }
5656
57- char_type* get_buffer_begin() override
57+ uint8_t* get_buffer_begin() override
5858 {
5959 return _inputBuffer;
6060 }
6161
62- char_type* get_buffer_end() override
62+ uint8_t* get_buffer_end() override
6363 {
6464 return _inputBuffer + _bufferCapacity;
6565 }
@@ -71,21 +71,21 @@ class aes_encoder
7171 write_encryption_header();
7272 }
7373
74- _aes.encrypt(reinterpret_cast<uint8_t*>(_inputBuffer), length);
75- _stream->write(_inputBuffer, length);
74+ _aes.encrypt(_inputBuffer, length);
75+ utils::stream::serialize(*_stream, _inputBuffer, length);
7676 }
7777
7878 void sync() override
7979 {
80- serialize(*_stream, _aes.finish());
80+ utils::stream::serialize(*_stream, _aes.finish());
8181 _stream->rdbuf()->pubsync();
8282 }
8383
8484 private:
8585 void write_encryption_header()
8686 {
87- serialize(*_stream, _aesContext.salt.data(), _aesContext.salt.size());
88- serialize(*_stream, _aesContext.passverify);
87+ utils::stream::serialize(*_stream, _aesContext.salt.data(), _aesContext.salt.size());
88+ utils::stream::serialize(*_stream, _aesContext.passverify);
8989
9090 _encryptionHeaderWritten = true;
9191 }
@@ -95,7 +95,7 @@ class aes_encoder
9595 delete[] _inputBuffer;
9696 }
9797
98- char_type* _inputBuffer = nullptr;
98+ uint8_t* _inputBuffer = nullptr;
9999 size_t _bufferCapacity = 0;
100100
101101 std::ostream* _stream = nullptr;
--- a/Source/ZipLib/encryption/aes/detail/aes_types.h
+++ b/Source/ZipLib/encryption/aes/detail/aes_types.h
@@ -6,9 +6,9 @@ namespace detail {
66
77 enum
88 {
9- AES_PASSWORD_VERIFY_SIZE = 2,
10- AES_AUTHCODE_SIZE = 10,
11- AES_MAX_SALT_LENGTH = 16
9+ AES_PASSWORD_VERIFY_SIZE = 2,
10+ AES_AUTHCODE_SIZE = 10,
11+ AES_MAX_SALT_LENGTH = 16
1212 };
1313
1414 using aes_passverify = std::array<uint8_t, AES_PASSWORD_VERIFY_SIZE>;
--- a/Source/ZipLib/encryption/encryption_interface.h
+++ b/Source/ZipLib/encryption/encryption_interface.h
@@ -21,14 +21,12 @@ struct encryption_properties_interface
2121 class encryption_interface
2222 {
2323 public:
24- typedef char char_type;
25-
2624 virtual ~encryption_interface() { }
2725
2826 virtual bool is_init() const = 0;
2927
30- virtual char_type* get_buffer_begin() = 0;
31- virtual char_type* get_buffer_end() = 0;
28+ virtual uint8_t* get_buffer_begin() = 0;
29+ virtual uint8_t* get_buffer_end() = 0;
3230 };
3331
3432 class encryption_encoder_interface
--- a/Source/ZipLib/encryption/zipcrypto/zipcrypto_decoder.h
+++ b/Source/ZipLib/encryption/zipcrypto/zipcrypto_decoder.h
@@ -1,8 +1,9 @@
11 #pragma once
2-#include "../encryption_interface.h"
32 #include "zipcrypto_properties.h"
4-#include "../../extlibs/zlib/zconf.h"
53 #include "detail/zipcrypto.h"
4+#include "../encryption_interface.h"
5+#include "../../utils/stream/serialization.h"
6+#include "../../extlibs/zlib/zconf.h"
67
78 #include <cstdint>
89
@@ -36,7 +37,7 @@ class zipcrypto_decoder
3637 _bufferCapacity = zipcryptoProps.BufferCapacity;
3738
3839 uninit_buffers();
39- _inputBuffer = new char_type[_bufferCapacity];
40+ _inputBuffer = new uint8_t[_bufferCapacity];
4041
4142 // init stream
4243 _stream = &stream;
@@ -57,12 +58,12 @@ class zipcrypto_decoder
5758 return _stream != nullptr;
5859 }
5960
60- char_type* get_buffer_begin() override
61+ uint8_t* get_buffer_begin() override
6162 {
6263 return _inputBuffer;
6364 }
6465
65- char_type* get_buffer_end() override
66+ uint8_t* get_buffer_end() override
6667 {
6768 return _inputBuffer + _bufferCapacity;
6869 }
@@ -74,10 +75,10 @@ class zipcrypto_decoder
7475 read_encryption_header();
7576 }
7677
77- _stream->read(_inputBuffer, _bufferCapacity);
78+ utils::stream::deserialize(*_stream, _inputBuffer, _bufferCapacity);
7879
7980 size_t n = static_cast<size_t>(_stream->gcount());
80- _zipcrypto.decrypt_buffer(reinterpret_cast<uint8_t*>(_inputBuffer), n);
81+ _zipcrypto.decrypt_buffer(_inputBuffer, n);
8182
8283 return n;
8384 }
@@ -90,9 +91,10 @@ class zipcrypto_decoder
9091 private:
9192 void read_encryption_header()
9293 {
93- _stream->read(
94- reinterpret_cast<char_type*>(&_zipcrypto.get_encryption_header()),
95- _zipcrypto.get_encryption_header_size());
94+ utils::stream::deserialize(
95+ *_stream,
96+ &_zipcrypto.get_encryption_header(),
97+ _zipcrypto.get_encryption_header_size());
9698
9799 _zipcrypto.decrypt_header();
98100 _encryptionHeaderRead = true;
@@ -103,10 +105,10 @@ class zipcrypto_decoder
103105 delete[] _inputBuffer;
104106 }
105107
106- char_type* _inputBuffer = nullptr;
107- size_t _bufferCapacity = 0;
108+ uint8_t* _inputBuffer = nullptr;
109+ size_t _bufferCapacity = 0;
108110
109- std::istream* _stream = nullptr;
111+ std::istream* _stream = nullptr;
110112 detail::zipcrypto _zipcrypto;
111- bool _encryptionHeaderRead = false;
113+ bool _encryptionHeaderRead = false;
112114 };
--- a/Source/ZipLib/encryption/zipcrypto/zipcrypto_encoder.h
+++ b/Source/ZipLib/encryption/zipcrypto/zipcrypto_encoder.h
@@ -1,7 +1,8 @@
11 #pragma once
2-#include "../encryption_interface.h"
32 #include "zipcrypto_properties.h"
43 #include "detail/zipcrypto.h"
4+#include "../encryption_interface.h"
5+#include "../../utils/stream/serialization.h"
56
67 #include <cstdint>
78
@@ -35,7 +36,7 @@ class zipcrypto_encoder
3536 _bufferCapacity = zipcryptoProps.BufferCapacity;
3637
3738 uninit_buffers();
38- _inputBuffer = new char_type[_bufferCapacity];
39+ _inputBuffer = new uint8_t[_bufferCapacity];
3940
4041 // init stream
4142 _stream = &stream;
@@ -53,12 +54,12 @@ class zipcrypto_encoder
5354 return _stream != nullptr;
5455 }
5556
56- char_type* get_buffer_begin() override
57+ uint8_t* get_buffer_begin() override
5758 {
5859 return _inputBuffer;
5960 }
6061
61- char_type* get_buffer_end() override
62+ uint8_t* get_buffer_end() override
6263 {
6364 return _inputBuffer + _bufferCapacity;
6465 }
@@ -70,8 +71,8 @@ class zipcrypto_encoder
7071 write_encryption_header();
7172 }
7273
73- _zipcrypto.encrypt_buffer(reinterpret_cast<uint8_t*>(_inputBuffer), length);
74- _stream->write(_inputBuffer, length);
74+ _zipcrypto.encrypt_buffer(_inputBuffer, length);
75+ utils::stream::serialize(*_stream, _inputBuffer, length);
7576 }
7677
7778 void sync() override
@@ -83,9 +84,11 @@ class zipcrypto_encoder
8384 void write_encryption_header()
8485 {
8586 _zipcrypto.encrypt_header();
86- _stream->write(
87- reinterpret_cast<const char_type*>(&_zipcrypto.get_encryption_header()),
88- _zipcrypto.get_encryption_header_size());
87+
88+ utils::stream::serialize(
89+ *_stream,
90+ &_zipcrypto.get_encryption_header(),
91+ _zipcrypto.get_encryption_header_size());
8992
9093 _encryptionHeaderWritten = true;
9194 }
@@ -95,7 +98,7 @@ class zipcrypto_encoder
9598 delete[] _inputBuffer;
9699 }
97100
98- char_type* _inputBuffer = nullptr;
101+ uint8_t* _inputBuffer = nullptr;
99102 size_t _bufferCapacity = 0;
100103
101104 std::ostream* _stream = nullptr;
--- a/Source/ZipLib/extlibs/aes/aes.vcxproj
+++ b/Source/ZipLib/extlibs/aes/aes.vcxproj
@@ -114,6 +114,7 @@
114114 <WarningLevel>Level3</WarningLevel>
115115 <Optimization>Disabled</Optimization>
116116 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
117+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
117118 </ClCompile>
118119 <Link>
119120 <SubSystem>Windows</SubSystem>
@@ -127,6 +128,7 @@
127128 <WarningLevel>Level3</WarningLevel>
128129 <Optimization>Disabled</Optimization>
129130 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
131+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
130132 </ClCompile>
131133 <Link>
132134 <SubSystem>Windows</SubSystem>
--- a/Source/ZipLib/extlibs/bzip2/bzip2.vcxproj
+++ b/Source/ZipLib/extlibs/bzip2/bzip2.vcxproj
@@ -104,6 +104,7 @@
104104 <Optimization>Disabled</Optimization>
105105 <PreprocessorDefinitions>WIN32;BZ_NO_STDIO;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106106 <DisableSpecificWarnings>4996; 4244</DisableSpecificWarnings>
107+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
107108 </ClCompile>
108109 <Link>
109110 <SubSystem>Windows</SubSystem>
@@ -118,6 +119,7 @@
118119 <Optimization>Disabled</Optimization>
119120 <PreprocessorDefinitions>WIN32;BZ_NO_STDIO;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120121 <DisableSpecificWarnings>4996; 4244</DisableSpecificWarnings>
122+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
121123 </ClCompile>
122124 <Link>
123125 <SubSystem>Windows</SubSystem>
--- a/Source/ZipLib/extlibs/lzma/lzma.vcxproj
+++ b/Source/ZipLib/extlibs/lzma/lzma.vcxproj
@@ -160,6 +160,7 @@
160160 <Optimization>Disabled</Optimization>
161161 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
162162 <DisableSpecificWarnings>4996</DisableSpecificWarnings>
163+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
163164 </ClCompile>
164165 <Link>
165166 <SubSystem>Windows</SubSystem>
@@ -174,6 +175,7 @@
174175 <Optimization>Disabled</Optimization>
175176 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
176177 <DisableSpecificWarnings>4996</DisableSpecificWarnings>
178+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
177179 </ClCompile>
178180 <Link>
179181 <SubSystem>Windows</SubSystem>
--- a/Source/ZipLib/extlibs/zlib/zlib.vcxproj
+++ b/Source/ZipLib/extlibs/zlib/zlib.vcxproj
@@ -116,6 +116,7 @@
116116 <Optimization>Disabled</Optimization>
117117 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118118 <DisableSpecificWarnings>4996</DisableSpecificWarnings>
119+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
119120 </ClCompile>
120121 <Link>
121122 <SubSystem>Windows</SubSystem>
@@ -130,6 +131,7 @@
130131 <Optimization>Disabled</Optimization>
131132 <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
132133 <DisableSpecificWarnings>4996</DisableSpecificWarnings>
134+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
133135 </ClCompile>
134136 <Link>
135137 <SubSystem>Windows</SubSystem>
--- a/Source/ZipLib/methods/encryption/detail/AesExtraField.h
+++ b/Source/ZipLib/methods/encryption/detail/AesExtraField.h
@@ -1,7 +1,7 @@
11 #pragma once
22 #include "../../../detail/ZipGenericExtraField.h"
33 #include "../../../streams/memstream.h"
4-#include "../../../streams/serialization.h"
4+#include "../../../utils/stream/serialization.h"
55 #include <cstdint>
66
77 namespace detail {
@@ -36,10 +36,10 @@ namespace detail {
3636
3737 uint16_t dummyVendorID;
3838
39- deserialize(extraFieldDataStream, AesVersion);
40- deserialize(extraFieldDataStream, dummyVendorID);
41- deserialize(extraFieldDataStream, EncryptionMode);
42- deserialize(extraFieldDataStream, CompressionMethod);
39+ utils::stream::deserialize(extraFieldDataStream, AesVersion);
40+ utils::stream::deserialize(extraFieldDataStream, dummyVendorID);
41+ utils::stream::deserialize(extraFieldDataStream, EncryptionMode);
42+ utils::stream::deserialize(extraFieldDataStream, CompressionMethod);
4343 }
4444
4545 void ToExtraField(detail::ZipGenericExtraField& extraField)
@@ -51,10 +51,10 @@ namespace detail {
5151
5252 omemstream extraFieldDataStream((char*)extraField.Data.data(), extraField.Data.size());
5353
54- serialize(extraFieldDataStream, AesVersion);
55- serialize(extraFieldDataStream, VendorID);
56- serialize(extraFieldDataStream, EncryptionMode);
57- serialize(extraFieldDataStream, CompressionMethod);
54+ utils::stream::serialize(extraFieldDataStream, AesVersion);
55+ utils::stream::serialize(extraFieldDataStream, VendorID);
56+ utils::stream::serialize(extraFieldDataStream, EncryptionMode);
57+ utils::stream::serialize(extraFieldDataStream, CompressionMethod);
5858 }
5959 };
6060
--- a/Source/ZipLib/streams/streambuffs/compression_decoder_streambuf.h
+++ b/Source/ZipLib/streams/streambuffs/compression_decoder_streambuf.h
@@ -35,7 +35,7 @@ class compression_decoder_streambuf
3535 _compressionDecoder->init(stream);
3636
3737 // set stream buffer
38- this->setg(_compressionDecoder->get_buffer_end(), _compressionDecoder->get_buffer_end(), _compressionDecoder->get_buffer_end());
38+ this->setg(get_buffer_end(), get_buffer_end(), get_buffer_end());
3939 }
4040
4141 void init(compression_decoder_interface_ptr compressionDecoder, compression_properties_interface& props, std::istream& stream)
@@ -46,7 +46,7 @@ class compression_decoder_streambuf
4646 _compressionDecoder->init(stream, props);
4747
4848 // set stream buffer
49- this->setg(_compressionDecoder->get_buffer_end(), _compressionDecoder->get_buffer_end(), _compressionDecoder->get_buffer_end());
49+ this->setg(get_buffer_end(), get_buffer_end(), get_buffer_end());
5050 }
5151
5252 bool is_init() const
@@ -60,7 +60,7 @@ class compression_decoder_streambuf
6060 // buffer exhausted
6161 if (this->gptr() >= this->egptr())
6262 {
63- char_type* base = _compressionDecoder->get_buffer_begin();
63+ char_type* base = get_buffer_begin();
6464
6565 // how many bytes has been read
6666 size_t n = _compressionDecoder->decode_next();
@@ -78,5 +78,15 @@ class compression_decoder_streambuf
7878 }
7979
8080 private:
81+ char_type* get_buffer_begin()
82+ {
83+ return reinterpret_cast<char_type*>(_compressionDecoder->get_buffer_begin());
84+ }
85+
86+ char_type* get_buffer_end()
87+ {
88+ return reinterpret_cast<char_type*>(_compressionDecoder->get_buffer_end());
89+ }
90+
8191 compression_decoder_interface_ptr _compressionDecoder;
8292 };
--- a/Source/ZipLib/streams/streambuffs/compression_encoder_streambuf.h
+++ b/Source/ZipLib/streams/streambuffs/compression_encoder_streambuf.h
@@ -40,7 +40,7 @@ class compression_encoder_streambuf
4040 _compressionEncoder->init(stream);
4141
4242 // set stream buffer
43- this->setp(_compressionEncoder->get_buffer_begin(), _compressionEncoder->get_buffer_end() - 1);
43+ this->setp(get_buffer_begin(), get_buffer_end() - 1);
4444 }
4545
4646 void init(compression_encoder_interface_ptr compressionEncoder, compression_properties_interface& props, std::ostream& stream)
@@ -51,7 +51,7 @@ class compression_encoder_streambuf
5151 _compressionEncoder->init(stream, props);
5252
5353 // set stream buffer
54- this->setp(_compressionEncoder->get_buffer_begin(), _compressionEncoder->get_buffer_end() - 1);
54+ this->setp(get_buffer_begin(), get_buffer_end() - 1);
5555 }
5656
5757 bool is_init() const
@@ -98,7 +98,17 @@ class compression_encoder_streambuf
9898 _compressionEncoder->encode_next(inputLength);
9999
100100 // set pointers for new buffer
101- this->setp(_compressionEncoder->get_buffer_begin(), _compressionEncoder->get_buffer_end() - 1);
101+ this->setp(get_buffer_begin(), get_buffer_end() - 1);
102+ }
103+
104+ char_type* get_buffer_begin()
105+ {
106+ return reinterpret_cast<char_type*>(_compressionEncoder->get_buffer_begin());
107+ }
108+
109+ char_type* get_buffer_end()
110+ {
111+ return reinterpret_cast<char_type*>(_compressionEncoder->get_buffer_end());
102112 }
103113
104114 compression_encoder_interface_ptr _compressionEncoder;
--- a/Source/ZipLib/streams/streambuffs/encryption_decoder_streambuf.h
+++ b/Source/ZipLib/streams/streambuffs/encryption_decoder_streambuf.h
@@ -35,7 +35,7 @@ class encryption_decoder_streambuf
3535 _encryptionDecoder->init(stream);
3636
3737 // set stream buffer
38- this->setg(_encryptionDecoder->get_buffer_end(), _encryptionDecoder->get_buffer_end(), _encryptionDecoder->get_buffer_end());
38+ this->setg(get_buffer_end(), get_buffer_end(), get_buffer_end());
3939 }
4040
4141 void init(encryption_decoder_interface_ptr encryptionDecoder, encryption_properties_interface& props, std::istream& stream)
@@ -46,7 +46,7 @@ class encryption_decoder_streambuf
4646 _encryptionDecoder->init(stream, props);
4747
4848 // set stream buffer
49- this->setg(_encryptionDecoder->get_buffer_end(), _encryptionDecoder->get_buffer_end(), _encryptionDecoder->get_buffer_end());
49+ this->setg(get_buffer_end(), get_buffer_end(), get_buffer_end());
5050 }
5151
5252 bool is_init() const
@@ -60,7 +60,7 @@ class encryption_decoder_streambuf
6060 // buffer exhausted
6161 if (this->gptr() >= this->egptr())
6262 {
63- char_type* base = _encryptionDecoder->get_buffer_begin();
63+ char_type* base = get_buffer_begin();
6464
6565 // how many bytes has been read
6666 size_t n = _encryptionDecoder->decrypt_next();
@@ -78,5 +78,15 @@ class encryption_decoder_streambuf
7878 }
7979
8080 private:
81+ char_type* get_buffer_begin()
82+ {
83+ return reinterpret_cast<char_type*>(_encryptionDecoder->get_buffer_begin());
84+ }
85+
86+ char_type* get_buffer_end()
87+ {
88+ return reinterpret_cast<char_type*>(_encryptionDecoder->get_buffer_end());
89+ }
90+
8191 encryption_decoder_interface_ptr _encryptionDecoder;
8292 };
--- a/Source/ZipLib/streams/streambuffs/encryption_encoder_streambuf.h
+++ b/Source/ZipLib/streams/streambuffs/encryption_encoder_streambuf.h
@@ -40,7 +40,7 @@ class encryption_encoder_streambuf
4040 _encryptionEncoder->init(stream);
4141
4242 // set stream buffer
43- this->setp(_encryptionEncoder->get_buffer_begin(), _encryptionEncoder->get_buffer_end() - 1);
43+ this->setp(get_buffer_begin(), get_buffer_end() - 1);
4444 }
4545
4646 void init(encryption_encoder_interface_ptr encryptionEncoder, encryption_properties_interface& props, std::ostream& stream)
@@ -51,7 +51,7 @@ class encryption_encoder_streambuf
5151 _encryptionEncoder->init(stream, props);
5252
5353 // set stream buffer
54- this->setp(_encryptionEncoder->get_buffer_begin(), _encryptionEncoder->get_buffer_end() - 1);
54+ this->setp(get_buffer_begin(), get_buffer_end() - 1);
5555 }
5656
5757 bool is_init() const
@@ -98,7 +98,17 @@ class encryption_encoder_streambuf
9898 _encryptionEncoder->encrypt_next(inputLength);
9999
100100 // set pointers for new buffer
101- this->setp(_encryptionEncoder->get_buffer_begin(), _encryptionEncoder->get_buffer_end() - 1);
101+ this->setp(get_buffer_begin(), get_buffer_end() - 1);
102+ }
103+
104+ char_type* get_buffer_begin()
105+ {
106+ return reinterpret_cast<char_type*>(_encryptionEncoder->get_buffer_begin());
107+ }
108+
109+ char_type* get_buffer_end()
110+ {
111+ return reinterpret_cast<char_type*>(_encryptionEncoder->get_buffer_end());
102112 }
103113
104114 encryption_encoder_interface_ptr _encryptionEncoder;
--- /dev/null
+++ b/Source/ZipLib/utils/stream/copy.h
@@ -0,0 +1,18 @@
1+#pragma once
2+#include <iostream>
3+#include <vector>
4+
5+namespace utils { namespace stream {
6+
7+static void copy(std::istream& from, std::ostream& to, size_t bufferSize = 1024 * 1024)
8+{
9+ std::vector<char> buff(bufferSize);
10+
11+ do
12+ {
13+ from.read(buff.data(), buff.size());
14+ to.write(buff.data(), from.gcount());
15+ } while (static_cast<size_t>(from.gcount()) == buff.size());
16+}
17+
18+} }
--- a/Source/ZipLib/streams/serialization.h
+++ b/Source/ZipLib/utils/stream/serialization.h
@@ -5,6 +5,8 @@
55 #include <array>
66 #include <list>
77
8+namespace utils { namespace stream {
9+
810 namespace detail {
911
1012 template <typename CONTAINER_TYPE>
@@ -58,6 +60,20 @@ void serialize(std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>& stream, const TYPE& v
5860 }
5961
6062 /**
63+ * \brief Serializes native array of the input type.
64+ *
65+ * \tparam TYPE Type of the value to be serialized.
66+ * \tparam N Deducted array size.
67+ * \param stream The stream to be serialized into.
68+ * \param value The value to be serialized.
69+ */
70+template <typename TYPE, size_t N, typename ELEM_TYPE, typename TRAITS_TYPE>
71+void serialize(std::basic_ostream<ELEM_TYPE, TRAITS_TYPE>& stream, const TYPE(&value)[N])
72+{
73+ stream.write(reinterpret_cast<const ELEM_TYPE*>(value), N * (sizeof(TYPE) / sizeof(ELEM_TYPE)));
74+}
75+
76+/**
6177 * \brief Serializes the input type of specified size
6278 *
6379 * \tparam TYPE Type of the value to be serialized.
@@ -135,6 +151,23 @@ std::ios::pos_type deserialize(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& strea
135151 }
136152
137153 /**
154+ * \brief Deserializes native array of the input type.
155+ *
156+ * \tparam RETURN_TYPE Type of the value to be deserialized.
157+ * \tparam N Deducted array size.
158+ * \param stream The stream to be deserialized from.
159+ * \param [out] out The deserialized value.
160+ *
161+ * \return Count of read elements.
162+ */
163+template <typename RETURN_TYPE, size_t N, typename ELEM_TYPE, typename TRAITS_TYPE>
164+std::ios::pos_type deserialize(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& stream, RETURN_TYPE(&out)[N])
165+{
166+ stream.read(reinterpret_cast<ELEM_TYPE*>(out), N * sizeof(RETURN_TYPE));
167+ return stream.gcount();
168+}
169+
170+/**
138171 * \brief Deserializes the input type from the stream
139172 *
140173 * \tparam RETURN_TYPE Type of the value to be deserialized.
@@ -204,4 +237,6 @@ template <typename ELEM_TYPE, typename TRAITS_TYPE, typename ARRAY_ELEM_TYPE, si
204237 std::ios::pos_type deserialize(std::basic_istream<ELEM_TYPE, TRAITS_TYPE>& stream, std::array<ARRAY_ELEM_TYPE, ARRAY_SIZE>& out)
205238 {
206239 return detail::deserialize_stl_container(stream, out, out.size());
207-}
\ No newline at end of file
240+}
241+
242+} }
--- a/Source/ZipLib/utils/stream_utils.h
+++ b/Source/ZipLib/utils/stream_utils.h
@@ -1,18 +1,3 @@
11 #pragma once
2-#include <iostream>
3-#include <vector>
4-
5-namespace utils { namespace stream {
6-
7-static void copy(std::istream& from, std::ostream& to, size_t bufferSize = 1024 * 1024)
8-{
9- std::vector<char> buff(bufferSize);
10-
11- do
12- {
13- from.read(buff.data(), buff.size());
14- to.write(buff.data(), from.gcount());
15- } while (static_cast<size_t>(from.gcount()) == buff.size());
16-}
17-
18-} }
2+#include "stream/copy.h"
3+#include "stream/serialization.h"