From caf9e032e6b4ccb114a74a3936c916bcfaba262d Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 2 Mar 2009 02:39:17 +0000 Subject: changes for 5.6: - added AuthenticatedSymmetricCipher interface class and Filter wrappers - added CCM, GCM (with SSE2 assembly), CMAC, and SEED - improved AES speed on x86 and x64 - removed WORD64_AVAILABLE; compiler 64-bit int support is now required git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@433 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- algparam.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'algparam.cpp') diff --git a/algparam.cpp b/algparam.cpp index c9da677..84f8be0 100644 --- a/algparam.cpp +++ b/algparam.cpp @@ -22,7 +22,7 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf { if (strcmp(name, "ValueNames") == 0) { - ThrowIfTypeMismatch(name, typeid(std::string), valueType); + NameValuePairs::ThrowIfTypeMismatch(name, typeid(std::string), valueType); if (m_next.get()) m_next->GetVoidValue(name, valueType, pValue); (*reinterpret_cast(pValue) += m_name) += ";"; @@ -40,9 +40,53 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf return false; } +AlgorithmParameters::AlgorithmParameters() + : m_constructed(false), m_defaultThrowIfNotUsed(true) +{ + new(m_first) member_ptr; +} + +AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x) + : m_constructed(false), m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed) +{ + if (x.m_constructed) + { + x.First().MoveInto(m_first); + m_constructed = true; + } + else + new(m_first) member_ptr(x.Next().release()); +} + +AlgorithmParameters::~AlgorithmParameters() +{ + if (m_constructed) + First().~AlgorithmParametersBase(); + else + Next().~member_ptr(); +} + bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const { - return m_ptr->GetVoidValue(name, valueType, pValue); + if (m_constructed) + return First().GetVoidValue(name, valueType, pValue); + else if (Next().get()) + return Next()->GetVoidValue(name, valueType, pValue); + else + return false; +} + +AlgorithmParametersBase & AlgorithmParameters::First() +{ + return *reinterpret_cast(m_first); +} + +member_ptr & AlgorithmParameters::Next() +{ + if (m_constructed) + return First().m_next; + else + return *reinterpret_cast *>(m_first); } NAMESPACE_END -- cgit v1.2.1