summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Vaner <michal.vaner@nic.cz>2010-12-20 21:04:51 +0100
committerMichal Vaner <michal.vaner@nic.cz>2010-12-20 21:04:51 +0100
commitafa0f7eea0f9d339f956c3223ff64ebd01ef2997 (patch)
tree26dbf9ae3202a99d2b7567ad1401c6c78ddfb85c /src
parentInsert to ZoneTable (diff)
downloadkea-afa0f7eea0f9d339f956c3223ff64ebd01ef2997.tar.xz
kea-afa0f7eea0f9d339f956c3223ff64ebd01ef2997.zip
ZoneTable::find
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac440@3896 e5f2f494-b856-4b98-b285-d166d9295462
Diffstat (limited to 'src')
-rw-r--r--src/lib/datasrc/zonetable.cc44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/lib/datasrc/zonetable.cc b/src/lib/datasrc/zonetable.cc
index 9c87b51645..fdc5040444 100644
--- a/src/lib/datasrc/zonetable.cc
+++ b/src/lib/datasrc/zonetable.cc
@@ -101,6 +101,36 @@ struct ZoneTable::ZoneTableImpl {
return (result::EXIST);
}
}
+
+ ZoneTable::FindResult findZone(const Name& name) const {
+ ZoneNode *node(NULL);
+ result::Result my_result;
+
+ // Translate the return codes
+ switch (zones.find(name, &node)) {
+ case ZoneTree::EXACTMATCH:
+ my_result = result::SUCCESS;
+ break;
+ case ZoneTree::PARTIALMATCH:
+ my_result = result::PARTIALMATCH;
+ break;
+ // We have no data there, so translate the pointer to NULL as well
+ case ZoneTree::NOTFOUND:
+ return (FindResult(result::NOTFOUND, ConstZonePtr()));
+ // Can Not Happen
+ default:
+ isc_throw(AssertError,
+ "RBTree<Zone>::find returned unexpected result");
+ }
+
+ // Can Not Happen (remember, NOTFOUND is handled)
+ if (!node) {
+ isc_throw(AssertError,
+ "RBTree<Zone>::find gave NULL pointer");
+ }
+
+ return (FindResult(my_result, node->getData()));
+ }
};
ZoneTable::ZoneTable() : impl_(new ZoneTableImpl)
@@ -123,18 +153,8 @@ ZoneTable::removeZone(const Name&) {
ZoneTable::FindResult
ZoneTable::findZone(const Name& name) const {
- // Inefficient internal loop to find a longest match.
- // This will be replaced with a single call to more intelligent backend.
- for (int i = 0; i < name.getLabelCount(); ++i) {
- Name matchname(name.split(i));
- ZoneTableImpl::ZoneMap::const_iterator found =
- impl_->zones.find(matchname);
- if (found != impl_->zones.end()) {
- return (FindResult(i == 0 ? result::SUCCESS :
- result::PARTIALMATCH, (*found).second));
- }
- }
- return (FindResult(result::NOTFOUND, ConstZonePtr()));
+ return (impl_->findZone(name));
}
+
} // end of namespace datasrc
} // end of namespace isc