Kea 3.3.1
isc::dhcp::ClientClasses Class Reference

Container for storing client class names. More...

#include <classify.h>

Inheritance diagram for isc::dhcp::ClientClasses:

Classes

struct  Hash
 Hash enabling use in the unordered containers. More...

Public Types

typedef ClientClassContainer::const_iterator const_iterator
 Type of iterators.
typedef ClientClassContainer::iterator iterator

Public Member Functions

 ClientClasses ()
 Default constructor.
 ClientClasses (const ClientClasses &other)
 Copy constructor.
 ClientClasses (const std::string &class_names)
 Constructor from comma separated values.
virtual ~ClientClasses ()
 Destructor.
void clear ()
 Clears containers.
bool contains (const ClientClass &x) const
 returns if class x belongs to the defined classes
bool empty () const
 Check if classes is empty.
bool equals (const ClientClasses &other) const
 Compares two ClientClasses container for equality.
void erase (const ClientClass &class_name)
 Erase element by name.
void fromElement (isc::data::ConstElementPtr list)
 Sets contents from a ListElement.
void insert (const ClientClass &class_name)
 Insert an element.
bool intersects (const ClientClasses &cclasses) const
 returns whether this container has at least one class in common with a given container.
bool operator!= (const ClientClasses &other) const
 Compares two ClientClasses container for inequality.
ClientClassesoperator= (const ClientClasses &other)
 Assigns the contents of on container to another.
bool operator== (const ClientClasses &other) const
 Compares two ClientClasses containers for equality.
size_t size () const
 Returns the number of classes.
virtual isc::data::ElementPtr toElement () const
 Returns all class names as an ElementPtr of type ListElement.
std::string toText (const std::string &separator=", ") const
 Returns all class names as text.
const_iterator cbegin () const
 Iterators to the first element.
const_iterator begin () const
iterator begin ()
const_iterator cend () const
 Iterators to the past the end element.
const_iterator end () const
iterator end ()
Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor.

Static Public Member Functions

static std::string escape (const std::string &name, bool escape_escape=true)
 Escape a client class name.

Static Public Attributes

static constexpr char CLIENT_CLASS_ESCAPE = '%'
 Escape character.
static const std::vector< bool > CLIENT_CLASS_VALID_CHARACTERS
 Valid character in a client class name boolean vector.

Detailed Description

Container for storing client class names.

Both a list to iterate on it in insert order and unordered set of names for existence.

Definition at line 111 of file classify.h.

Member Typedef Documentation

◆ const_iterator

typedef ClientClassContainer::const_iterator isc::dhcp::ClientClasses::const_iterator

Type of iterators.

Definition at line 115 of file classify.h.

◆ iterator

typedef ClientClassContainer::iterator isc::dhcp::ClientClasses::iterator

Definition at line 116 of file classify.h.

Constructor & Destructor Documentation

◆ ClientClasses() [1/3]

isc::dhcp::ClientClasses::ClientClasses ( )
inline

◆ ClientClasses() [2/3]

isc::dhcp::ClientClasses::ClientClasses ( const std::string & class_names)

Constructor from comma separated values.

Parameters
class_namesA string containing a client classes separated with commas. The class names are trimmed before insertion to the set.

Definition at line 22 of file classify.cc.

References insert(), and isc::util::str::trim().

Here is the call graph for this function:

◆ ~ClientClasses()

virtual isc::dhcp::ClientClasses::~ClientClasses ( )
inlinevirtual

Destructor.

Definition at line 129 of file classify.h.

◆ ClientClasses() [3/3]

isc::dhcp::ClientClasses::ClientClasses ( const ClientClasses & other)

Copy constructor.

Parameters
otherClientClasses object to be copied.

Definition at line 36 of file classify.cc.

References ClientClasses(), and insert().

Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

iterator isc::dhcp::ClientClasses::begin ( )
inline

Definition at line 193 of file classify.h.

◆ begin() [2/2]

const_iterator isc::dhcp::ClientClasses::begin ( ) const
inline

Definition at line 189 of file classify.h.

◆ cbegin()

const_iterator isc::dhcp::ClientClasses::cbegin ( ) const
inline

Iterators to the first element.

Definition at line 185 of file classify.h.

Referenced by equals().

◆ cend()

const_iterator isc::dhcp::ClientClasses::cend ( ) const
inline

Iterators to the past the end element.

Definition at line 200 of file classify.h.

Referenced by equals().

◆ clear()

void isc::dhcp::ClientClasses::clear ( )
inline

Clears containers.

Definition at line 228 of file classify.h.

Referenced by fromElement(), and operator=().

◆ contains()

bool isc::dhcp::ClientClasses::contains ( const ClientClass & x) const

returns if class x belongs to the defined classes

Parameters
xclient class to be checked
Returns
true if x belongs to the classes

Definition at line 52 of file classify.cc.

Referenced by intersects().

◆ empty()

◆ end() [1/2]

iterator isc::dhcp::ClientClasses::end ( )
inline

Definition at line 208 of file classify.h.

◆ end() [2/2]

const_iterator isc::dhcp::ClientClasses::end ( ) const
inline

Definition at line 204 of file classify.h.

◆ equals()

bool isc::dhcp::ClientClasses::equals ( const ClientClasses & other) const

Compares two ClientClasses container for equality.

Returns
True if the two containers are equal, false otherwise.

Definition at line 120 of file classify.cc.

References ClientClasses(), cbegin(), cend(), and size().

Referenced by operator!=(), and operator==().

Here is the call graph for this function:

◆ erase()

void isc::dhcp::ClientClasses::erase ( const ClientClass & class_name)

Erase element by name.

Parameters
class_nameThe name of the class to erase.

Definition at line 43 of file classify.cc.

◆ escape()

std::string isc::dhcp::ClientClasses::escape ( const std::string & name,
bool escape_escape = true )
static

Escape a client class name.

Valid characters are letters, digits and "!#$%&*+-./:?@^_|~".

For generated names we need that when name1 != name2 escape(name1) != escape(name2), and for configured names escape(escape(name)) == escape(name) for all names. So escape the escape character itself for generated but not for configured names.

Parameters
nameCandidate client class name.
escape_escapeWhen true (default) escape the escape character.
Returns
The name using 'xy' escapes for invalid characters, and doubling ''.

Definition at line 164 of file classify.cc.

References isc::util::str::byteToHex(), CLIENT_CLASS_ESCAPE, and CLIENT_CLASS_VALID_CHARACTERS.

Referenced by isc::dhcp::Dhcpv4Exchange::classifyByVendor(), isc::dhcp::ClientClassDefParser::parse(), and isc::dhcp::TemplateClientClassDef::test().

Here is the call graph for this function:

◆ fromElement()

void isc::dhcp::ClientClasses::fromElement ( isc::data::ConstElementPtr list)

Sets contents from a ListElement.

Parameters
listJSON list of classes from which to populate the container.
Exceptions
BadValueif the element is not a list or contents are invalid

Definition at line 101 of file classify.cc.

References clear(), insert(), isc_throw, isc::data::Element::list, and isc::data::Element::string.

Referenced by isc::dhcp::OptionDataParser::createOption().

Here is the call graph for this function:

◆ insert()

◆ intersects()

bool isc::dhcp::ClientClasses::intersects ( const ClientClasses & cclasses) const

returns whether this container has at least one class in common with a given container.

Parameters
cclasseslist of classes to check for intersection with
Returns
true if this container has at least one class that is also in cclasses, false otherwise.

Definition at line 58 of file classify.cc.

References ClientClasses(), contains(), and size().

Here is the call graph for this function:

◆ operator!=()

bool isc::dhcp::ClientClasses::operator!= ( const ClientClasses & other) const
inline

Compares two ClientClasses container for inequality.

Returns
True if the two containers are not equal, false otherwise.

Definition at line 154 of file classify.h.

References ClientClasses(), and equals().

Here is the call graph for this function:

◆ operator=()

ClientClasses & isc::dhcp::ClientClasses::operator= ( const ClientClasses & other)

Assigns the contents of on container to another.

Definition at line 125 of file classify.cc.

References ClientClasses(), clear(), and insert().

Here is the call graph for this function:

◆ operator==()

bool isc::dhcp::ClientClasses::operator== ( const ClientClasses & other) const
inline

Compares two ClientClasses containers for equality.

Returns
True if the two containers are equal, false otherwise.

Definition at line 147 of file classify.h.

References ClientClasses(), and equals().

Here is the call graph for this function:

◆ size()

size_t isc::dhcp::ClientClasses::size ( ) const
inline

Returns the number of classes.

Note
; in C++ 11 list size complexity is constant so there is no advantage to use the set part.

Definition at line 179 of file classify.h.

Referenced by equals(), and intersects().

◆ toElement()

ElementPtr isc::dhcp::ClientClasses::toElement ( ) const
virtual

Returns all class names as an ElementPtr of type ListElement.

Returns
the list

Implements isc::data::CfgToElement.

Definition at line 92 of file classify.cc.

References isc::data::Element::create(), and isc::data::Element::createList().

Here is the call graph for this function:

◆ toText()

std::string isc::dhcp::ClientClasses::toText ( const std::string & separator = ", ") const

Returns all class names as text.

Parameters
separatorSeparator to be used between class names. The default separator comprises comma sign followed by space character.
Returns
the string representation of all classes

Definition at line 77 of file classify.cc.

Referenced by isc::dhcp::Dhcpv4Exchange::Dhcpv4Exchange(), isc::dhcp::hash_value(), isc::dhcp::Dhcpv6Srv::initContext(), and isc::dhcp::CfgOption::replace().

Member Data Documentation

◆ CLIENT_CLASS_ESCAPE

char isc::dhcp::ClientClasses::CLIENT_CLASS_ESCAPE = '%'
staticconstexpr

Escape character.

Definition at line 268 of file classify.h.

Referenced by escape().

◆ CLIENT_CLASS_VALID_CHARACTERS

const std::vector< bool > isc::dhcp::ClientClasses::CLIENT_CLASS_VALID_CHARACTERS
static
Initial value:
= {
false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false,
false, true, false, true, true, true, true, false,
false, false, true, true, false, true, true, true,
true, true, true, true, true, true, true, true,
true, true, true, false, false, false, false, true,
true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true,
true, true, true, false, false, false, true, true,
false, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true,
true, true, true, false, true, false, true, false,
}

Valid character in a client class name boolean vector.

Definition at line 265 of file classify.h.

Referenced by escape().


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