Commit b9716272 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

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

parent 954143a2
......@@ -183,7 +183,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
// Request the context
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
if (!context) {
isc_throw(isc::Unexpected, "Iterator context null at " +
......
......@@ -155,7 +155,7 @@ public:
* \param id The ID of the zone, returned from getZone().
* \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
{
/*
......
......@@ -382,7 +382,7 @@ public:
// Construct an iterator for records with a specific name. When constructed
// this way, the getNext() call will copy all fields except name
Context(const boost::shared_ptr<const SQLite3Database>& database, int id,
const isc::dns::Name& name) :
const std::string& name) :
iterator_type_(ITT_NAME),
database_(database),
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) {
const char* errmsg = sqlite3_errmsg(database_->dbparameters_->db_);
sqlite3_finalize(statement_);
......@@ -458,7 +458,7 @@ private:
};
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)));
}
......
......@@ -104,7 +104,7 @@ public:
* \param id the zone id, as returned by getZone()
* \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;
/** \brief Look up all resource records for a zone
......
......@@ -84,8 +84,8 @@ private:
class MockNameIteratorContext : public IteratorContext {
public:
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
// 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) {
return (IteratorContextPtr(new MockNameIteratorContext(*this, id, name)));
} else {
......@@ -424,7 +424,7 @@ private:
// This tests the default getRecords behaviour, throwing NotImplemented
TEST(DatabaseConnectionTest, getRecords) {
EXPECT_THROW(NopAccessor().getRecords(Name("."), 1),
EXPECT_THROW(NopAccessor().getRecords(".", 1),
isc::NotImplemented);
}
......
......@@ -179,14 +179,14 @@ TEST_F(SQLite3Access, getRecords) {
std::string columns[column_count];
DatabaseAccessor::IteratorContextPtr
context(db->getRecords(Name("foo.bar"), 1));
context(db->getRecords("foo.bar", 1));
ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
context);
EXPECT_FALSE(context->getNext(columns));
checkRecordRow(columns, "", "", "", "", "");
// 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));
checkRecordRow(columns, "CNAME", "3600", "",
"cnametest.example.org.", "");
......@@ -207,7 +207,7 @@ TEST_F(SQLite3Access, getRecords) {
"NSEC 5 3 7200 20100322084538 20100220084538 33495 "
"example.com. FAKEFAKEFAKEFAKE", "");
context = db->getRecords(Name("example.com."), zone_id);
context = db->getRecords("example.com.", zone_id);
ASSERT_TRUE(context->getNext(columns));
checkRecordRow(columns, "SOA", "3600", "",
"master.example.com. admin.example.com. "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment