Crypto++ 8.9 Free C++ class library of cryptographic schemes

Classes | Public Member Functions | Static Public Member Functions | List of all members
NameValuePairs Class Referenceabstract

Interface for retrieving values given their names. More...

Inheritance diagram for NameValuePairs:

## Classes
class | ValueTypeMismatch
| Thrown when an unexpected type is encountered. More...

## Public Member Functions
template<class T >
bool | GetThisObject (T &object) const
| Get a copy of this object or subobject. More...
template<class T >
bool | GetThisPointer (T *&ptr) const
| Get a pointer to this object. More...
template<class T >
bool | GetValue (const char *name, T &value) const
| Get a named value. More...
template<class T >
T | GetValueWithDefault (const char *name, T defaultValue) const
| Get a named value. More...
CRYPTOPP_DLL std::string | GetValueNames () const
| Get a list of value names that can be retrieved. More...
CRYPTOPP_DLL bool | GetIntValue (const char *name, int &value) const
| Get a named value with type int. More...
CRYPTOPP_DLL int | GetIntValueWithDefault (const char *name, int defaultValue) const
| Get a named value with type int, with default. More...
CRYPTOPP_DLL bool | GetWord64Value (const char *name, word64 &value) const
| Get a named value with type word64. More...
CRYPTOPP_DLL word64 | GetWord64ValueWithDefault (const char *name, word64 defaultValue) const
| Get a named value with type word64, with default. More...
template<class T >
void | GetRequiredParameter (const char *className, const char *name, T &value) const
| Retrieves a required name/value pair. More...
CRYPTOPP_DLL void | GetRequiredIntParameter (const char *className, const char *name, int &value) const
| Retrieves a required name/value pair. More...
virtual CRYPTOPP_DLL bool | GetVoidValue (const char *name, const std::type_info &valueType, void *pValue) const =0
| Get a named value. More...

## Static Public Member Functions
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. More...

## Detailed Description

Interface for retrieving values given their names.

This class is used to safely pass a variable number of arbitrarily typed arguments to functions and to read values from keys and crypto parameters.

To obtain an object that implements NameValuePairs for the purpose of parameter passing, use the MakeParameters() function.

To get a value from NameValuePairs, you need to know the name and the type of the value. Call GetValueNames() on a NameValuePairs object to obtain a list of value names that it supports. then look at the Name namespace documentation to see what the type of each value is, or alternatively, call GetIntValue() with the value name, and if the type is not int, a ValueTypeMismatch exception will be thrown and you can get the actual type from the exception object.

See also
  NullNameValuePairs, g_nullNameValuePairs, NameValuePairs on the Crypto++ wiki

Definition at line 326 of file cryptlib.h.

## Member Function Documentation

## ◆ GetThisObject()

template<class T >

bool NameValuePairs::GetThisObject | ( | T & | object | ) | const
| inline

Get a copy of this object or subobject.

Template Parameters

  T | class or type

Parameters

  object | reference to a variable that receives the value

Definition at line 362 of file cryptlib.h.

## ◆ GetThisPointer()

template<class T >

bool NameValuePairs::GetThisPointer | ( | T *& | ptr | ) | const
| inline

Get a pointer to this object.

Template Parameters

  T | class or type

Parameters

  ptr | reference to a pointer to a variable that receives the value

Definition at line 371 of file cryptlib.h.

## ◆ GetValue()

template<class T >

bool NameValuePairs::GetValue | ( | const char * | name,
|  | T & | value
| ) |  | const
| inline

Get a named value.

Template Parameters

  T | class or type

Parameters

  name | the name of the object or value to retrieve
  value | reference to a variable that receives the value

Returns
  true if the value was retrieved, false otherwise

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 384 of file cryptlib.h.

## ◆ GetValueWithDefault()

template<class T >

T NameValuePairs::GetValueWithDefault | ( | const char * | name,
|  | T | defaultValue
| ) |  | const
| inline

Get a named value.

Template Parameters

  T | class or type

Parameters

  name | the name of the object or value to retrieve
  defaultValue | the default value of the class or type if it does not exist

Returns
  the object or value

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 397 of file cryptlib.h.

## ◆ GetValueNames()

CRYPTOPP_DLL std::string NameValuePairs::GetValueNames | ( |  | ) | const
| inline

Get a list of value names that can be retrieved.

Returns
  a list of names available to retrieve

the items in the list are delimited with a colon.

Definition at line 409 of file cryptlib.h.

## ◆ GetIntValue()

CRYPTOPP_DLL bool NameValuePairs::GetIntValue | ( | const char * | name,
|  | int & | value
| ) |  | const
| inline

Get a named value with type int.

Parameters

  name | the name of the value to retrieve
  value | the value retrieved upon success

Returns
  true if an int value was retrieved, false otherwise

GetIntValue() is used to ensure we don't accidentally try to get an unsigned int or some other type when we mean int (which is the most common case)

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 420 of file cryptlib.h.

## ◆ GetIntValueWithDefault()

CRYPTOPP_DLL int NameValuePairs::GetIntValueWithDefault | ( | const char * | name,
|  | int | defaultValue
| ) |  | const
| inline

Get a named value with type int, with default.

Parameters

  name | the name of the value to retrieve
  defaultValue | the default value if the name does not exist

Returns
  the value retrieved on success or the default value

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 429 of file cryptlib.h.

## ◆ GetWord64Value()

CRYPTOPP_DLL bool NameValuePairs::GetWord64Value | ( | const char * | name,
|  | word64 & | value
| ) |  | const
| inline

Get a named value with type word64.

Parameters

  name | the name of the value to retrieve
  value | the value retrieved upon success

Returns
  true if an word64 value was retrieved, false otherwise

See also
  GetValue(), GetValueWithDefault(), GetWord64ValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 438 of file cryptlib.h.

## ◆ GetWord64ValueWithDefault()

CRYPTOPP_DLL word64 NameValuePairs::GetWord64ValueWithDefault | ( | const char * | name,
|  | word64 | defaultValue
| ) |  | const
| inline

Get a named value with type word64, with default.

Parameters

  name | the name of the value to retrieve
  defaultValue | the default value if the name does not exist

Returns
  the value retrieved on success or the default value

See also
  GetValue(), GetValueWithDefault(), GetWord64Value(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredWord64Parameter()

Definition at line 447 of file cryptlib.h.

## ◆ ThrowIfTypeMismatch()

static CRYPTOPP_DLL void NameValuePairs::ThrowIfTypeMismatch | ( | const char * | name,
|  | const std::type_info & | stored,
|  | const std::type_info & | retrieving
| ) |  |
| inline static

Ensures an expected name and type is present.

Parameters

  name | the name of the value
  stored | the type that was stored for the name
  retrieving | the type that is being retrieved for the name

Exceptions

  ValueTypeMismatch |

ThrowIfTypeMismatch() effectively performs a type safety check. stored and retrieving are C++ mangled names for the type.

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 459 of file cryptlib.h.

## ◆ GetRequiredParameter()

template<class T >

void NameValuePairs::GetRequiredParameter | ( | const char * | className,
|  | const char * | name,
|  | T & | value
| ) |  | const
| inline

Retrieves a required name/value pair.

Template Parameters

  T | class or type

Parameters

  className | the name of the class
  name | the name of the value
  value | reference to a variable to receive the value

Exceptions

  InvalidArgument |

GetRequiredParameter() throws InvalidArgument if the name is not present or not of the expected type T.

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 473 of file cryptlib.h.

## ◆ GetRequiredIntParameter()

CRYPTOPP_DLL void NameValuePairs::GetRequiredIntParameter | ( | const char * | className,
|  | const char * | name,
|  | int & | value
| ) |  | const
| inline

Retrieves a required name/value pair.

Parameters

  className | the name of the class
  name | the name of the value
  value | reference to a variable to receive the value

Exceptions

  InvalidArgument |

GetRequiredParameter() throws InvalidArgument if the name is not present or not of the expected type T.

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 488 of file cryptlib.h.

## ◆ GetVoidValue()

virtual CRYPTOPP_DLL bool NameValuePairs::GetVoidValue | ( | const char * | name,
|  | const std::type_info & | valueType,
|  | void * | pValue
| ) |  | const
| pure virtual

Get a named value.

Parameters

  name | the name of the object or value to retrieve
  valueType | reference to a variable that receives the value
  pValue | void pointer to a variable that receives the value

Returns
  true if the value was retrieved, false otherwise

GetVoidValue() retrieves the value of name if it exists.

Note
  GetVoidValue() is an internal function and should be implemented by derived classes. Users should use one of the other functions instead.

See also
  GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Implemented in XTR_DH, ed25519PublicKey, ed25519PrivateKey, x25519, InvertibleRWFunction, RWFunction, InvertibleRSAFunction, RSAFunction, InvertibleRabinFunction, RabinFunction, DL_PublicKeyImpl< GP >, DL_PrivateKeyImpl< GP >, DL_GroupParameters< T >, DL_GroupParameters< typename GROUP_PRECOMP::Element >, DL_GroupParameters_LUC, InvertibleLUCFunction, LUCFunction, DL_GroupParameters_GFP, DL_GroupParameters_IntegerBasedImpl< GROUP_PRECOMP, BASE_PRECOMP >, DL_GroupParameters_IntegerBasedImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC >, DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation >, DL_GroupParameters_IntegerBased, InvertibleESIGNFunction, ESIGNFunction, DL_GroupParameters_EC< EC >, AlgorithmParameters, and CombinedNameValuePairs.

The documentation for this class was generated from the following file:

- cryptlib.h