Browse Source

[1144] some suggested (mostly) editorial cleanups:
- style guideline adjustment (position of opening braces, indentation, etc)
- avoid 'using namespace' before including a header file and (as a result
of it) in ds_like.h
- move standard header files from dlv/ds implementation files to ds_link.h
as much as possible
- trivial documentation updates

JINMEI Tatuya 13 years ago
parent
commit
31e0103301

+ 33 - 17
src/lib/dns/rdata/generic/detail/ds_like.h

@@ -17,19 +17,36 @@
 
 
 #include <stdint.h>
 #include <stdint.h>
 
 
+#include <iostream>
+#include <sstream>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
+#include <boost/lexical_cast.hpp>
+
+#include <exceptions/exceptions.h>
+
+#include <dns/messagerenderer.h>
+#include <dns/name.h>
+#include <dns/rdata.h>
+#include <dns/rdataclass.h>
+
+namespace isc {
+namespace dns {
+namespace rdata {
+namespace generic {
+namespace detail {
+
 /// \brief \c rdata::DSLikeImpl class represents the DS-like RDATA for DS
 /// \brief \c rdata::DSLikeImpl class represents the DS-like RDATA for DS
 /// and DLV types.
 /// and DLV types.
 ///
 ///
 /// This class implements the basic interfaces inherited by the DS and DLV
 /// This class implements the basic interfaces inherited by the DS and DLV
 /// classes from the abstract \c rdata::Rdata class, and provides trivial
 /// classes from the abstract \c rdata::Rdata class, and provides trivial
 /// accessors to DS-like RDATA.
 /// accessors to DS-like RDATA.
-template<class Type, uint16_t typeCode>class DSLikeImpl {
+template <class Type, uint16_t typeCode> class DSLikeImpl {
     // Common sequence of toWire() operations used for the two versions of
     // Common sequence of toWire() operations used for the two versions of
     // toWire().
     // toWire().
-    template<typename Output>
+    template <typename Output>
     void
     void
     toWireCommon(Output& output) const {
     toWireCommon(Output& output) const {
         output.writeUint16(tag_);
         output.writeUint16(tag_);
@@ -45,10 +62,9 @@ public:
     ///
     ///
     /// \c InvalidRdataText is thrown if the method cannot process the
     /// \c InvalidRdataText is thrown if the method cannot process the
     /// parameter data for any of the number of reasons.
     /// parameter data for any of the number of reasons.
-    DSLikeImpl(const string& ds_str)
-    {
-        istringstream iss(ds_str);
-        stringbuf digestbuf;
+    DSLikeImpl(const std::string& ds_str) {
+        std::istringstream iss(ds_str);
+        std::stringbuf digestbuf;
         uint32_t tag, algorithm, digest_type;
         uint32_t tag, algorithm, digest_type;
 
 
         iss >> tag >> algorithm >> digest_type >> &digestbuf;
         iss >> tag >> algorithm >> digest_type >> &digestbuf;
@@ -90,24 +106,19 @@ public:
             isc_throw(InvalidRdataLength, RRType(typeCode) << " too short");
             isc_throw(InvalidRdataLength, RRType(typeCode) << " too short");
         }
         }
 
 
-        uint16_t tag = buffer.readUint16();
-        uint16_t algorithm = buffer.readUint8();
-        uint16_t digest_type = buffer.readUint8();
+        tag_ = buffer.readUint16();
+        algorithm_ = buffer.readUint8();
+        digest_type_ = buffer.readUint8();
 
 
         rdata_len -= 4;
         rdata_len -= 4;
         digest_.resize(rdata_len);
         digest_.resize(rdata_len);
         buffer.readData(&digest_[0], rdata_len);
         buffer.readData(&digest_[0], rdata_len);
-
-        tag_ = tag;
-        algorithm_ = algorithm;
-        digest_type_ = digest_type;
     }
     }
 
 
     /// \brief The copy constructor.
     /// \brief The copy constructor.
     ///
     ///
     /// Trivial for now, we could've used the default one.
     /// Trivial for now, we could've used the default one.
-    DSLikeImpl(const DSLikeImpl& source)
-    {
+    DSLikeImpl(const DSLikeImpl& source) {
         digest_ = source.digest_;
         digest_ = source.digest_;
         tag_ = source.tag_;
         tag_ = source.tag_;
         algorithm_ = source.algorithm_;
         algorithm_ = source.algorithm_;
@@ -117,7 +128,7 @@ public:
     /// \brief Convert the DS-like data to a string.
     /// \brief Convert the DS-like data to a string.
     ///
     ///
     /// \return A \c string object that represents the DS-like data.
     /// \return A \c string object that represents the DS-like data.
-    string
+    std::string
     toText() const {
     toText() const {
         using namespace boost;
         using namespace boost;
         return (lexical_cast<string>(static_cast<int>(tag_)) +
         return (lexical_cast<string>(static_cast<int>(tag_)) +
@@ -189,9 +200,14 @@ private:
     uint16_t tag_;
     uint16_t tag_;
     uint8_t algorithm_;
     uint8_t algorithm_;
     uint8_t digest_type_;
     uint8_t digest_type_;
-    vector<uint8_t> digest_;
+    std::vector<uint8_t> digest_;
 };
 };
 
 
+}
+}
+}
+}
+}
 #endif //  __DS_LIKE_H
 #endif //  __DS_LIKE_H
 
 
 // Local Variables: 
 // Local Variables: 

+ 3 - 8
src/lib/dns/rdata/generic/dlv_32769.cc

@@ -12,33 +12,28 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 // PERFORMANCE OF THIS SOFTWARE.
 
 
-#include <iostream>
 #include <string>
 #include <string>
-#include <sstream>
-#include <vector>
-
-#include <boost/lexical_cast.hpp>
 
 
 #include <util/buffer.h>
 #include <util/buffer.h>
 #include <util/encode/hex.h>
 #include <util/encode/hex.h>
 
 
 #include <dns/messagerenderer.h>
 #include <dns/messagerenderer.h>
-#include <dns/name.h>
 #include <dns/rdata.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
 #include <dns/rdataclass.h>
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <time.h>
 #include <time.h>
 
 
+#include <dns/rdata/generic/detail/ds_like.h>
+
 using namespace std;
 using namespace std;
 using namespace isc::util;
 using namespace isc::util;
 using namespace isc::util::encode;
 using namespace isc::util::encode;
+using namespace isc::dns::rdata::generic::detail;
 
 
 // BEGIN_ISC_NAMESPACE
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
 
-#include <dns/rdata/generic/detail/ds_like.h>
-
 /// \brief Constructor from string.
 /// \brief Constructor from string.
 ///
 ///
 /// A copy of the implementation object is allocated and constructed.
 /// A copy of the implementation object is allocated and constructed.

+ 5 - 3
src/lib/dns/rdata/generic/dlv_32769.h

@@ -30,9 +30,11 @@
 
 
 // BEGIN_RDATA_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
 
-template<class Type, uint16_t typeCode> class DSLikeImpl;
+namespace detail {
+template <class Type, uint16_t typeCode> class DSLikeImpl;
+}
 
 
-/// \brief \c rdata::DLV class represents the DLV RDATA as defined %in
+/// \brief \c rdata::generic::DLV class represents the DLV RDATA as defined in
 /// RFC4431.
 /// RFC4431.
 ///
 ///
 /// This class implements the basic interfaces inherited from the abstract
 /// This class implements the basic interfaces inherited from the abstract
@@ -62,7 +64,7 @@ public:
     /// This method never throws an exception.
     /// This method never throws an exception.
     uint16_t getTag() const;
     uint16_t getTag() const;
 private:
 private:
-    typedef DSLikeImpl<DLV, 32769> DLVImpl;
+    typedef detail::DSLikeImpl<DLV, 32769> DLVImpl;
     DLVImpl* impl_;
     DLVImpl* impl_;
 };
 };
 
 

+ 3 - 8
src/lib/dns/rdata/generic/ds_43.cc

@@ -12,33 +12,28 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 // PERFORMANCE OF THIS SOFTWARE.
 
 
-#include <iostream>
 #include <string>
 #include <string>
-#include <sstream>
-#include <vector>
-
-#include <boost/lexical_cast.hpp>
 
 
 #include <util/buffer.h>
 #include <util/buffer.h>
 #include <util/encode/hex.h>
 #include <util/encode/hex.h>
 
 
 #include <dns/messagerenderer.h>
 #include <dns/messagerenderer.h>
-#include <dns/name.h>
 #include <dns/rdata.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
 #include <dns/rdataclass.h>
 
 
+#include <dns/rdata/generic/detail/ds_like.h>
+
 #include <stdio.h>
 #include <stdio.h>
 #include <time.h>
 #include <time.h>
 
 
 using namespace std;
 using namespace std;
 using namespace isc::util;
 using namespace isc::util;
 using namespace isc::util::encode;
 using namespace isc::util::encode;
+using namespace isc::dns::rdata::generic::detail;
 
 
 // BEGIN_ISC_NAMESPACE
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
 
-#include <dns/rdata/generic/detail/ds_like.h>
-
 DS::DS(const string& ds_str) :
 DS::DS(const string& ds_str) :
     impl_(new DSImpl(ds_str))
     impl_(new DSImpl(ds_str))
 {}
 {}

+ 24 - 4
src/lib/dns/rdata/generic/ds_43.h

@@ -30,21 +30,41 @@
 
 
 // BEGIN_RDATA_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
 
-template<class Type, uint16_t typeCode> class DSLikeImpl;
+namespace detail {
+template <class Type, uint16_t typeCode> class DSLikeImpl;
+}
 
 
+/// \brief \c rdata::generic::DS class represents the DS RDATA as defined in
+/// RFC3658.
+///
+/// This class implements the basic interfaces inherited from the abstract
+/// \c rdata::Rdata class, and provides trivial accessors specific to the
+/// DS RDATA.
 class DS : public Rdata {
 class DS : public Rdata {
 public:
 public:
     // BEGIN_COMMON_MEMBERS
     // BEGIN_COMMON_MEMBERS
     // END_COMMON_MEMBERS
     // END_COMMON_MEMBERS
+
+    /// \brief Assignment operator.
+    ///
+    /// It internally allocates a resource, and if it fails a corresponding
+    /// standard exception will be thrown.
+    /// This operator never throws an exception otherwise.
+    ///
+    /// This operator provides the strong exception guarantee: When an
+    /// exception is thrown the content of the assignment target will be
+    /// intact.
     DS& operator=(const DS& source);
     DS& operator=(const DS& source);
+
+    /// \brief The destructor.
     ~DS();
     ~DS();
 
 
+    /// \brief Return the value of the Tag field.
     ///
     ///
-    /// Specialized methods
-    ///
+    /// This method never throws an exception.
     uint16_t getTag() const;
     uint16_t getTag() const;
 private:
 private:
-    typedef DSLikeImpl<DS, 43> DSImpl;
+    typedef detail::DSLikeImpl<DS, 43> DSImpl;
     DSImpl* impl_;
     DSImpl* impl_;
 };
 };
 
 

+ 5 - 6
src/lib/dns/tests/rdata_ds_like_unittest.cc

@@ -33,8 +33,9 @@ using namespace isc::dns;
 using namespace isc::util;
 using namespace isc::util;
 using namespace isc::dns::rdata;
 using namespace isc::dns::rdata;
 
 
+namespace {
 // hacks to make templates work
 // hacks to make templates work
-template<class T>
+template <class T>
 class RRTYPE : public RRType {
 class RRTYPE : public RRType {
 public:
 public:
     RRTYPE();
     RRTYPE();
@@ -43,7 +44,6 @@ public:
 template<> RRTYPE<generic::DS>::RRTYPE() : RRType(RRType::DS()) {}
 template<> RRTYPE<generic::DS>::RRTYPE() : RRType(RRType::DS()) {}
 template<> RRTYPE<generic::DLV>::RRTYPE() : RRType(RRType::DLV()) {}
 template<> RRTYPE<generic::DLV>::RRTYPE() : RRType(RRType::DLV()) {}
 
 
-namespace {
 template <class DS_LIKE>
 template <class DS_LIKE>
 class Rdata_DS_LIKE_Test : public RdataTest {
 class Rdata_DS_LIKE_Test : public RdataTest {
 protected:
 protected:
@@ -51,7 +51,7 @@ protected:
 };
 };
 
 
 string ds_like_txt("12892 5 2 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
 string ds_like_txt("12892 5 2 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
-              "5F0EB5C777586DE18DA6B5");
+                   "5F0EB5C777586DE18DA6B5");
 
 
 template <class DS_LIKE>
 template <class DS_LIKE>
 DS_LIKE const Rdata_DS_LIKE_Test<DS_LIKE>::rdata_ds_like(ds_like_txt);
 DS_LIKE const Rdata_DS_LIKE_Test<DS_LIKE>::rdata_ds_like(ds_like_txt);
@@ -103,7 +103,7 @@ TYPED_TEST(Rdata_DS_LIKE_Test, toWireRenderer) {
     vector<unsigned char> data;
     vector<unsigned char> data;
     UnitTestUtil::readWireData("rdata_ds_fromWire", data);
     UnitTestUtil::readWireData("rdata_ds_fromWire", data);
     EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
     EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
-                        static_cast<const uint8_t *>
+                        static_cast<const uint8_t*>
                         (Rdata_DS_LIKE_Test<TypeParam>::obuffer.getData()) + 2,
                         (Rdata_DS_LIKE_Test<TypeParam>::obuffer.getData()) + 2,
                         Rdata_DS_LIKE_Test<TypeParam>::obuffer.getLength() - 2,
                         Rdata_DS_LIKE_Test<TypeParam>::obuffer.getLength() - 2,
                         &data[2], data.size() - 2);
                         &data[2], data.size() - 2);
@@ -116,8 +116,7 @@ TYPED_TEST(Rdata_DS_LIKE_Test, toWireBuffer) {
 
 
 TYPED_TEST(Rdata_DS_LIKE_Test, compare) {
 TYPED_TEST(Rdata_DS_LIKE_Test, compare) {
     // trivial case: self equivalence
     // trivial case: self equivalence
-    EXPECT_EQ(0,
-              TypeParam(ds_like_txt).compare(TypeParam(ds_like_txt)));
+    EXPECT_EQ(0, TypeParam(ds_like_txt).compare(TypeParam(ds_like_txt)));
 
 
     // TODO: need more tests
     // TODO: need more tests
 }
 }