Browse Source

[1183] make name arg of getRecords std::string

Jelte Jansen 13 years ago
parent
commit
b97162729a

+ 1 - 1
src/lib/datasrc/database.cc

@@ -183,7 +183,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
 
 
     // Request the context
     // Request the context
     DatabaseAccessor::IteratorContextPtr
     DatabaseAccessor::IteratorContextPtr
-        context(database_->getRecords(name, zone_id_));
+        context(database_->getRecords(name.toText(), zone_id_));
     // It must not return NULL, that's a bug of the implementation
     // It must not return NULL, that's a bug of the implementation
     if (!context) {
     if (!context) {
         isc_throw(isc::Unexpected, "Iterator context null at " +
         isc_throw(isc::Unexpected, "Iterator context null at " +

+ 1 - 1
src/lib/datasrc/database.h

@@ -155,7 +155,7 @@ public:
      * \param id The ID of the zone, returned from getZone().
      * \param id The ID of the zone, returned from getZone().
      * \return Newly created iterator context. Must not be NULL.
      * \return Newly created iterator context. Must not be NULL.
      */
      */
-    virtual IteratorContextPtr getRecords(const isc::dns::Name& name,
+    virtual IteratorContextPtr getRecords(const std::string& name,
                                           int id) const
                                           int id) const
     {
     {
         /*
         /*

+ 4 - 4
src/lib/datasrc/sqlite3_accessor.cc

@@ -382,7 +382,7 @@ public:
     // Construct an iterator for records with a specific name. When constructed
     // Construct an iterator for records with a specific name. When constructed
     // this way, the getNext() call will copy all fields except name
     // this way, the getNext() call will copy all fields except name
     Context(const boost::shared_ptr<const SQLite3Database>& database, int id,
     Context(const boost::shared_ptr<const SQLite3Database>& database, int id,
-            const isc::dns::Name& name) :
+            const std::string& name) :
         iterator_type_(ITT_NAME),
         iterator_type_(ITT_NAME),
         database_(database),
         database_(database),
         statement_(NULL)
         statement_(NULL)
@@ -442,8 +442,8 @@ private:
         }
         }
     }
     }
 
 
-    void bindName(const isc::dns::Name& name) {
-        if (sqlite3_bind_text(statement_, 2, name.toText().c_str(), -1,
+    void bindName(const std::string& name) {
+        if (sqlite3_bind_text(statement_, 2, name.c_str(), -1,
                               SQLITE_TRANSIENT) != SQLITE_OK) {
                               SQLITE_TRANSIENT) != SQLITE_OK) {
             const char* errmsg = sqlite3_errmsg(database_->dbparameters_->db_);
             const char* errmsg = sqlite3_errmsg(database_->dbparameters_->db_);
             sqlite3_finalize(statement_);
             sqlite3_finalize(statement_);
@@ -458,7 +458,7 @@ private:
 };
 };
 
 
 DatabaseAccessor::IteratorContextPtr
 DatabaseAccessor::IteratorContextPtr
-SQLite3Database::getRecords(const isc::dns::Name& name, int id) const {
+SQLite3Database::getRecords(const std::string& name, int id) const {
     return (IteratorContextPtr(new Context(shared_from_this(), id, name)));
     return (IteratorContextPtr(new Context(shared_from_this(), id, name)));
 }
 }
 
 

+ 1 - 1
src/lib/datasrc/sqlite3_accessor.h

@@ -104,7 +104,7 @@ public:
      * \param id the zone id, as returned by getZone()
      * \param id the zone id, as returned by getZone()
      * \return Iterator that contains all records with the given name
      * \return Iterator that contains all records with the given name
      */
      */
-    virtual IteratorContextPtr getRecords(const isc::dns::Name& name,
+    virtual IteratorContextPtr getRecords(const std::string& name,
                                           int id) const;
                                           int id) const;
 
 
     /** \brief Look up all resource records for a zone
     /** \brief Look up all resource records for a zone

+ 4 - 4
src/lib/datasrc/tests/database_unittest.cc

@@ -84,8 +84,8 @@ private:
     class MockNameIteratorContext : public IteratorContext {
     class MockNameIteratorContext : public IteratorContext {
     public:
     public:
         MockNameIteratorContext(const MockAccessor& mock_accessor, int zone_id,
         MockNameIteratorContext(const MockAccessor& mock_accessor, int zone_id,
-                                const isc::dns::Name& name) :
-            searched_name_(name.toText()), cur_record_(0)
+                                const std::string& name) :
+            searched_name_(name), cur_record_(0)
         {
         {
             // 'hardcoded' name to trigger exceptions (for testing
             // 'hardcoded' name to trigger exceptions (for testing
             // the error handling of find() (the other on is below in
             // the error handling of find() (the other on is below in
@@ -235,7 +235,7 @@ public:
         }
         }
     }
     }
 
 
-    virtual IteratorContextPtr getRecords(const Name& name, int id) const {
+    virtual IteratorContextPtr getRecords(const std::string& name, int id) const {
         if (id == 42) {
         if (id == 42) {
             return (IteratorContextPtr(new MockNameIteratorContext(*this, id, name)));
             return (IteratorContextPtr(new MockNameIteratorContext(*this, id, name)));
         } else {
         } else {
@@ -424,7 +424,7 @@ private:
 
 
 // This tests the default getRecords behaviour, throwing NotImplemented
 // This tests the default getRecords behaviour, throwing NotImplemented
 TEST(DatabaseConnectionTest, getRecords) {
 TEST(DatabaseConnectionTest, getRecords) {
-    EXPECT_THROW(NopAccessor().getRecords(Name("."), 1),
+    EXPECT_THROW(NopAccessor().getRecords(".", 1),
                  isc::NotImplemented);
                  isc::NotImplemented);
 }
 }
 
 

+ 3 - 3
src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

@@ -179,14 +179,14 @@ TEST_F(SQLite3Access, getRecords) {
     std::string columns[column_count];
     std::string columns[column_count];
 
 
     DatabaseAccessor::IteratorContextPtr
     DatabaseAccessor::IteratorContextPtr
-        context(db->getRecords(Name("foo.bar"), 1));
+        context(db->getRecords("foo.bar", 1));
     ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
     ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
               context);
               context);
     EXPECT_FALSE(context->getNext(columns));
     EXPECT_FALSE(context->getNext(columns));
     checkRecordRow(columns, "", "", "", "", "");
     checkRecordRow(columns, "", "", "", "", "");
 
 
     // now try some real searches
     // now try some real searches
-    context = db->getRecords(Name("foo.example.com."), zone_id);
+    context = db->getRecords("foo.example.com.", zone_id);
     ASSERT_TRUE(context->getNext(columns));
     ASSERT_TRUE(context->getNext(columns));
     checkRecordRow(columns, "CNAME", "3600", "",
     checkRecordRow(columns, "CNAME", "3600", "",
                    "cnametest.example.org.", "");
                    "cnametest.example.org.", "");
@@ -207,7 +207,7 @@ TEST_F(SQLite3Access, getRecords) {
                    "NSEC 5 3 7200 20100322084538 20100220084538 33495 "
                    "NSEC 5 3 7200 20100322084538 20100220084538 33495 "
                    "example.com. FAKEFAKEFAKEFAKE", "");
                    "example.com. FAKEFAKEFAKEFAKE", "");
 
 
-    context = db->getRecords(Name("example.com."), zone_id);
+    context = db->getRecords("example.com.", zone_id);
     ASSERT_TRUE(context->getNext(columns));
     ASSERT_TRUE(context->getNext(columns));
     checkRecordRow(columns, "SOA", "3600", "",
     checkRecordRow(columns, "SOA", "3600", "",
                    "master.example.com. admin.example.com. "
                    "master.example.com. admin.example.com. "