Index

DKNVPair

Purpose:

This class holds an arbitrary name and value pair. It is frequently used to pass parameters with varying numbers, names, and types. As the name suggests, DKNVPair has two parts; name and value. The name is a string name of the object stored in the value part. The value is a DKAny containing the named object.

Class summary:

 class DKNVPair
 {
public:
 
  dkNVPair(const char *InName = 0);
  dkNVPair(const char *InName, const DKAny &InValue);
 
  dkNVPair(const DKNVPair &fromPair);
 
  virtual DKNVPair();
 
  dkString getName() const;
  void     setName(const char* name);
 
  dkAny    getValue() const;
  void     setValue(const DKAny& value);
 
  void     set(const char* name, const DKAny& value);
 };

Members:

Constructor and destructor
The first constructor constructs an NVPair using the given name and value. In the second constructor, the name and value are copied from the input parameters. The third constructor is a copy constructor.

The destructor destroys the name and value in DKNVPair's internal representation. Since the value is stored in DKAny, it coincides with DKAny memory policy; that is, if the object is not managed by DKAny, then you must destroy it manually.

  dkNVPair(const char *InName = 0);
  dkNVPair(const char *InName, const DKAny &InValue);
  dkNVPair(const DKNVPair &fromPair);
 
  virtual DKNVPair();

Member functions

getName
Returns the name assigned to the object in this NVPair.
dkString getName() const;

setName
Assigns a name for the object in this NVPair.
void setName(const char* name);

getValue
Returns a DKAny containing the object stored in this NVPair.
dkAny getValue() const;

setValue
Stores an object contained in the given DKAny into this NVPair.
void setValue(const DKAny& value);

set
Stores an object contained in the given DKAny into this NVPair, and assigns a name to it.
void set(const char* name, const DKAny& value);

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.