summaryrefslogtreecommitdiff
path: root/filters.h
diff options
context:
space:
mode:
authororangefour <thirdorange@gmx.com>2018-11-01 11:49:04 +0100
committerJeffrey Walton <noloader@gmail.com>2018-11-01 06:49:04 -0400
commit20f82c067e587a7cd74d0a4dbc9faa8ee1502aff (patch)
treef97696b6729fa334077f10cb465953c6384f0997 /filters.h
parent7c5da3e1ca1235022f6b04e1f1a1609813827b88 (diff)
downloadcryptopp-git-20f82c067e587a7cd74d0a4dbc9faa8ee1502aff.tar.gz
Add VectorSource (GH #730)
Diffstat (limited to 'filters.h')
-rw-r--r--filters.h20
1 files changed, 19 insertions, 1 deletions
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<char> type
+ /// \param output std::basic_string<char> or std::vector<byte> 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<StringStore>
+{
+public:
+ /// \brief Construct a VectorSource
+ /// \param attachment an optional attached transformation
+ VectorSource(BufferedTransformation *attachment = NULLPTR)
+ : SourceTemplate<StringStore>(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<byte> &vec, bool pumpAll, BufferedTransformation *attachment = NULLPTR)
+ : SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(vec)));}
+};
+
/// \brief RNG-based implementation of Source interface
/// \since Crypto++ 4.0
class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate<RandomNumberStore>