8 #ifndef CRYPTOPP_ALGPARAM_H 9 #define CRYPTOPP_ALGPARAM_H 15 #if (CRYPTOPP_MSC_VERSION >= 1400) 16 # pragma warning(push) 17 # pragma warning(disable: 6011 28193) 38 : m_deepCopy(false), m_data(NULL), m_size(0)
50 : m_deepCopy(false), m_data(NULL), m_size(0)
52 Assign(data, size, deepCopy);
62 : m_deepCopy(false), m_data(NULL), m_size(0)
65 Assign((
const byte *)
string.
data(),
string.
size(), deepCopy);
79 m_block.Assign(data, size);
85 m_deepCopy = deepCopy;
89 const byte *
begin()
const {
return m_deepCopy ? m_block.begin() : m_data;}
91 const byte *
end()
const {
return m_deepCopy ? m_block.end() : m_data + m_size;}
93 size_t size()
const {
return m_deepCopy ? m_block.size() : m_size;}
142 : m_pairs1(pairs1), m_pairs2(pairs2) {}
144 bool GetVoidValue(
const char *
name,
const std::type_info &valueType,
void *pValue)
const;
150 #ifndef CRYPTOPP_DOXYGEN_PROCESSING 151 template <
class T,
class BASE>
156 : m_pObject(pObject), m_name(name), m_valueType(&valueType), m_pValue(pValue), m_found(false), m_getValueNames(false)
158 if (strcmp(m_name,
"ValueNames") == 0)
160 m_found = m_getValueNames =
true;
164 if (
typeid(
T) !=
typeid(BASE))
165 pObject->BASE::GetVoidValue(m_name, valueType, pValue);
166 ((*
reinterpret_cast<std::string *
>(m_pValue) +=
"ThisPointer:") +=
typeid(
T).
name()) +=
';';
169 if (!m_found && strncmp(m_name,
"ThisPointer:", 12) == 0 && strcmp(m_name+12,
typeid(
T).
name()) == 0)
172 *
reinterpret_cast<const T **
>(pValue) = pObject;
177 if (!m_found && searchFirst)
178 m_found = searchFirst->
GetVoidValue(m_name, valueType, pValue);
180 if (!m_found &&
typeid(
T) !=
typeid(BASE))
181 m_found = pObject->BASE::GetVoidValue(m_name, valueType, pValue);
184 operator bool()
const {
return m_found;}
190 (*
reinterpret_cast<std::string *
>(m_pValue) += name) +=
";";
191 if (!m_found && strcmp(name, m_name) == 0)
194 *
reinterpret_cast<R *
>(m_pValue) = (m_pObject->*pm)();
202 #ifndef __INTEL_COMPILER // ICL 9.1 workaround: Intel compiler copies the vTable pointer for some reason 204 ((*
reinterpret_cast<std::string *
>(m_pValue) +=
"ThisObject:") +=
typeid(
T).
name()) +=
';';
205 if (!m_found && strncmp(m_name,
"ThisObject:", 11) == 0 && strcmp(m_name+11,
typeid(
T).
name()) == 0)
208 *
reinterpret_cast<T *
>(m_pValue) = *m_pObject;
223 template <
class BASE,
class T>
237 template <
class T,
class BASE>
242 : m_pObject(pObject), m_source(source), m_done(false)
246 else if (
typeid(BASE) !=
typeid(
T))
247 pObject->BASE::AssignFrom(source);
256 if (!m_source.GetValue(name, value))
257 throw InvalidArgument(std::string(
typeid(
T).
name()) +
": Missing required parameter '" + name +
"'");
258 (m_pObject->*pm)(value);
263 template <
class R,
class S>
269 if (!m_source.GetValue(name1, value1))
270 throw InvalidArgument(std::string(
typeid(
T).
name()) +
": Missing required parameter '" + name1 +
"'");
272 if (!m_source.GetValue(name2, value2))
273 throw InvalidArgument(std::string(
typeid(
T).
name()) +
": Missing required parameter '" + name2 +
"'");
274 (m_pObject->*pm)(value1, value2);
285 template <
class BASE,
class T>
297 #endif // CRYPTOPP_DOXYGEN_PROCESSING 322 #ifdef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 323 if (!std::uncaught_exception())
328 if (m_throwIfNotUsed && !m_used)
331 #ifndef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 340 : m_name(x.m_name), m_throwIfNotUsed(x.m_throwIfNotUsed), m_used(x.m_used)
342 m_next.reset(const_cast<AlgorithmParametersBase &>(x).m_next.release());
352 : m_name(name), m_throwIfNotUsed(throwIfNotUsed), m_used(false) {}
354 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
360 virtual void AssignValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const =0;
361 virtual void MoveInto(
void *p)
const =0;
387 void AssignValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const 390 if (!(g_pAssignIntToInteger != NULL &&
typeid(
T) ==
typeid(
int) &&
g_pAssignIntToInteger(valueType, pValue, &m_value)))
393 *
reinterpret_cast<T *
>(pValue) = m_value;
397 #if defined(DEBUG_NEW) && (_MSC_VER >= 1300) 398 # pragma push_macro("new") 408 #if defined(DEBUG_NEW) && (_MSC_VER >= 1300) 409 # pragma pop_macro("new") 442 , m_defaultThrowIfNotUsed(throwIfNotUsed)
461 m_defaultThrowIfNotUsed = throwIfNotUsed;
472 return operator()(name, value, m_defaultThrowIfNotUsed);
475 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
504 #define CRYPTOPP_GET_FUNCTION_ENTRY(name) (Name::name(), &ThisClass::Get##name) 505 #define CRYPTOPP_SET_FUNCTION_ENTRY(name) (Name::name(), &ThisClass::Set##name) 506 #define CRYPTOPP_SET_FUNCTION_ENTRY2(name1, name2) (Name::name1(), Name::name2(), &ThisClass::Set##name1##And##name2) 509 #if (CRYPTOPP_MSC_VERSION >= 1400) 510 # pragma warning(pop) Used to pass byte array input as part of a NameValuePairs object.
Base class for all exceptions thrown by the library.
An invalid argument was detected.
bool GetThisObject(T &object) const
Get a copy of this object or subobject.
CombinedNameValuePairs(const NameValuePairs &pairs1, const NameValuePairs &pairs2)
Construct a CombinedNameValuePairs.
Utility functions for the Crypto++ library.
bool(CRYPTOPP_API * PAssignIntToInteger)(const std::type_info &valueType, void *pInteger, const void *pInt)
member_ptr< AlgorithmParametersBase > m_next
const NameValuePairs & m_source
Base class for AlgorithmParameters.
AssignFromHelperClass(T *pObject, const NameValuePairs &source)
const std::type_info * m_valueType
#define NAMESPACE_BEGIN(x)
ConstByteArrayParameter(const T &string, bool deepCopy=false)
Construct a ConstByteArrayParameter.
#define CRYPTOPP_DLL_TEMPLATE_CLASS
AlgorithmParametersBase(const char *name, bool throwIfNotUsed)
Construct a AlgorithmParametersBase.
AssignFromHelperClass & operator()(const char *name1, const char *name2, void(T::*pm)(const R &, const S &))
ConstByteArrayParameter(const byte *data, size_t size, bool deepCopy=false)
Construct a ConstByteArrayParameter.
AlgorithmParametersBase(const AlgorithmParametersBase &x)
Abstract base classes that provide a uniform interface to this library.
Classes for automatic resource management.
size_t size() const
Length of the memory block.
Library configuration file.
member_ptr< AlgorithmParametersBase > m_next
std::hash for asio::adress
ConstByteArrayParameter(const char *data=NULL, bool deepCopy=false)
Construct a ConstByteArrayParameter.
CRYPTOPP_DLL const std::type_info &CRYPTOPP_API IntegerTypeId()
Combines two sets of NameValuePairs.
Used to pass byte array input as part of a NameValuePairs object.
const byte * begin() const
Pointer to the first byte in the memory block.
const NameValuePairs & m_pairs2
virtual CRYPTOPP_DLL bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0
Get a named value.
Classes and functions for secure memory allocations.
CRYPTOPP_DLL PAssignIntToInteger g_pAssignIntToInteger
GetValueHelperClass< T, BASE > & operator()(const char *name, const R &(T::*pm)() const)
#define CRYPTOPP_COMPILE_ASSERT(assertion)
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
ParameterNotUsed(const char *name)
Exception thrown when an AlgorithmParameter is unused.
byte * begin() const
Pointer to the first byte in the memory block.
void Assign(const byte *data, size_t size, bool deepCopy)
Assign contents from a memory buffer.
Template base class for AlgorithmParameters.
size_t size() const
Length of the memory block.
AssignFromHelperClass< T, BASE > AssignFromHelper(T *pObject, const NameValuePairs &source)
AlgorithmParameters & operator()(const char *name, const T &value)
Appends a NameValuePair to a collection of NameValuePairs.
GetValueHelperClass< T, BASE > & Assignable()
AssignFromHelperClass & operator()(const char *name, void(T::*pm)(const R &))
const byte * end() const
Pointer beyond the last byte in the memory block.
byte * end() const
Pointer beyond the last byte in the memory block.
ByteArrayParameter(byte *data=NULL, unsigned int size=0)
Construct a ByteArrayParameter.
AlgorithmParameters & operator=(const AlgorithmParameters &x)
ByteArrayParameter(SecByteBlock &block)
Construct a ByteArrayParameter.
void MoveInto(void *buffer) const
uint8_t const size_t const size
void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const
#define CRYPTOPP_UNUSED(x)
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
virtual ~AlgorithmParametersBase() CRYPTOPP_THROW
An object that implements NameValuePairs.
Multiple precision integer with arithmetic operations.
AlgorithmParametersTemplate(const char *name, const T &value, bool throwIfNotUsed)
Construct an AlgorithmParametersTemplate.
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.
GetValueHelperClass(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst)
Interface for retrieving values given their names.
GetValueHelperClass< T, BASE > GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULL)
bool m_defaultThrowIfNotUsed