From: Mukund Sivaraman Date: Tue, 4 Feb 2014 20:07:12 +0000 (+0530) Subject: [2536] Remove "using namespace" from headers (DNS code) X-Git-Tag: bind10-1.2.0beta1-release~56^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9fcbaef68193a99a142f63b576fdfdd5519192c0;p=thirdparty%2Fkea.git [2536] Remove "using namespace" from headers (DNS code) --- diff --git a/src/lib/cache/message_cache.h b/src/lib/cache/message_cache.h index 0c19139088..0df23ede37 100644 --- a/src/lib/cache/message_cache.h +++ b/src/lib/cache/message_cache.h @@ -73,8 +73,8 @@ protected: /// \param name query name of the message. /// \param type query type of the message. /// \return return the hash key. - HashKey getEntryHashKey(const isc::dns::Name& name, - const isc::dns::RRType& type) const; + isc::nsas::HashKey getEntryHashKey(const isc::dns::Name& name, + const isc::dns::RRType& type) const; // Make these variants be protected for easy unittest. protected: @@ -91,4 +91,3 @@ typedef boost::shared_ptr MessageCachePtr; } // namespace isc #endif // MESSAGE_CACHE_H - diff --git a/src/lib/cache/message_entry.cc b/src/lib/cache/message_entry.cc index b6af869d28..36e76915db 100644 --- a/src/lib/cache/message_entry.cc +++ b/src/lib/cache/message_entry.cc @@ -23,6 +23,7 @@ #include "logger.h" using namespace isc::dns; +using namespace isc::nsas; using namespace std; // Put file scope functions in unnamed namespace. diff --git a/src/lib/cache/message_entry.h b/src/lib/cache/message_entry.h index 206e601c1b..5b55fbbf3c 100644 --- a/src/lib/cache/message_entry.h +++ b/src/lib/cache/message_entry.h @@ -22,8 +22,6 @@ #include "rrset_cache.h" #include "rrset_entry.h" -using namespace isc::nsas; - namespace isc { namespace cache { @@ -33,7 +31,7 @@ class RRsetEntry; /// /// The object of MessageEntry represents one response message /// answered to the resolver client. -class MessageEntry : public NsasEntry { +class MessageEntry : public isc::nsas::NsasEntry { // Noncopyable private: MessageEntry(const MessageEntry& source); @@ -92,7 +90,7 @@ public: /// \brief Get the hash key of the message entry. /// /// \return return hash key - virtual HashKey hashKey() const { + virtual isc::nsas::HashKey hashKey() const { return (*hash_key_ptr_); } @@ -173,7 +171,7 @@ protected: private: std::string entry_name_; // The name for this entry(name + type) - HashKey* hash_key_ptr_; // the key for messag entry in hash table. + isc::nsas::HashKey* hash_key_ptr_; // the key for messag entry in hash table. std::vector rrsets_; RRsetCachePtr rrset_cache_; //Normal rrset cache diff --git a/src/lib/cache/rrset_cache.h b/src/lib/cache/rrset_cache.h index 304c6e8907..8587ec7ab5 100644 --- a/src/lib/cache/rrset_cache.h +++ b/src/lib/cache/rrset_cache.h @@ -20,8 +20,6 @@ #include -using namespace isc::nsas; - namespace isc { namespace cache { diff --git a/src/lib/cache/rrset_entry.cc b/src/lib/cache/rrset_entry.cc index 359fd686ec..2e5bf93049 100644 --- a/src/lib/cache/rrset_entry.cc +++ b/src/lib/cache/rrset_entry.cc @@ -21,6 +21,7 @@ #include "rrset_copy.h" using namespace isc::dns; +using namespace isc::nsas; namespace isc { namespace cache { diff --git a/src/lib/cache/rrset_entry.h b/src/lib/cache/rrset_entry.h index 0efda3660f..71b5e4b1fe 100644 --- a/src/lib/cache/rrset_entry.h +++ b/src/lib/cache/rrset_entry.h @@ -22,8 +22,6 @@ #include #include "cache_entry_key.h" -using namespace isc::nsas; - namespace isc { namespace cache { @@ -60,7 +58,7 @@ enum RRsetTrustLevel { /// The object of RRsetEntry represents one cached RRset. /// Each RRset entry may be refered using shared_ptr by several message /// entries. -class RRsetEntry : public NsasEntry +class RRsetEntry : public isc::nsas::NsasEntry { /// /// \name Constructors and Destructor @@ -105,7 +103,7 @@ public: /// \brief Get the hash key /// /// \return return hash key - HashKey hashKey() const { + isc::nsas::HashKey hashKey() const { return (hash_key_); } @@ -124,7 +122,7 @@ private: time_t expire_time_; // Expiration time of rrset. RRsetTrustLevel trust_level_; // RRset trustworthiness. boost::shared_ptr rrset_; - HashKey hash_key_; // RRsetEntry hash key + isc::nsas::HashKey hash_key_; // RRsetEntry hash key }; typedef boost::shared_ptr RRsetEntryPtr; diff --git a/src/lib/cache/tests/cache_test_messagefromfile.h b/src/lib/cache/tests/cache_test_messagefromfile.h index 7d55f08c71..85bc0d9c8d 100644 --- a/src/lib/cache/tests/cache_test_messagefromfile.h +++ b/src/lib/cache/tests/cache_test_messagefromfile.h @@ -17,9 +17,6 @@ #include #include -using namespace isc; -using namespace isc::dns; - namespace { /// \brief Reads a Message from a data file @@ -27,13 +24,12 @@ namespace { /// \param message Message to put the read data in /// \param datafile The file to read from void -messageFromFile(Message& message, const char* datafile) { +messageFromFile(isc::dns::Message& message, const char* datafile) { std::vector data; - UnitTestUtil::readWireData(datafile, data); + isc::UnitTestUtil::readWireData(datafile, data); isc::util::InputBuffer buffer(&data[0], data.size()); message.fromWire(buffer); } } // namespace - diff --git a/src/lib/cache/tests/cache_test_sectioncount.h b/src/lib/cache/tests/cache_test_sectioncount.h index df7cb5258d..0dcdaee804 100644 --- a/src/lib/cache/tests/cache_test_sectioncount.h +++ b/src/lib/cache/tests/cache_test_sectioncount.h @@ -17,9 +17,6 @@ #include #include -using namespace isc; -using namespace isc::dns; - namespace { /// \brief Counts the number of rrsets in the given section @@ -29,9 +26,9 @@ namespace { /// /// \return The number of RRsets in the given section int -sectionRRsetCount(Message& msg, Message::Section section) { +sectionRRsetCount(isc::dns::Message& msg, isc::dns::Message::Section section) { int count = 0; - for (RRsetIterator rrset_iter = msg.beginSection(section); + for (isc::dns::RRsetIterator rrset_iter = msg.beginSection(section); rrset_iter != msg.endSection(section); ++rrset_iter) { ++count; @@ -41,4 +38,3 @@ sectionRRsetCount(Message& msg, Message::Section section) { } } // namespace - diff --git a/src/lib/cache/tests/message_cache_unittest.cc b/src/lib/cache/tests/message_cache_unittest.cc index 60ae0371a2..c26b3cb6a6 100644 --- a/src/lib/cache/tests/message_cache_unittest.cc +++ b/src/lib/cache/tests/message_cache_unittest.cc @@ -23,6 +23,7 @@ #include "cache_test_messagefromfile.h" using namespace isc::cache; +using namespace isc::nsas; using namespace isc; using namespace isc::dns; using namespace isc::util; diff --git a/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc b/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc index 23d6d0ed68..23461805af 100644 --- a/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc +++ b/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc @@ -30,6 +30,7 @@ using namespace std; using isc::UnitTestUtil; using namespace isc::dns; using namespace isc::dns::rdata; +using namespace isc::util; namespace { diff --git a/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc b/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc index fbb256a151..0af1a12f9a 100644 --- a/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc +++ b/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc @@ -34,6 +34,7 @@ using boost::lexical_cast; using isc::UnitTestUtil; using namespace isc::dns; using namespace isc::dns::rdata; +using namespace isc::util; namespace { diff --git a/src/lib/dns/tests/rdata_unittest.h b/src/lib/dns/tests/rdata_unittest.h index 04af07c2fe..8c7f954eeb 100644 --- a/src/lib/dns/tests/rdata_unittest.h +++ b/src/lib/dns/tests/rdata_unittest.h @@ -27,8 +27,6 @@ #include #include -using namespace isc::util; - namespace isc { namespace dns { namespace rdata { @@ -77,7 +75,7 @@ protected: } } - OutputBuffer obuffer; + isc::util::OutputBuffer obuffer; MessageRenderer renderer; /// This is an RDATA object of some "unknown" RR type so that it can be /// used to test the compare() method against a well-known RR type. diff --git a/src/lib/nsas/tests/hash_unittest.cc b/src/lib/nsas/tests/hash_unittest.cc index f71d4b35e5..fe43bfabcd 100644 --- a/src/lib/nsas/tests/hash_unittest.cc +++ b/src/lib/nsas/tests/hash_unittest.cc @@ -26,6 +26,7 @@ #include "nsas_test.h" using namespace std; +using namespace isc::dns; namespace isc { namespace nsas { diff --git a/src/lib/nsas/tests/nameserver_address_store_unittest.cc b/src/lib/nsas/tests/nameserver_address_store_unittest.cc index a606f2614c..3bde33bffb 100644 --- a/src/lib/nsas/tests/nameserver_address_store_unittest.cc +++ b/src/lib/nsas/tests/nameserver_address_store_unittest.cc @@ -41,8 +41,10 @@ #include "nsas_test.h" using namespace isc::dns; +using namespace isc::dns::rdata; using namespace isc::util; using namespace std; +using isc::util::unittests::TestResolver; namespace isc { namespace nsas { diff --git a/src/lib/nsas/tests/nameserver_address_unittest.cc b/src/lib/nsas/tests/nameserver_address_unittest.cc index 1b211e9e3e..f8512bf3ff 100644 --- a/src/lib/nsas/tests/nameserver_address_unittest.cc +++ b/src/lib/nsas/tests/nameserver_address_unittest.cc @@ -26,12 +26,13 @@ #include "../nameserver_entry.h" #include "nsas_test.h" +using namespace isc::dns; +using namespace isc::dns::rdata; +using isc::util::unittests::TestResolver; + namespace isc { namespace nsas { -using namespace dns; -using namespace rdata; - #define TEST_ADDRESS_INDEX 1 /// \brief NameserverEntry sample class for testing diff --git a/src/lib/nsas/tests/nameserver_entry_unittest.cc b/src/lib/nsas/tests/nameserver_entry_unittest.cc index 10f0c20b80..dd7f3b970d 100644 --- a/src/lib/nsas/tests/nameserver_entry_unittest.cc +++ b/src/lib/nsas/tests/nameserver_entry_unittest.cc @@ -41,7 +41,7 @@ using namespace isc::nsas; using namespace isc::asiolink; using namespace std; using namespace isc::dns; -using namespace rdata; +using isc::util::unittests::TestResolver; namespace { diff --git a/src/lib/nsas/tests/nsas_entry_compare_unittest.cc b/src/lib/nsas/tests/nsas_entry_compare_unittest.cc index 33e41b80cc..9bc5b9c3a7 100644 --- a/src/lib/nsas/tests/nsas_entry_compare_unittest.cc +++ b/src/lib/nsas/tests/nsas_entry_compare_unittest.cc @@ -25,6 +25,7 @@ #include "../nsas_entry_compare.h" #include "nsas_test.h" +using namespace isc::dns; using namespace std; namespace isc { diff --git a/src/lib/nsas/tests/nsas_test.h b/src/lib/nsas/tests/nsas_test.h index 9f92149891..54e5d45d6f 100644 --- a/src/lib/nsas/tests/nsas_test.h +++ b/src/lib/nsas/tests/nsas_test.h @@ -38,11 +38,6 @@ #include #include "../nsas_entry.h" -using namespace isc::dns::rdata; -using namespace isc::dns; -using namespace isc::util; -using isc::util::unittests::TestResolver; - namespace isc { namespace dns { @@ -77,15 +72,15 @@ public: /// For this reason, a single class definition template -class RdataTest: public Rdata { +class RdataTest: public rdata::Rdata { public: /// \brief Constructor /// /// Set the data in the object. /// - /// \param v4address IPV4 address to store. (The format of this address is - /// not checked.) + /// \param v4address IPV4 address to store. (The format of this + /// address is not checked.) RdataTest(const std::string& data) : data_(data) {} @@ -99,8 +94,9 @@ public: /// \brief Return type of Rdata /// - /// Returns the type of the data. May be useful in the tests, although this - /// will not appear in the main code as this interface is not defined. + /// Returns the type of the data. May be useful in the tests, + /// although this will not appear in the main code as this interface + /// is not defined. virtual uint16_t getType() const { return (type_.getType()); } @@ -111,13 +107,13 @@ public: /// //@{ /// \brief Render the \c Rdata in the wire format to a buffer - virtual void toWire(OutputBuffer& buffer) const; + virtual void toWire(isc::util::OutputBuffer& buffer) const; /// \brief render the \Rdata in the wire format to a \c MessageRenderer virtual void toWire(AbstractMessageRenderer& renderer) const; /// \brief Comparison Method - virtual int compare(const Rdata& other) const; + virtual int compare(const rdata::Rdata& other) const; //@} private: @@ -126,7 +122,7 @@ private: }; template -void RdataTest::toWire(OutputBuffer&) const { +void RdataTest::toWire(isc::util::OutputBuffer&) const { } template @@ -134,7 +130,7 @@ void RdataTest::toWire(AbstractMessageRenderer&) const { } template -int RdataTest::compare(const Rdata&) const { +int RdataTest::compare(const rdata::Rdata&) const { return 0; } @@ -210,7 +206,8 @@ private: /// /// Some constants used in the various tests. -static const uint32_t HASHTABLE_DEFAULT_SIZE = 1009; ///< First prime above 1000 +static const uint32_t HASHTABLE_DEFAULT_SIZE = 1009; ///< First prime + ///above 1000 // String constants. These should end in a dot. static const std::string EXAMPLE_CO_UK("example.co.uk."); @@ -219,63 +216,92 @@ static const std::string MIXED_EXAMPLE_CO_UK("EXAmple.co.uk."); class TestWithRdata : public ::testing::Test { protected: - typedef boost::shared_ptr RRsetPtr; + typedef boost::shared_ptr RRsetPtr; /// \brief Constructor /// - /// Initializes the RRsets used in the tests. The RRsets themselves have to - /// be initialized with the basic data on their construction. The Rdata for - /// them is added in SetUp(). + /// Initializes the RRsets used in the tests. The RRsets themselves + /// have to be initialized with the basic data on their + /// construction. The Rdata for them is added in SetUp(). TestWithRdata() : - rrv4_(new RRset(Name(EXAMPLE_CO_UK), RRClass::IN(), RRType::A(), - RRTTL(1200))), - rrcase_(new RRset(Name(MIXED_EXAMPLE_CO_UK), RRClass::IN(), - RRType::A(), RRTTL(1200))), - rrch_(new RRset(Name(EXAMPLE_CO_UK), RRClass::CH(), RRType::A(), - RRTTL(1200))), - rrns_(new RRset(Name(EXAMPLE_CO_UK), RRClass::IN(), RRType::NS(), - RRTTL(1200))), - rr_single_(new RRset(Name(EXAMPLE_CO_UK), RRClass::IN(), - RRType::NS(), RRTTL(600))), - rr_empty_(new RRset(Name(EXAMPLE_CO_UK), RRClass::IN(), - RRType::NS(), RRTTL(600))), - rrv6_(new RRset(Name(EXAMPLE_CO_UK), RRClass::IN(), - RRType::AAAA(), RRTTL(900))), - rrnet_(new RRset(Name(EXAMPLE_NET), RRClass::IN(), RRType::A(), - RRTTL(600))), + rrv4_(new isc::dns::RRset(isc::dns::Name(EXAMPLE_CO_UK), + isc::dns::RRClass::IN(), + isc::dns::RRType::A(), + isc::dns::RRTTL(1200))), + rrcase_(new isc::dns::RRset(isc::dns::Name(MIXED_EXAMPLE_CO_UK), + isc::dns::RRClass::IN(), + isc::dns::RRType::A(), + isc::dns::RRTTL(1200))), + rrch_(new isc::dns::RRset(isc::dns::Name(EXAMPLE_CO_UK), + isc::dns::RRClass::CH(), + isc::dns::RRType::A(), + isc::dns::RRTTL(1200))), + rrns_(new isc::dns::RRset(isc::dns::Name(EXAMPLE_CO_UK), + isc::dns::RRClass::IN(), + isc::dns::RRType::NS(), + isc::dns::RRTTL(1200))), + rr_single_(new isc::dns::RRset(isc::dns::Name(EXAMPLE_CO_UK), + isc::dns::RRClass::IN(), + isc::dns::RRType::NS(), + isc::dns::RRTTL(600))), + rr_empty_(new isc::dns::RRset(isc::dns::Name(EXAMPLE_CO_UK), + isc::dns::RRClass::IN(), + isc::dns::RRType::NS(), + isc::dns::RRTTL(600))), + rrv6_(new isc::dns::RRset(isc::dns::Name(EXAMPLE_CO_UK), + isc::dns::RRClass::IN(), + isc::dns::RRType::AAAA(), + isc::dns::RRTTL(900))), + rrnet_(new isc::dns::RRset(isc::dns::Name(EXAMPLE_NET), + isc::dns::RRClass::IN(), + isc::dns::RRType::A(), + isc::dns::RRTTL(600))), ns_name_("ns.example.net.") {} /// \brief Add Rdata to RRsets /// - /// The data are added as const pointers to avoid the stricter type checking - /// applied by the Rdata code. There is no need for it in these tests. + /// The data are added as const pointers to avoid the stricter type + /// checking applied by the Rdata code. There is no need for it in + /// these tests. virtual void SetUp() { // A records - rrv4_->addRdata(ConstRdataPtr(new RdataTest("1.2.3.4"))); - rrv4_->addRdata(ConstRdataPtr(new RdataTest("5.6.7.8"))); - rrv4_->addRdata(ConstRdataPtr(new RdataTest("9.10.11.12"))); + rrv4_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest("1.2.3.4"))); + rrv4_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest("5.6.7.8"))); + rrv4_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest("9.10.11.12"))); // A records - rrcase_->addRdata(ConstRdataPtr(new RdataTest("13.14.15.16"))); + rrcase_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest + ("13.14.15.16"))); // No idea what Chaosnet address look like other than they are 16 bits // The fact that they are type A is probably also incorrect. - rrch_->addRdata(ConstRdataPtr(new RdataTest("1324"))); + rrch_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest("1324"))); // NS records take a single name - rrns_->addRdata(rdata::generic::NS("example.fr.")); - rrns_->addRdata(rdata::generic::NS("example.de.")); + rrns_->addRdata(isc::dns::rdata::generic::NS("example.fr.")); + rrns_->addRdata(isc::dns::rdata::generic::NS("example.de.")); // Single NS record with 0 TTL - rr_single_->addRdata(rdata::generic::NS(ns_name_)); + rr_single_->addRdata(isc::dns::rdata::generic::NS(ns_name_)); // AAAA records - rrv6_->addRdata(ConstRdataPtr(new RdataTest("2001::1002"))); - rrv6_->addRdata(ConstRdataPtr(new RdataTest("dead:beef:feed::"))); + rrv6_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest + ("2001::1002"))); + rrv6_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest + ("dead:beef:feed::"))); // A record for example.net - rrnet_->addRdata(ConstRdataPtr(new RdataTest("17.18.18.20"))); + rrnet_->addRdata(isc::dns::rdata::ConstRdataPtr + (new isc::dns::RdataTest + ("17.18.18.20"))); } /// \brief Data for the tests @@ -287,7 +313,7 @@ protected: RRsetPtr rr_empty_; ///< NS RRset without any nameservers RRsetPtr rrv6_; ///< Standard RRset, IN, AAAA, lowercase name RRsetPtr rrnet_; ///< example.net A RRset - Name ns_name_; ///< Nameserver name of ns.example.net + isc::dns::Name ns_name_; ///< Nameserver name of ns.example.net }; } // namespace nsas diff --git a/src/lib/nsas/tests/zone_entry_unittest.cc b/src/lib/nsas/tests/zone_entry_unittest.cc index d685fbb390..04a6d4da8f 100644 --- a/src/lib/nsas/tests/zone_entry_unittest.cc +++ b/src/lib/nsas/tests/zone_entry_unittest.cc @@ -33,9 +33,11 @@ using namespace isc::nsas; using namespace isc::asiolink; -using namespace std; using namespace isc::dns; +using namespace isc::dns::rdata; using namespace isc::util; +using namespace std; +using isc::util::unittests::TestResolver; namespace { diff --git a/src/lib/resolve/recursive_query.cc b/src/lib/resolve/recursive_query.cc index 3c54a781c1..e0c5a30034 100644 --- a/src/lib/resolve/recursive_query.cc +++ b/src/lib/resolve/recursive_query.cc @@ -43,6 +43,7 @@ #include using namespace isc::dns; +using namespace isc::nsas; using namespace isc::util; using namespace isc::asiolink; using namespace isc::resolve;