txt_16.cc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 <stdint.h>
  15. #include <string.h>
  16. #include <string>
  17. #include <vector>
  18. #include <util/buffer.h>
  19. #include <dns/exceptions.h>
  20. #include <dns/messagerenderer.h>
  21. #include <dns/rdata.h>
  22. #include <dns/rdataclass.h>
  23. #include <dns/rdata/generic/detail/txt_like.h>
  24. using namespace std;
  25. using namespace isc::util;
  26. // BEGIN_ISC_NAMESPACE
  27. // BEGIN_RDATA_NAMESPACE
  28. TXT&
  29. TXT::operator=(const TXT& source) {
  30. if (impl_ == source.impl_) {
  31. return (*this);
  32. }
  33. TXTImpl* newimpl = new TXTImpl(*source.impl_);
  34. delete impl_;
  35. impl_ = newimpl;
  36. return (*this);
  37. }
  38. TXT::~TXT() {
  39. delete impl_;
  40. }
  41. TXT::TXT(InputBuffer& buffer, size_t rdata_len) :
  42. impl_(new TXTImpl(buffer, rdata_len))
  43. {}
  44. /// \brief Constructor using the master lexer.
  45. ///
  46. /// This implementation only uses the \c lexer parameters; others are
  47. /// ignored.
  48. ///
  49. /// \throw CharStringTooLong the parameter string length exceeds maximum.
  50. /// \throw InvalidRdataText the method cannot process the parameter data
  51. ///
  52. /// \param lexer A \c MasterLexer object parsing a master file for this
  53. /// RDATA.
  54. TXT::TXT(MasterLexer& lexer, const Name*, MasterLoader::Options,
  55. MasterLoaderCallbacks&) :
  56. impl_(new TXTImpl(lexer))
  57. {}
  58. TXT::TXT(const std::string& txtstr) :
  59. impl_(new TXTImpl(txtstr))
  60. {}
  61. TXT::TXT(const TXT& other) :
  62. Rdata(), impl_(new TXTImpl(*other.impl_))
  63. {}
  64. void
  65. TXT::toWire(OutputBuffer& buffer) const {
  66. impl_->toWire(buffer);
  67. }
  68. void
  69. TXT::toWire(AbstractMessageRenderer& renderer) const {
  70. impl_->toWire(renderer);
  71. }
  72. string
  73. TXT::toText() const {
  74. return (impl_->toText());
  75. }
  76. int
  77. TXT::compare(const Rdata& other) const {
  78. const TXT& other_txt = dynamic_cast<const TXT&>(other);
  79. return (impl_->compare(*other_txt.impl_));
  80. }
  81. // END_RDATA_NAMESPACE
  82. // END_ISC_NAMESPACE