Kea 2.5.4
question.h
Go to the documentation of this file.
1// Copyright (C) 2010-2015 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 QUESTION_H
8#define QUESTION_H 1
9
10#include <iostream>
11#include <string>
12
13#include <boost/shared_ptr.hpp>
14
15#include <dns/name.h>
16#include <dns/rrclass.h>
17#include <dns/rrtype.h>
18
19namespace isc {
20namespace util {
21class InputBuffer;
22class OutputBuffer;
23}
24
25namespace dns {
26
27class AbstractMessageRenderer;
28class Question;
29
31typedef boost::shared_ptr<Question> QuestionPtr;
32
34typedef boost::shared_ptr<const Question> ConstQuestionPtr;
35
95class Question {
105
106public:
118
128 Question(const Name& name, const RRClass& rrclass, const RRType& rrtype) :
129 name_(name), rrtype_(rrtype), rrclass_(rrclass)
130 {}
132
136
137
143 const Name& getName() const { return (name_); }
144
151 const RRType& getType() const { return (rrtype_); }
152
159 const RRClass& getClass() const { return (rrclass_); }
161
165
166
183 std::string toText(bool newline = false) const;
184
217 unsigned int toWire(AbstractMessageRenderer& renderer) const;
218
227 unsigned int toWire(isc::util::OutputBuffer& buffer) const;
229
233
234
236 bool operator <(const Question& rhs) const {
237 return (rrclass_ < rhs.rrclass_ ||
238 (rrclass_ == rhs.rrclass_ &&
239 (rrtype_ < rhs.rrtype_ ||
240 (rrtype_ == rhs.rrtype_ && (name_ < rhs.name_)))));
241 }
242
248 bool operator==(const Question& rhs) const {
249 return ((rrclass_ == rhs.rrclass_) && (rrtype_ == rhs.rrtype_) &&
250 (name_ == rhs.name_));
251 }
252
259 bool operator!=(const Question& rhs) const {
260 return (!operator==(rhs));
261 }
263
264private:
265 Name name_;
266 RRType rrtype_;
267 RRClass rrclass_;
268};
269
284std::ostream& operator<<(std::ostream& os, const Question& question);
285} // end of namespace dns
286} // end of namespace isc
287#endif // QUESTION_H
288
289// Local Variables:
290// mode: c++
291// End:
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
The Name class encapsulates DNS names.
Definition: name.h:223
The Question class encapsulates the common search key of DNS lookup, consisting of owner name,...
Definition: question.h:95
std::string toText(bool newline=false) const
Convert the Question to a string.
Definition: question.cc:38
Question(const Name &name, const RRClass &rrclass, const RRType &rrtype)
Constructor from fixed parameters of the Question.
Definition: question.h:128
Question(isc::util::InputBuffer &buffer)
Constructor from wire-format data.
Definition: question.cc:24
const Name & getName() const
Returns the owner name of the Question.
Definition: question.h:143
bool operator<(const Question &rhs) const
A "less than" operator is needed for this class so it can function as an index to std::map.
Definition: question.h:236
const RRType & getType() const
Returns the RR Class of the Question.
Definition: question.h:151
bool operator==(const Question &rhs) const
Equality operator.
Definition: question.h:248
bool operator!=(const Question &rhs) const
Inequality operator.
Definition: question.h:259
const RRClass & getClass() const
Returns the RR Type of the Question.
Definition: question.h:159
unsigned int toWire(AbstractMessageRenderer &renderer) const
Render the Question in the wire format with name compression.
Definition: question.cc:58
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition: buffer.h:81
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
boost::shared_ptr< Question > QuestionPtr
A pointer-like type pointing to an Question object.
Definition: question.h:31
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
boost::shared_ptr< const Question > ConstQuestionPtr
A pointer-like type pointing to an (immutable) Question object.
Definition: question.h:34
Defines the logger used by the top-level component of kea-lfc.