]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Implement toString() for DNSRecord
authorFred Morcos <fred.morcos@open-xchange.com>
Tue, 31 May 2022 11:35:58 +0000 (13:35 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 13 Jun 2022 12:24:24 +0000 (14:24 +0200)
pdns/dnsparser.hh

index 90070966bd170cfe14fd0bdf4ec1a2a9c16ceb6c..0354876d2cca4bdc5c4a16faf52310be5a53d65c 100644 (file)
@@ -24,6 +24,7 @@
 #include <sstream>
 #include <stdexcept>
 #include <iostream>
+#include <utility>
 #include <vector>
 #include <cerrno>
 // #include <netinet/in.h>
@@ -304,6 +305,18 @@ struct DNSRecord
   uint16_t d_clen{};
   DNSResourceRecord::Place d_place;
 
+  [[nodiscard]] std::string print(const std::string& indent = "") const
+  {
+    std::stringstream s;
+    s << indent << "Content = " << d_content->getZoneRepresentation() << std::endl;
+    s << indent << "Type = " << d_type << std::endl;
+    s << indent << "Class = " << d_class << std::endl;
+    s << indent << "TTL = " << d_ttl << std::endl;
+    s << indent << "clen = " << d_clen << std::endl;
+    s << indent << "Place = " << std::to_string(d_place) << std::endl;
+    return s.str();
+  }
+
   bool operator<(const DNSRecord& rhs) const
   {
     if(std::tie(d_name, d_type, d_class, d_ttl) < std::tie(rhs.d_name, rhs.d_type, rhs.d_class, rhs.d_ttl))