Skip to content

Commit 41af26d

Browse files
committed
moving ChecksumValidatingStreamBuf to inline implementation
1 parent 9a55a9c commit 41af26d

File tree

2 files changed

+21
-39
lines changed

2 files changed

+21
-39
lines changed

src/aws-cpp-sdk-transfer/include/aws/transfer/ChecksumValidatingStreamBuf.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,34 @@ namespace Aws
1818
* Stream buffer wrapper that calculates checksum while forwarding data to underlying stream.
1919
* Used for single-part download checksum validation.
2020
*/
21-
class AWS_TRANSFER_API ChecksumValidatingStreamBuf : public std::streambuf
21+
class ChecksumValidatingStreamBuf : public std::streambuf
2222
{
2323
public:
2424
ChecksumValidatingStreamBuf(std::streambuf* underlyingBuf,
25-
std::shared_ptr<Aws::Utils::Crypto::Hash> hash);
25+
std::shared_ptr<Aws::Utils::Crypto::Hash> hash)
26+
: m_underlyingBuf(underlyingBuf), m_hash(hash)
27+
{
28+
}
2629

2730
std::shared_ptr<Aws::Utils::Crypto::Hash> GetHash() const { return m_hash; }
2831

2932
protected:
30-
std::streamsize xsputn(const char* s, std::streamsize n) override;
31-
int overflow(int c) override;
33+
std::streamsize xsputn(const char* s, std::streamsize n) override
34+
{
35+
if (m_hash && n > 0) {
36+
m_hash->Update(const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(s)), static_cast<size_t>(n));
37+
}
38+
return m_underlyingBuf->sputn(s, n);
39+
}
40+
41+
int overflow(int c) override
42+
{
43+
if (c != EOF && m_hash) {
44+
unsigned char byte = static_cast<unsigned char>(c);
45+
m_hash->Update(&byte, 1);
46+
}
47+
return m_underlyingBuf->sputc(c);
48+
}
3249

3350
private:
3451
std::streambuf* m_underlyingBuf;

src/aws-cpp-sdk-transfer/source/transfer/ChecksumValidatingStreamBuf.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)