Crypto++
|
00001 // algparam.cpp - written and placed in the public domain by Wei Dai 00002 00003 #include "pch.h" 00004 00005 #ifndef CRYPTOPP_IMPORTS 00006 00007 #include "algparam.h" 00008 00009 NAMESPACE_BEGIN(CryptoPP) 00010 00011 PAssignIntToInteger g_pAssignIntToInteger = NULL; 00012 00013 bool CombinedNameValuePairs::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const 00014 { 00015 if (strcmp(name, "ValueNames") == 0) 00016 return m_pairs1.GetVoidValue(name, valueType, pValue) && m_pairs2.GetVoidValue(name, valueType, pValue); 00017 else 00018 return m_pairs1.GetVoidValue(name, valueType, pValue) || m_pairs2.GetVoidValue(name, valueType, pValue); 00019 } 00020 00021 void AlgorithmParametersBase::operator=(const AlgorithmParametersBase& rhs) 00022 { 00023 assert(false); 00024 } 00025 00026 bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const 00027 { 00028 if (strcmp(name, "ValueNames") == 0) 00029 { 00030 NameValuePairs::ThrowIfTypeMismatch(name, typeid(std::string), valueType); 00031 if (m_next.get()) 00032 m_next->GetVoidValue(name, valueType, pValue); 00033 (*reinterpret_cast<std::string *>(pValue) += m_name) += ";"; 00034 return true; 00035 } 00036 else if (strcmp(name, m_name) == 0) 00037 { 00038 AssignValue(name, valueType, pValue); 00039 m_used = true; 00040 return true; 00041 } 00042 else if (m_next.get()) 00043 return m_next->GetVoidValue(name, valueType, pValue); 00044 else 00045 return false; 00046 } 00047 00048 AlgorithmParameters::AlgorithmParameters() 00049 : m_defaultThrowIfNotUsed(true) 00050 { 00051 } 00052 00053 AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x) 00054 : m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed) 00055 { 00056 m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release()); 00057 } 00058 00059 AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x) 00060 { 00061 m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release()); 00062 return *this; 00063 } 00064 00065 bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const 00066 { 00067 if (m_next.get()) 00068 return m_next->GetVoidValue(name, valueType, pValue); 00069 else 00070 return false; 00071 } 00072 00073 NAMESPACE_END 00074 00075 #endif