Kea  1.9.9-git
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 
19 namespace isc {
20 namespace util {
21 class InputBuffer;
22 class OutputBuffer;
23 }
24 
25 namespace dns {
26 
27 class AbstractMessageRenderer;
28 class Question;
29 
31 typedef boost::shared_ptr<Question> QuestionPtr;
32 
34 typedef boost::shared_ptr<const Question> ConstQuestionPtr;
35 
95 class Question {
105 
106 public:
118 
128  Question(const Name& name, const RRClass& rrclass, const RRType& rrtype) :
129  name_(name), rrtype_(rrtype), rrclass_(rrclass)
130  {}
132 
136 
137  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  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  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 
264 private:
265  Name name_;
266  RRType rrtype_;
267  RRClass rrclass_;
268 };
269 
284 std::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 Name class encapsulates DNS names.
Definition: name.h:223
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
The Question class encapsulates the common search key of DNS lookup, consisting of owner name...
Definition: question.h:95
const Name & getName() const
Returns the owner name of the Question.
Definition: question.h:143
Question(const Name &name, const RRClass &rrclass, const RRType &rrtype)
Constructor from fixed parameters of the Question.
Definition: question.h:128
bool operator==(const Question &rhs) const
Equality operator.
Definition: question.h:248
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
bool operator!=(const Question &rhs) const
Inequality operator.
Definition: question.h:259
const RRType & getType() const
Returns the RR Class of the Question.
Definition: question.h:151
unsigned int toWire(AbstractMessageRenderer &renderer) const
Render the Question in the wire format with name compression.
Definition: question.cc:58
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
Question(isc::util::InputBuffer &buffer)
Constructor from wire-format data.
Definition: question.cc:24
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
const RRClass & getClass() const
Returns the RR Type of the Question.
Definition: question.h:159
Defines the logger used by the top-level component of kea-dhcp-ddns.
std::string toText(bool newline=false) const
Convert the Question to a string.
Definition: question.cc:38
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
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
boost::shared_ptr< Question > QuestionPtr
A pointer-like type pointing to an Question object.
Definition: question.h:28
boost::shared_ptr< const Question > ConstQuestionPtr
A pointer-like type pointing to an (immutable) Question object.
Definition: question.h:34