dlv_32769.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <string>
  15. #include <util/buffer.h>
  16. #include <util/encode/hex.h>
  17. #include <dns/messagerenderer.h>
  18. #include <dns/rdata.h>
  19. #include <dns/rdataclass.h>
  20. #include <dns/rdata/generic/detail/ds_like.h>
  21. using namespace std;
  22. using namespace isc::util;
  23. using namespace isc::util::encode;
  24. using namespace isc::dns::rdata::generic::detail;
  25. // BEGIN_ISC_NAMESPACE
  26. // BEGIN_RDATA_NAMESPACE
  27. /// \brief Constructor from string.
  28. ///
  29. /// A copy of the implementation object is allocated and constructed.
  30. DLV::DLV(const std::string& ds_str) :
  31. impl_(new DLVImpl(ds_str))
  32. {}
  33. /// \brief Constructor from wire-format data.
  34. ///
  35. /// A copy of the implementation object is allocated and constructed.
  36. DLV::DLV(InputBuffer& buffer, size_t rdata_len) :
  37. impl_(new DLVImpl(buffer, rdata_len))
  38. {}
  39. /// \brief Copy constructor
  40. ///
  41. /// A copy of the implementation object is allocated and constructed.
  42. DLV::DLV(const DLV& source) :
  43. Rdata(), impl_(new DLVImpl(*source.impl_))
  44. {}
  45. /// \brief Assignment operator
  46. ///
  47. /// PIMPL-induced logic
  48. DLV&
  49. DLV::operator=(const DLV& source) {
  50. if (impl_ == source.impl_) {
  51. return (*this);
  52. }
  53. DLVImpl* newimpl = new DLVImpl(*source.impl_);
  54. delete impl_;
  55. impl_ = newimpl;
  56. return (*this);
  57. }
  58. /// \brief Destructor
  59. ///
  60. /// Deallocates an internal resource.
  61. DLV::~DLV() {
  62. delete impl_;
  63. }
  64. /// \brief Convert the \c DLV to a string.
  65. ///
  66. /// A pass-thru to the corresponding implementation method.
  67. string
  68. DLV::toText() const {
  69. return (impl_->toText());
  70. }
  71. /// \brief Render the \c DLV in the wire format to a OutputBuffer object
  72. ///
  73. /// A pass-thru to the corresponding implementation method.
  74. void
  75. DLV::toWire(OutputBuffer& buffer) const {
  76. impl_->toWire(buffer);
  77. }
  78. /// \brief Render the \c DLV in the wire format to a AbstractMessageRenderer
  79. /// object
  80. ///
  81. /// A pass-thru to the corresponding implementation method.
  82. void
  83. DLV::toWire(AbstractMessageRenderer& renderer) const {
  84. impl_->toWire(renderer);
  85. }
  86. /// \brief Compare two instances of \c DLV RDATA.
  87. ///
  88. /// The type check is performed here. Otherwise, a pass-thru to the
  89. /// corresponding implementation method.
  90. int
  91. DLV::compare(const Rdata& other) const {
  92. const DLV& other_ds = dynamic_cast<const DLV&>(other);
  93. return (impl_->compare(*other_ds.impl_));
  94. }
  95. /// \brief Tag accessor
  96. uint16_t
  97. DLV::getTag() const {
  98. return (impl_->getTag());
  99. }
  100. // END_RDATA_NAMESPACE
  101. // END_ISC_NAMESPACE