Kea 2.7.6
labeled_value.h
Go to the documentation of this file.
1// Copyright (C) 2013-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef LABELED_VALUE_H
8#define LABELED_VALUE_H
9
11
12#include <boost/shared_ptr.hpp>
13#include <ostream>
14#include <string>
15#include <map>
16
19
20namespace isc {
21namespace util {
22
25public:
26 LabeledValueError(const char* file, size_t line, const char* what) :
27 isc::Exception(file, line, what) { }
28};
29
40public:
41
48 LabeledValue(const int value, const std::string& label);
49
53 virtual ~LabeledValue();
54
58 int getValue() const;
59
63 std::string getLabel() const;
64
68 bool operator==(const LabeledValue& other) const;
69
73 bool operator!=(const LabeledValue& other) const;
74
78 bool operator<(const LabeledValue& other) const;
79
80private:
82 int value_;
83
85 std::string label_;
86};
87
89std::ostream& operator<<(std::ostream& os, const LabeledValue& vlp);
90
92typedef boost::shared_ptr<LabeledValue> LabeledValuePtr;
93
95typedef std::map<unsigned int, LabeledValuePtr> LabeledValueMap;
96
97
115public:
117 static const char* UNDEFINED_LABEL;
118
123
127 virtual ~LabeledValueSet();
128
135 void add(LabeledValuePtr entry);
136
144 void add(const int value, const std::string& label);
145
152 const LabeledValuePtr& get(int value);
153
159 bool isDefined(const int value) const;
160
167 std::string getLabel(const int value) const;
168
169private:
171 LabeledValueMap map_;
172};
173
174} // namespace isc::util
175} // namespace isc
176#endif
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Thrown if an error is encountered handling a LabeledValue.
LabeledValueError(const char *file, size_t line, const char *what)
Implements a set of unique LabeledValues.
static const char * UNDEFINED_LABEL
Defines a text label returned by when value is not found.
bool isDefined(const int value) const
Tests if the set contains an entry for the given value.
const LabeledValuePtr & get(int value)
Fetches a pointer to the entry associated with value.
virtual ~LabeledValueSet()
Destructor.
std::string getLabel(const int value) const
Fetches the label for the given value.
void add(LabeledValuePtr entry)
Adds the given entry to the set.
Implements the concept of a constant value with a text label.
int getValue() const
Gets the integer value of this instance.
bool operator!=(const LabeledValue &other) const
Inequality operator.
LabeledValue(const int value, const std::string &label)
Constructor.
bool operator==(const LabeledValue &other) const
Equality operator.
bool operator<(const LabeledValue &other) const
Less-than operator.
std::string getLabel() const
Gets the text label of this instance.
virtual ~LabeledValue()
Destructor.
std::ostream & operator<<(std::ostream &os, const CSVRow &row)
Overrides standard output stream operator for CSVRow object.
Definition csv_file.cc:100
std::map< unsigned int, LabeledValuePtr > LabeledValueMap
Defines a map of pointers to LabeledValues keyed by value.
boost::shared_ptr< LabeledValue > LabeledValuePtr
Defines a shared pointer to a LabeledValue instance.
Defines the logger used by the top-level component of kea-lfc.