Kea  2.1.7-git
rrttl.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 RRTTL_H
8 #define RRTTL_H 1
9 
10 #include <dns/exceptions.h>
11 
12 #include <boost/optional.hpp>
13 
14 #include <stdint.h>
15 
16 namespace isc {
17 namespace util {
18 class InputBuffer;
19 class OutputBuffer;
20 }
21 
22 namespace dns {
23 
24 // forward declarations
25 class AbstractMessageRenderer;
26 
31 class InvalidRRTTL : public DNSTextError {
32 public:
33  InvalidRRTTL(const char* file, size_t line, const char* what) :
34  DNSTextError(file, line, what) {}
35 };
36 
42 public:
43  IncompleteRRTTL(const char* file, size_t line, const char* what) :
44  isc::dns::Exception(file, line, what) {}
45 };
46 
55 class RRTTL {
56 public:
62 
63  explicit RRTTL(uint32_t ttlval) : ttlval_(ttlval) {}
69 
84  explicit RRTTL(const std::string& ttlstr);
85 
96  explicit RRTTL(isc::util::InputBuffer& buffer);
97 
125  static RRTTL* createFromText(const std::string& ttlstr);
127 
128 
132 
133  const std::string toText() const;
154  void toWire(AbstractMessageRenderer& renderer) const;
164  void toWire(isc::util::OutputBuffer& buffer) const;
166 
170 
171  uint32_t getValue() const { return (ttlval_); }
178 
186 
187  bool equals(const RRTTL& other) const
193  { return (ttlval_ == other.ttlval_); }
195  bool operator==(const RRTTL& other) const
196  { return (ttlval_ == other.ttlval_); }
202  bool nequals(const RRTTL& other) const
203  { return (ttlval_ != other.ttlval_); }
205  bool operator!=(const RRTTL& other) const
206  { return (ttlval_ != other.ttlval_); }
214  bool leq(const RRTTL& other) const
215  { return (ttlval_ <= other.ttlval_); }
216 
218  bool operator<=(const RRTTL& other) const
219  { return (ttlval_ <= other.ttlval_); }
220 
228  bool geq(const RRTTL& other) const
229  { return (ttlval_ >= other.ttlval_); }
230 
232  bool operator>=(const RRTTL& other) const
233  { return (ttlval_ >= other.ttlval_); }
234 
242  bool lthan(const RRTTL& other) const
243  { return (ttlval_ < other.ttlval_); }
244 
246  bool operator<(const RRTTL& other) const
247  { return (ttlval_ < other.ttlval_); }
248 
256  bool gthan(const RRTTL& other) const
257  { return (ttlval_ > other.ttlval_); }
258 
260  bool operator>(const RRTTL& other) const
261  { return (ttlval_ > other.ttlval_); }
263 
267 
268  static const RRTTL& MAX_TTL() {
275  static const RRTTL max_ttl(0x7fffffff);
276  return (max_ttl);
277  }
279 
280 private:
281  uint32_t ttlval_;
282 };
283 
298 std::ostream&
299 operator<<(std::ostream& os, const RRTTL& rrttl);
300 }
301 }
302 #endif // RRTTL_H
303 
304 // Local Variables:
305 // mode: c++
306 // End:
bool operator!=(const RRTTL &other) const
Same as nequals().
Definition: rrttl.h:205
bool operator>=(const RRTTL &other) const
Same as geq()
Definition: rrttl.h:232
Base class for all sorts of text parse errors.
bool geq(const RRTTL &other) const
Greater-than or equal comparison for RRTTL against other.
Definition: rrttl.h:228
std::ostream & operator<<(std::ostream &os, const CSVRow &row)
Overrides standard output stream operator for CSVRow object.
Definition: csv_file.cc:100
bool leq(const RRTTL &other) const
Less-than or equal comparison for RRTTL against other.
Definition: rrttl.h:214
bool operator<=(const RRTTL &other) const
Same as leq()
Definition: rrttl.h:218
bool operator<(const RRTTL &other) const
Same as lthan()
Definition: rrttl.h:246
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
bool operator==(const RRTTL &other) const
Same as equals().
Definition: rrttl.h:195
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition: rrttl.h:55
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
Defines the logger used by the top-level component of kea-lfc.
bool operator>(const RRTTL &other) const
Same as gthan()
Definition: rrttl.h:260
bool lthan(const RRTTL &other) const
Less-than comparison for RRTTL against other.
Definition: rrttl.h:242
bool nequals(const RRTTL &other) const
Return true iff two RRTTLs are not equal.
Definition: rrttl.h:202
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition: buffer.h:81
bool gthan(const RRTTL &other) const
Greater-than comparison for RRTTL against other.
Definition: rrttl.h:256
InvalidRRTTL(const char *file, size_t line, const char *what)
Definition: rrttl.h:33
A standard DNS module exception that is thrown if an RRTTL object is being constructed from an unreco...
Definition: rrttl.h:31
IncompleteRRTTL(const char *file, size_t line, const char *what)
Definition: rrttl.h:43
A standard DNS module exception that is thrown if an RRTTL object is being constructed from a incompl...
Definition: rrttl.h:41