The RRTTL
class encapsulates TTLs used in DNS resource records.
This is a straightforward class; an RRTTL
object simply maintains a 32-bit unsigned integer corresponding to the TTL value. The main purpose of this class is to provide convenient interfaces to convert a textual representation into the integer TTL value and vice versa, and to handle wire-format representations.
Definition at line 51 of file rrttl.h.
isc::dns::RRTTL::RRTTL |
( |
const std::string & | ttlstr | ) |
|
|
explicit |
Constructor from a string.
It accepts either a decimal number, specifying number of seconds. Or, it can be given a sequence of numbers and units, like "2H" (meaning two hours), "1W3D" (one week and 3 days). The allowed units are W (week), D (day), H (hour), M (minute) and S (second). They can be also specified in lower-case. No further restrictions are checked (so they can be specified in arbitrary order and even things like "1D1D" can be used to specify two days).
- Parameters
-
ttlstr | A string representation of the RRTTL . |
- Exceptions
-
InvalidRRTTL | in case the string is not recognized as valid TTL representation. |
Definition at line 168 of file rrttl.cc.
References isc_throw.
RRTTL * isc::dns::RRTTL::createFromText |
( |
const std::string & | ttlstr | ) |
|
|
static |
A separate factory of RRTTL from text.
This static method is similar to the constructor that takes a string object, but works as a factory and reports parsing failure in the form of the return value. Normally the constructor version should suffice, but in some cases the caller may have to expect mixture of valid and invalid input, and may want to minimize the overhead of possible exception handling. This version is provided for such purpose.
If the given text represents a valid RRTTL, it returns a pointer to a new RRTTL object. If the given text does not represent a valid RRTTL, it returns null..
One main purpose of this function is to minimize the overhead when the given text does not represent a valid RR TTL. For this reason this function intentionally omits the capability of delivering a detailed reason for the parse failure, such as in the want()
string when exception is thrown from the constructor (it will internally require a creation of string object, which is relatively expensive). If such detailed information is necessary, the constructor version should be used to catch the resulting exception.
This function never throws the InvalidRRTTL
exception.
- Parameters
-
ttlstr | A string representation of the RRTTL . |
- Returns
- A new RRTTL object for the given text or a null value.
Definition at line 176 of file rrttl.cc.
References RRTTL().
const string isc::dns::RRTTL::toText |
( |
| ) |
const |
Convert the RRTTL
to a string.
This version of implementation simply converts the TTL value into the numeric textual representation. We may introduce more human-readable format depending on the context in future versions.
If resource allocation in rendering process fails, a corresponding standard exception will be thrown.
- Returns
- A string representation of the
RRTTL
.
Definition at line 192 of file rrttl.cc.
Render the RRTTL
in the wire format.
This method renders the TTL value in network byte order via renderer
, which encapsulates output buffer and other rendering contexts.
If resource allocation in rendering process fails, a corresponding standard exception will be thrown.
- Parameters
-
renderer | DNS message rendering context that encapsulates the output buffer in which the RRTTL is to be stored. |
Definition at line 204 of file rrttl.cc.
Referenced by isc::dns::BasicRRsetImpl::toWire().