ptr_12.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright (C) 2010 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 <config.h>
  15. #include <string>
  16. #include <util/buffer.h>
  17. #include <dns/name.h>
  18. #include <dns/messagerenderer.h>
  19. #include <dns/rdata.h>
  20. #include <dns/rdataclass.h>
  21. using namespace std;
  22. using namespace isc::util;
  23. // BEGIN_ISC_NAMESPACE
  24. // BEGIN_RDATA_NAMESPACE
  25. PTR::PTR(const std::string& type_str) :
  26. ptr_name_(type_str)
  27. {}
  28. PTR::PTR(InputBuffer& buffer, size_t) :
  29. ptr_name_(buffer)
  30. {
  31. // we don't need rdata_len for parsing. if necessary, the caller will
  32. // check consistency.
  33. }
  34. PTR::PTR(const PTR& source) :
  35. Rdata(), ptr_name_(source.ptr_name_)
  36. {}
  37. std::string
  38. PTR::toText() const {
  39. return (ptr_name_.toText());
  40. }
  41. void
  42. PTR::toWire(OutputBuffer& buffer) const {
  43. ptr_name_.toWire(buffer);
  44. }
  45. void
  46. PTR::toWire(AbstractMessageRenderer& renderer) const {
  47. renderer.writeName(ptr_name_);
  48. }
  49. int
  50. PTR::compare(const Rdata& other) const {
  51. // The compare method normally begins with this dynamic cast.
  52. const PTR& other_ptr = dynamic_cast<const PTR&>(other);
  53. return (compareNames(ptr_name_, other_ptr.ptr_name_));
  54. }
  55. const Name&
  56. PTR::getPTRName() const {
  57. return (ptr_name_);
  58. }
  59. // END_RDATA_NAMESPACE
  60. // END_ISC_NAMESPACE