Kea  1.9.9-git
isc::util::LabeledValue Class Reference

Implements the concept of a constant value with a text label. More...

#include <labeled_value.h>

+ Inheritance diagram for isc::util::LabeledValue:

Public Member Functions

 LabeledValue (const int value, const std::string &label)
 Constructor. More...
 
virtual ~LabeledValue ()
 Destructor. More...
 
std::string getLabel () const
 Gets the text label of this instance. More...
 
int getValue () const
 Gets the integer value of this instance. More...
 
bool operator!= (const LabeledValue &other) const
 Inequality operator. More...
 
bool operator< (const LabeledValue &other) const
 Less-than operator. More...
 
bool operator== (const LabeledValue &other) const
 Equality operator. More...
 

Detailed Description

Implements the concept of a constant value with a text label.

This class implements an association between a constant integer value and a text label. It provides a single constructor, accessors for both the value and label, and boolean operators which treat the value as the "key" for comparisons. This allows them to be assembled into dictionaries of unique values. Note, that the labels are not required to be unique but in practice it makes little sense to for them to be otherwise.

Definition at line 39 of file labeled_value.h.

Constructor & Destructor Documentation

isc::util::LabeledValue::LabeledValue ( const int  value,
const std::string &  label 
)

Constructor.

Parameters
valuethe numeric constant value to be labeled.
labelthe text label to associate to this value.
Exceptions
LabeledValueErrorif label is empty.

Definition at line 16 of file labeled_value.cc.

References isc_throw.

isc::util::LabeledValue::~LabeledValue ( )
virtual

Destructor.

Destructor is virtual to permit derivations.

Definition at line 23 of file labeled_value.cc.

Member Function Documentation

std::string isc::util::LabeledValue::getLabel ( ) const

Gets the text label of this instance.

Returns
The text label as string

Definition at line 32 of file labeled_value.cc.

Referenced by isc::util::operator<<().

int isc::util::LabeledValue::getValue ( ) const

Gets the integer value of this instance.

Returns
integer value of this instance.

Definition at line 27 of file labeled_value.cc.

bool isc::util::LabeledValue::operator!= ( const LabeledValue other) const

Inequality operator.

Returns
True if a.value_ is not equal to b.value_.

Definition at line 42 of file labeled_value.cc.

bool isc::util::LabeledValue::operator< ( const LabeledValue other) const

Less-than operator.

Returns
True if a.value_ is less than b.value_.

Definition at line 47 of file labeled_value.cc.

bool isc::util::LabeledValue::operator== ( const LabeledValue other) const

Equality operator.

Returns
True if a.value_ is equal to b.value_.

Definition at line 37 of file labeled_value.cc.


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