Crypto++ 8.4 Free C++ class library of cryptographic schemes

algparam.cpp
1 // algparam.cpp - originally 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
10 NAMESPACE_BEGIN(CryptoPP)
11
12 bool CombinedNameValuePairs::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
13 {
14 if (strcmp(name, "ValueNames") == 0)
15 return m_pairs1.GetVoidValue(name, valueType, pValue) && m_pairs2.GetVoidValue(name, valueType, pValue);
16 else
17 return m_pairs1.GetVoidValue(name, valueType, pValue) || m_pairs2.GetVoidValue(name, valueType, pValue);
18 }
19
20 void AlgorithmParametersBase::operator=(const AlgorithmParametersBase &rhs)
21 {
22 CRYPTOPP_UNUSED(rhs);
23 CRYPTOPP_ASSERT(false);
24 }
25
26 bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
27 {
28 if (strcmp(name, "ValueNames") == 0)
29 {
30 NameValuePairs::ThrowIfTypeMismatch(name, typeid(std::string), valueType);
31 if (m_next.get())
32 m_next->GetVoidValue(name, valueType, pValue);
33 (*reinterpret_cast<std::string *>(pValue) += m_name) += ";";
34 return true;
35 }
36 else if (strcmp(name, m_name) == 0)
37 {
38 AssignValue(name, valueType, pValue);
39 m_used = true;
40 return true;
41 }
42 else if (m_next.get())
43 return m_next->GetVoidValue(name, valueType, pValue);
44 else
45 return false;
46 }
47
48 AlgorithmParameters::AlgorithmParameters()
49 : m_defaultThrowIfNotUsed(true)
50 {
51 }
52
53 AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)
54 : m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
55 {
56 m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
57 }
58
59 AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
60 {
61 m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
62 return *this;
63 }
64
65 bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
66 {
67 if (m_next.get())
68 return m_next->GetVoidValue(name, valueType, pValue);
69 else
70 return false;
71 }
72
73 NAMESPACE_END
74
75 #endif
AlgorithmParameters
An object that implements NameValuePairs.
Definition: algparam.h:425
AlgorithmParameters::AlgorithmParameters
AlgorithmParameters()
Construct a AlgorithmParameters.
NameValuePairs::GetVoidValue
virtual CRYPTOPP_DLL bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0
Get a named value.
NameValuePairs::ThrowIfTypeMismatch
static CRYPTOPP_DLL void ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving)
Ensures an expected name and type is present.
Definition: cryptlib.h:454
CRYPTOPP_ASSERT
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
Definition: trap.h:68
CombinedNameValuePairs::GetVoidValue
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
pch.h
Precompiled header file.
AlgorithmParameters::GetVoidValue
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
CryptoPP
Crypto++ library namespace.
AlgorithmParametersBase
Base class for AlgorithmParameters.
Definition: algparam.h:303
algparam.h
Classes for working with NameValuePairs.
integer.h
Multiple precision integer with arithmetic operations.