Crypto++
algparam.cpp
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 
9 NAMESPACE_BEGIN(CryptoPP)
10 
11 PAssignIntToInteger g_pAssignIntToInteger = NULL;
12 
13 bool CombinedNameValuePairs::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
14 {
15  if (strcmp(name, "ValueNames") == 0)
16  return m_pairs1.GetVoidValue(name, valueType, pValue) && m_pairs2.GetVoidValue(name, valueType, pValue);
17  else
18  return m_pairs1.GetVoidValue(name, valueType, pValue) || m_pairs2.GetVoidValue(name, valueType, pValue);
19 }
20 
21 void AlgorithmParametersBase::operator=(const AlgorithmParametersBase& rhs)
22 {
23  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
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
to be implemented by derived classes, users should use one of the above functions instead ...
Definition: algparam.cpp:65
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
to be implemented by derived classes, users should use one of the above functions instead ...
Definition: algparam.cpp:13
static void ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving)
used by derived classes to check for type mismatch
Definition: cryptlib.h:290