1 // Copyright (C) 2011-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 // BEGIN_HEADER_GUARD 8 9 #include <string> 10 11 #include <dns/name.h> 12 #include <dns/rdata.h> 13 14 // BEGIN_ISC_NAMESPACE 15 16 // BEGIN_COMMON_DECLARATIONS 17 // END_COMMON_DECLARATIONS 18 19 // BEGIN_RDATA_NAMESPACE 20 21 /// \brief \c rdata::generic::RP class represents the RP RDATA as defined in 22 /// RFC1183. 23 /// 24 /// This class implements the basic interfaces inherited from the abstract 25 /// \c rdata::Rdata class, and provides trivial accessors specific to the 26 /// RP RDATA. 27 class RP : public Rdata { 28 public: 29 // BEGIN_COMMON_MEMBERS 30 // END_COMMON_MEMBERS 31 32 /// We use the default copy constructor and assignment operator. 33 34 /// \brief Constructor from RDATA field parameters. 35 /// 36 /// The parameters are a straightforward mapping of %RP RDATA 37 /// fields as defined in RFC1183. RP(const Name & mailbox,const Name & text)38 RP(const Name& mailbox, const Name& text) : 39 mailbox_(mailbox), text_(text) 40 {} 41 42 /// \brief Return the value of the mailbox field. 43 /// 44 /// \throw std::bad_alloc If resource allocation for the returned 45 /// \c Name fails. 46 /// 47 /// \note 48 /// Unlike the case of some other RDATA classes (such as 49 /// \c NS::getNSName()), this method constructs a new \c Name object 50 /// and returns it, instead of returning a reference to a \c Name object 51 /// internally maintained in the class (which is a private member). 52 /// This is based on the observation that this method will be rarely used 53 /// and even when it's used it will not be in a performance context 54 /// (for example, a recursive resolver won't need this field in its 55 /// resolution process). By returning a new object we have flexibility of 56 /// changing the internal representation without the risk of changing 57 /// the interface or method property. 58 /// The same note applies to the \c getText() method. getMailbox()59 Name getMailbox() const { return (mailbox_); } 60 61 /// \brief Return the value of the text field. 62 /// 63 /// \throw std::bad_alloc If resource allocation for the returned 64 /// \c Name fails. getText()65 Name getText() const { return (text_); } 66 67 private: 68 Name mailbox_; 69 Name text_; 70 }; 71 72 // END_RDATA_NAMESPACE 73 // END_ISC_NAMESPACE 74 // END_HEADER_GUARD 75 76 // Local Variables: 77 // mode: c++ 78 // End: 79