Fabcoin Core  0.16.2
P2P Digital Currency
algparam.cpp
Go to the documentation of this file.
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 
11 
13 
14 bool 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 
23 {
24  CRYPTOPP_UNUSED(rhs);
25  CRYPTOPP_ASSERT(false);
26 }
27 
28 bool 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 
51  : m_defaultThrowIfNotUsed(true)
52 {
53 }
54 
57 {
58  m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
59 }
60 
62 {
63  m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
64  return *this;
65 }
66 
67 bool 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 
76 
77 #endif
virtual void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const =0
Classes for working with NameValuePairs.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Definition: algparam.cpp:67
bool(CRYPTOPP_API * PAssignIntToInteger)(const std::type_info &valueType, void *pInteger, const void *pInt)
Definition: algparam.h:302
member_ptr< AlgorithmParametersBase > m_next
Definition: algparam.h:478
Base class for AlgorithmParameters.
Definition: algparam.h:309
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Definition: algparam.cpp:14
void operator=(const AlgorithmParametersBase &rhs)
Definition: algparam.cpp:22
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
member_ptr< AlgorithmParametersBase > m_next
Definition: algparam.h:366
std::hash for asio::adress
Definition: Common.h:323
Combines two sets of NameValuePairs.
Definition: algparam.h:135
PAssignIntToInteger g_pAssignIntToInteger
Definition: algparam.cpp:12
#define x(i)
const char * m_name
Definition: algparam.h:363
const char * name
Definition: rest.cpp:36
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Definition: algparam.cpp:28
const T * get() const
Definition: smartptr.h:52
#define CRYPTOPP_ASSERT(exp)
Definition: trap.h:92
AlgorithmParameters & operator=(const AlgorithmParameters &x)
Definition: algparam.cpp:61
T * release()
Definition: smartptr.h:55
#define CRYPTOPP_UNUSED(x)
Definition: config.h:741
An object that implements NameValuePairs.
Definition: algparam.h:433
Multiple precision integer with arithmetic operations.
#define NAMESPACE_END
Definition: config.h:201
void reset(T *p=0)
Definition: smartptr.h:72
static CRYPTOPP_DLL void CRYPTOPP_API 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:394
bool m_defaultThrowIfNotUsed
Definition: algparam.h:479