Browse Source

[1140] cleanup along the lines of [1144]

Dima Volodin 13 years ago
parent
commit
a36be89105

+ 3 - 1
src/lib/dns/Makefile.am

@@ -23,6 +23,7 @@ EXTRA_DIST += rdata/generic/cname_5.cc
 EXTRA_DIST += rdata/generic/cname_5.h
 EXTRA_DIST += rdata/generic/detail/nsec_bitmap.cc
 EXTRA_DIST += rdata/generic/detail/nsec_bitmap.h
+EXTRA_DIST += rdata/generic/detail/txt_like.h
 EXTRA_DIST += rdata/generic/dname_39.cc
 EXTRA_DIST += rdata/generic/dname_39.h
 EXTRA_DIST += rdata/generic/dnskey_48.cc
@@ -49,7 +50,7 @@ EXTRA_DIST += rdata/generic/rrsig_46.cc
 EXTRA_DIST += rdata/generic/rrsig_46.h
 EXTRA_DIST += rdata/generic/soa_6.cc
 EXTRA_DIST += rdata/generic/soa_6.h
-EXTRA_DIST += rdata/generic/txt_16.cc
+EXTRA_DIST += rdata/generic/spf_99.h
 EXTRA_DIST += rdata/generic/txt_16.h
 EXTRA_DIST += rdata/hs_4/a_1.cc
 EXTRA_DIST += rdata/hs_4/a_1.h
@@ -92,6 +93,7 @@ libdns___la_SOURCES += tsigkey.h tsigkey.cc
 libdns___la_SOURCES += tsigrecord.h tsigrecord.cc
 libdns___la_SOURCES += rdata/generic/detail/nsec_bitmap.h
 libdns___la_SOURCES += rdata/generic/detail/nsec_bitmap.cc
+libdns___la_SOURCES += rdata/generic/detail/txt_like.h
 
 libdns___la_CPPFLAGS = $(AM_CPPFLAGS)
 # Most applications of libdns++ will only implicitly rely on libcryptolink,

+ 11 - 11
src/lib/dns/rdata/generic/detail/txt_like.h

@@ -23,7 +23,7 @@
 using namespace std;
 using namespace isc::util;
 
-template<class RTYPE, uint16_t typeCode>class TXT_LIKE : public Rdata {
+template<uint16_t typeCode>class TXT_LIKE : public Rdata {
 public:
     TXT_LIKE(InputBuffer& buffer, size_t rdata_len) {
 	if (rdata_len > MAX_RDLENGTH) {
@@ -31,17 +31,17 @@ public:
 	}
 
 	if (rdata_len == 0) {       // note that this couldn't happen in the loop.
-	    isc_throw(DNSMessageFORMERR,
-		      "Error in parsing " + RRParamRegistry::getRegistry().codeToTypeText(typeCode)
-		     + " RDATA: 0-length character string");
+	    isc_throw(DNSMessageFORMERR, "Error in parsing " +
+		      RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+		      " RDATA: 0-length character string");
 	}
 
 	do {
 	    const uint8_t len = buffer.readUint8();
 	    if (rdata_len < len + 1) {
-		isc_throw(DNSMessageFORMERR,
-			  "Error in parsing " + RRParamRegistry::getRegistry().codeToTypeText(typeCode)
-			 + " RDATA: character string length is too large: " << static_cast<int>(len));
+		isc_throw(DNSMessageFORMERR, "Error in parsing " +
+			  RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+			  " RDATA: character string length is too large: " << static_cast<int>(len));
 	    }
 	    vector<uint8_t> data(len + 1);
 	    data[0] = len;
@@ -71,8 +71,8 @@ public:
 
 	// TBD: right now, we don't support escaped characters
 	if (txtstr.find('\\') != string::npos) {
-	    isc_throw(InvalidRdataText, RRParamRegistry::getRegistry().codeToTypeText(typeCode)
-			+ " RDATA from text: escaped character is currently not supported: " << txtstr);
+	    isc_throw(InvalidRdataText, RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+		      " RDATA from text: escaped character is currently not supported: " << txtstr);
 	}
 
 	vector<uint8_t> data;
@@ -83,7 +83,7 @@ public:
 	string_list_.push_back(data);
     }
 
-    TXT_LIKE(const RTYPE& other) :
+    TXT_LIKE(const TXT_LIKE& other) :
 	Rdata(), string_list_(other.string_list_)
     {}
 
@@ -130,7 +130,7 @@ public:
 
     int
     compare(const Rdata& other) const {
-	const RTYPE& other_txt = dynamic_cast<const RTYPE&>(other);
+	const TXT_LIKE& other_txt = dynamic_cast<const TXT_LIKE&>(other);
 
 	// This implementation is not efficient.  Revisit this (TBD).
 	OutputBuffer this_buffer(0);

+ 0 - 19
src/lib/dns/rdata/generic/spf_99.cc

@@ -1,19 +0,0 @@
-// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-// BEGIN_ISC_NAMESPACE
-// BEGIN_RDATA_NAMESPACE
-
-// END_RDATA_NAMESPACE
-// END_ISC_NAMESPACE

+ 1 - 42
src/lib/dns/rdata/generic/spf_99.h

@@ -33,48 +33,7 @@
 
 #include <dns/rdata/generic/detail/txt_like.h>
 
-class SPF : public TXT_LIKE<SPF, 99> {
-    friend class TXT_LIKE<SPF, 99>;
-    static string const id;
-
-public:
-    // BEGIN_COMMON_MEMBERS
-    // END_COMMON_MEMBERS
-
-};
-
-///    explicit SPF(const std::string& type_str);
-inline SPF::SPF(const std::string& type_str) : TXT_LIKE<SPF, 99>(type_str) {}
-
-///    SPF(isc::util::InputBuffer& buffer, size_t rdata_len);
-inline SPF::SPF(isc::util::InputBuffer& buffer, size_t rdata_len) : TXT_LIKE<SPF, 99>(buffer, rdata_len) {}
-
-///    SPF(const SPF& other);
-inline SPF::SPF(const SPF& other) : TXT_LIKE<SPF, 99>(other) {}
-
-///    virtual std::string toText() const;
-inline std::string SPF::toText() const
-{
-    return TXT_LIKE<SPF, 99>::toText();
-}
-
-///    virtual void toWire(isc::util::OutputBuffer& buffer) const;
-inline void SPF::toWire(isc::util::OutputBuffer& buffer) const
-{
-    TXT_LIKE<SPF, 99>::toWire(buffer);
-}
-
-///    virtual void toWire(AbstractMessageRenderer& renderer) const;
-inline void SPF::toWire(AbstractMessageRenderer& renderer) const
-{
-    TXT_LIKE<SPF, 99>::toWire(renderer);
-}
-
-///    virtual int compare(const Rdata& other) const;
-inline int SPF::compare(const Rdata& other) const
-{
-    return TXT_LIKE<SPF, 99>::compare(other);
-}
+typedef TXT_LIKE<99> SPF;
 
 // END_RDATA_NAMESPACE
 // END_ISC_NAMESPACE

+ 0 - 19
src/lib/dns/rdata/generic/txt_16.cc

@@ -1,19 +0,0 @@
-// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-// BEGIN_ISC_NAMESPACE
-// BEGIN_RDATA_NAMESPACE
-
-// END_RDATA_NAMESPACE
-// END_ISC_NAMESPACE

+ 1 - 42
src/lib/dns/rdata/generic/txt_16.h

@@ -33,48 +33,7 @@
 
 #include <dns/rdata/generic/detail/txt_like.h>
 
-class TXT : public TXT_LIKE<TXT, 16> {
-    friend class TXT_LIKE<TXT, 16>;
-    static string const id;
-
-public:
-    // BEGIN_COMMON_MEMBERS
-    // END_COMMON_MEMBERS
-
-};
-
-///    explicit TXT(const std::string& type_str);
-inline TXT::TXT(const std::string& type_str) : TXT_LIKE<TXT, 16>(type_str) {}
-
-///    TXT(isc::util::InputBuffer& buffer, size_t rdata_len);
-inline TXT::TXT(isc::util::InputBuffer& buffer, size_t rdata_len) : TXT_LIKE<TXT, 16>(buffer, rdata_len) {}
-
-///    TXT(const TXT& other);
-inline TXT::TXT(const TXT& other) : TXT_LIKE<TXT, 16>(other) {}
-
-///    virtual std::string toText() const;
-inline std::string TXT::toText() const
-{
-    return TXT_LIKE<TXT, 16>::toText();
-}
-
-///    virtual void toWire(isc::util::OutputBuffer& buffer) const;
-inline void TXT::toWire(isc::util::OutputBuffer& buffer) const
-{
-    TXT_LIKE<TXT, 16>::toWire(buffer);
-}
-
-///    virtual void toWire(AbstractMessageRenderer& renderer) const;
-inline void TXT::toWire(AbstractMessageRenderer& renderer) const
-{
-    TXT_LIKE<TXT, 16>::toWire(renderer);
-}
-
-///    virtual int compare(const Rdata& other) const;
-inline int TXT::compare(const Rdata& other) const
-{
-    return TXT_LIKE<TXT, 16>::compare(other);
-}
+typedef TXT_LIKE<16> TXT;
 
 // END_RDATA_NAMESPACE
 // END_ISC_NAMESPACE