Crypto++ 8.7
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
10NAMESPACE_BEGIN(CryptoPP)
11
12bool 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
20void AlgorithmParametersBase::operator=(const AlgorithmParametersBase &rhs)
21{
22 CRYPTOPP_UNUSED(rhs);
23 CRYPTOPP_ASSERT(false);
24}
25
26bool 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
49 : m_defaultThrowIfNotUsed(true)
50{
51}
52
54 : m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
55{
56 m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
57}
58
59AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
60{
61 m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
62 return *this;
63}
64
65bool 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
73NAMESPACE_END
74
75#endif
Classes for working with NameValuePairs.
Base class for AlgorithmParameters.
Definition: algparam.h:304
An object that implements NameValuePairs.
Definition: algparam.h:426
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
AlgorithmParameters()
Construct a AlgorithmParameters.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
virtual CRYPTOPP_DLL bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0
Get a named value.
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
Multiple precision integer with arithmetic operations.
Crypto++ library namespace.
Precompiled header file.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
Definition: trap.h:68