source: trunk/src-cryptopp/algparam.cpp

Last change on this file was e230cb0, checked in by David Stainton <dstainton415@…>, at 2016-10-12T13:27:29Z

Add cryptopp from tag CRYPTOPP_5_6_5

  • Property mode set to 100644
File size: 2.1 KB
Line 
1// algparam.cpp - written and placed in the public domain by Wei Dai
2
3#include "pch.h"
4
5#ifndef CRYPTOPP_IMPORTS
6
7#include "algparam.h"
8#include "integer.h"
9
10NAMESPACE_BEGIN(CryptoPP)
11
12PAssignIntToInteger g_pAssignIntToInteger = NULL;
13
14bool CombinedNameValuePairs::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
15{
16        if (strcmp(name, "ValueNames") == 0)
17                return m_pairs1.GetVoidValue(name, valueType, pValue) && m_pairs2.GetVoidValue(name, valueType, pValue);
18        else
19                return m_pairs1.GetVoidValue(name, valueType, pValue) || m_pairs2.GetVoidValue(name, valueType, pValue);
20}
21
22void AlgorithmParametersBase::operator=(const AlgorithmParametersBase &rhs)
23{
24        CRYPTOPP_UNUSED(rhs);
25        CRYPTOPP_ASSERT(false);
26}
27
28bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
29{
30        if (strcmp(name, "ValueNames") == 0)
31        {
32                NameValuePairs::ThrowIfTypeMismatch(name, typeid(std::string), valueType);
33                if (m_next.get())
34                    m_next->GetVoidValue(name, valueType, pValue);
35                (*reinterpret_cast<std::string *>(pValue) += m_name) += ";";
36                return true;
37        }
38        else if (strcmp(name, m_name) == 0)
39        {
40                AssignValue(name, valueType, pValue);
41                m_used = true;
42                return true;
43        }
44        else if (m_next.get())
45                return m_next->GetVoidValue(name, valueType, pValue);
46        else
47            return false;
48}
49
50AlgorithmParameters::AlgorithmParameters()
51        : m_defaultThrowIfNotUsed(true)
52{
53}
54
55AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)
56        : m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
57{
58        m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
59}
60
61AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
62{
63        m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
64        return *this;
65}
66
67bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
68{
69        if (m_next.get())
70                return m_next->GetVoidValue(name, valueType, pValue);
71        else
72                return false;
73}
74
75NAMESPACE_END
76
77#endif
Note: See TracBrowser for help on using the repository browser.