From 20f82c067e587a7cd74d0a4dbc9faa8ee1502aff Mon Sep 17 00:00:00 2001 From: orangefour Date: Thu, 1 Nov 2018 11:49:04 +0100 Subject: Add VectorSource (GH #730) --- filters.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'filters.h') diff --git a/filters.h b/filters.h index 696459a3..72e2550c 100644 --- a/filters.h +++ b/filters.h @@ -1067,7 +1067,7 @@ public: virtual ~StringSinkTemplate() {} /// \brief Construct a StringSinkTemplate - /// \param output std::basic_string type + /// \param output std::basic_string or std::vector type StringSinkTemplate(T &output) : m_output(&output) {CRYPTOPP_ASSERT(sizeof(value_type)==1);} @@ -1426,6 +1426,24 @@ public: /// \since Crypto++ 5.6.0 DOCUMENTED_TYPEDEF(StringSource, ArraySource) +/// \brief std::vector-based implementation of the Source interface +/// \since Crypto++ 8.0 +class CRYPTOPP_DLL VectorSource : public SourceTemplate +{ +public: + /// \brief Construct a VectorSource + /// \param attachment an optional attached transformation + VectorSource(BufferedTransformation *attachment = NULLPTR) + : SourceTemplate(attachment) {} + + /// \brief Construct a VectorSource + /// \param vec vector of bytes + /// \param pumpAll flag indicating if source data should be pumped to its attached transformation + /// \param attachment an optional attached transformation + VectorSource(const std::vector &vec, bool pumpAll, BufferedTransformation *attachment = NULLPTR) + : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(vec)));} +}; + /// \brief RNG-based implementation of Source interface /// \since Crypto++ 4.0 class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate -- cgit v1.2.1