[svn] commit: r3595 - in /trunk: ./ src/bin/bind10/ src/bin/host/ src/lib/datasrc/ src/lib/datasrc/tests/ src/lib/dns/ src/lib/dns/python/ src/lib/dns/tests/
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Nov 22 12:53:00 UTC 2010
Author: jinmei
Date: Mon Nov 22 12:52:59 2010
New Revision: 3595
Log:
merged trac #410 (getRdataIterator initialization change)
Modified:
trunk/ (props changed)
trunk/src/bin/bind10/bind10.py.in (props changed)
trunk/src/bin/host/host.cc
trunk/src/lib/datasrc/data_source.cc
trunk/src/lib/datasrc/tests/datasrc_unittest.cc
trunk/src/lib/datasrc/tests/sqlite3_unittest.cc
trunk/src/lib/datasrc/tests/static_unittest.cc
trunk/src/lib/datasrc/tests/test_datasrc.cc
trunk/src/lib/dns/python/rrset_python.cc
trunk/src/lib/dns/rrset.cc
trunk/src/lib/dns/rrset.h
trunk/src/lib/dns/tests/message_unittest.cc
trunk/src/lib/dns/tests/rrset_unittest.cc
trunk/src/lib/dns/tests/rrsetlist_unittest.cc
Modified: trunk/src/bin/host/host.cc
==============================================================================
--- trunk/src/bin/host/host.cc (original)
+++ trunk/src/bin/host/host.cc Mon Nov 22 12:52:59 2010
@@ -131,7 +131,7 @@
}
RdataIteratorPtr rit = (*it)->getRdataIterator();
- for (rit->first(); !rit->isLast(); rit->next()) {
+ for (; !rit->isLast(); rit->next()) {
// instead of using my name, maybe use returned label?
cout << name << " has address " <<
(*rit).getCurrent().toText() << endl;
Modified: trunk/src/lib/datasrc/data_source.cc
==============================================================================
--- trunk/src/lib/datasrc/data_source.cc (original)
+++ trunk/src/lib/datasrc/data_source.cc Mon Nov 22 12:52:59 2010
@@ -95,7 +95,7 @@
}
RdataIteratorPtr it = rrset->getRdataIterator();
- for (it->first(); !it->isLast(); it->next()) {
+ for (; !it->isLast(); it->next()) {
const Rdata& rd(it->getCurrent());
if (rrset->getType() == RRType::NS()) {
const generic::NS& ns = dynamic_cast<const generic::NS&>(rd);
@@ -123,7 +123,6 @@
// More than one DNAME RR in the RRset is illegal, so we only have
// to process the first one.
- it->first();
if (it->isLast()) {
return;
}
@@ -152,7 +151,6 @@
// More than one CNAME RR in the RRset is illegal, so we only have
// to process the first one.
- it->first();
if (it->isLast()) {
return;
}
@@ -660,7 +658,6 @@
// XXX: currently only one NSEC3 chain per zone is supported;
// we will need to revisit this.
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
if (it->isLast()) {
return (ConstNsec3ParamPtr());
}
Modified: trunk/src/lib/datasrc/tests/datasrc_unittest.cc
==============================================================================
--- trunk/src/lib/datasrc/tests/datasrc_unittest.cc (original)
+++ trunk/src/lib/datasrc/tests/datasrc_unittest.cc Mon Nov 22 12:52:59 2010
@@ -124,7 +124,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -138,7 +137,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -154,7 +152,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -193,7 +190,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -216,7 +212,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -237,7 +232,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -334,7 +328,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.2", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -353,7 +346,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -369,7 +361,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -406,7 +397,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("www.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -419,7 +409,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -438,7 +427,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -454,7 +442,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -474,7 +461,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("www.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -506,7 +492,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("spork.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -544,7 +529,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.2", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -556,7 +540,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -572,7 +555,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -591,7 +573,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("sql1.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -605,7 +586,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -621,7 +601,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -649,7 +628,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("cnametest.flame.org.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -668,7 +646,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("www.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -695,7 +672,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("www.sql1.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -720,7 +696,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("ns1.subzone.example.com.", it->getCurrent().toText());
it->next();
EXPECT_FALSE(it->isLast());
@@ -732,7 +707,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -751,7 +725,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("ns1.subzone.example.com.", it->getCurrent().toText());
it->next();
EXPECT_FALSE(it->isLast());
@@ -763,7 +736,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -795,7 +767,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -817,7 +788,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("ns1.subzone.example.com.", it->getCurrent().toText());
it->next();
EXPECT_FALSE(it->isLast());
@@ -829,7 +799,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
@@ -854,7 +823,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
@@ -890,7 +858,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ(createRdata(RRType::NS(), RRClass::IN(),
"ns.sub.example.org.")->toText(),
it->getCurrent().toText());
@@ -904,7 +871,6 @@
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ(createRdata(RRType::A(), RRClass::IN(), "192.0.2.101")->toText(),
it->getCurrent().toText());
it->next();
Modified: trunk/src/lib/datasrc/tests/sqlite3_unittest.cc
==============================================================================
--- trunk/src/lib/datasrc/tests/sqlite3_unittest.cc (original)
+++ trunk/src/lib/datasrc/tests/sqlite3_unittest.cc Mon Nov 22 12:52:59 2010
@@ -244,7 +244,6 @@
EXPECT_EQ(expected_rrttl, rrset->getTTL());
RdataIteratorPtr rdata_iterator = rrset->getRdataIterator();
- rdata_iterator->first();
vector<string>::const_iterator data_it = expected_data.begin();
for (; data_it != expected_data.end(); ++data_it) {
EXPECT_FALSE(rdata_iterator->isLast());
Modified: trunk/src/lib/datasrc/tests/static_unittest.cc
==============================================================================
--- trunk/src/lib/datasrc/tests/static_unittest.cc (original)
+++ trunk/src/lib/datasrc/tests/static_unittest.cc Mon Nov 22 12:52:59 2010
@@ -109,7 +109,6 @@
EXPECT_EQ(rrttl, rrset->getTTL());
RdataIteratorPtr rdata_iterator = rrset->getRdataIterator();
- rdata_iterator->first();
vector<string>::const_iterator data_it = expected_data.begin();
for (; data_it != expected_data.end(); ++data_it) {
EXPECT_FALSE(rdata_iterator->isLast());
Modified: trunk/src/lib/datasrc/tests/test_datasrc.cc
==============================================================================
--- trunk/src/lib/datasrc/tests/test_datasrc.cc (original)
+++ trunk/src/lib/datasrc/tests/test_datasrc.cc Mon Nov 22 12:52:59 2010
@@ -408,7 +408,7 @@
RRsetPtr rrset = RRsetPtr(new RRset(source->getName(), source->getClass(),
source->getType(), source->getTTL()));
RdataIteratorPtr it = source->getRdataIterator();
- for (it->first(); !it->isLast(); it->next()) {
+ for (; !it->isLast(); it->next()) {
rrset->addRdata(it->getCurrent());
}
if (source->getRRsig()) {
Modified: trunk/src/lib/dns/python/rrset_python.cc
==============================================================================
--- trunk/src/lib/dns/python/rrset_python.cc (original)
+++ trunk/src/lib/dns/python/rrset_python.cc Mon Nov 22 12:52:59 2010
@@ -355,7 +355,7 @@
RdataIteratorPtr it = self->rrset->getRdataIterator();
- for (it->first(); !it->isLast(); it->next()) {
+ for (; !it->isLast(); it->next()) {
s_Rdata *rds = static_cast<s_Rdata*>(rdata_type.tp_alloc(&rdata_type, 0));
if (rds != NULL) {
// hmz them iterators/shared_ptrs and private constructors
Modified: trunk/src/lib/dns/rrset.cc
==============================================================================
--- trunk/src/lib/dns/rrset.cc (original)
+++ trunk/src/lib/dns/rrset.cc Mon Nov 22 12:52:59 2010
@@ -44,7 +44,6 @@
string s;
RdataIteratorPtr it = getRdataIterator();
- it->first();
if (it->isLast()) {
isc_throw(EmptyRRset, "ToText() is attempted for an empty RRset");
}
@@ -66,7 +65,6 @@
unsigned int n = 0;
RdataIteratorPtr it = rrset.getRdataIterator();
- it->first();
if (it->isLast()) {
isc_throw(EmptyRRset, "ToWire() is attempted for an empty RRset");
}
@@ -224,7 +222,8 @@
BasicRdataIterator() {}
public:
BasicRdataIterator(const std::vector<rdata::ConstRdataPtr>& datavector) :
- datavector_(&datavector) {}
+ datavector_(&datavector), it_(datavector_->begin())
+ {}
~BasicRdataIterator() {}
virtual void first() { it_ = datavector_->begin(); }
virtual void next() { ++it_; }
Modified: trunk/src/lib/dns/rrset.h
==============================================================================
--- trunk/src/lib/dns/rrset.h (original)
+++ trunk/src/lib/dns/rrset.h Mon Nov 22 12:52:59 2010
@@ -148,7 +148,7 @@
/// "sort" and "search(find)" method?
/// - what about comparing two RRsets of the same type? If we need this,
/// should it compare rdata's as a set or as a list (i.e. compare
-/// each %rdata one by one or as a whole)? c.f. NLnet Labs' ldns
+/// each rdata one by one or as a whole)? c.f. NLnet Labs' ldns
/// (http://www.nlnetlabs.nl/projects/ldns/doc/index.html)
/// has \c ldns_rr_list_compare(), which takes the latter approach
/// (seemingly assuming the caller sorts the lists beforehand).
@@ -357,7 +357,7 @@
/// \endcode
///
/// This method is more strictly typed than the pointer version:
- /// If \c %rdata does not refer to the appropriate derived
+ /// If \c rdata does not refer to the appropriate derived
/// \c Rdata class
/// for the \c RRType for this \c RRset, it throws an exception of class
/// \c std::bad_cast.
@@ -385,6 +385,10 @@
/// \brief Return an iterator to go through all RDATA stored in the
/// \c RRset.
///
+ /// The rdata cursor of the returned iterator will point to the first
+ /// RDATA, that is, it effectively calls \c RdataIterator::first()
+ /// internally.
+ ///
/// Using the design pattern terminology, \c getRdataIterator()
/// is an example of a <em>factory method</em>.
///
@@ -417,10 +421,10 @@
/// The RDATA objects stored in the \c RRset are considered to form
/// a unidirectional list from the \c RdataIterator point of view (while
/// the actual implementation in the derived \c RRset may not use a list).
-/// We call this unidirectional list the <em>%rdata list</em>.
+/// We call this unidirectional list the <em>rdata list</em>.
///
/// An \c RdataIterator object internally (and conceptually) holds a
-/// <em>%rdata cursor</em>, which points to a specific item of the %rdata list.
+/// <em>rdata cursor</em>, which points to a specific item of the rdata list.
///
/// Note about design choice: as is clear from the interface, \c RdataIterator
/// is not compatible with the standard iterator classes.
@@ -458,29 +462,29 @@
//@}
public:
- /// \brief Move the %rdata cursor to the first RDATA in the %rdata list
+ /// \brief Move the rdata cursor to the first RDATA in the rdata list
/// (if any).
///
/// This method can safely be called multiple times, even after moving
- /// the %rdata cursor forward by the \c next() method.
+ /// the rdata cursor forward by the \c next() method.
///
/// This method should never throw an exception.
virtual void first() = 0;
- /// \brief Move the %rdata cursor to the next RDATA in the %rdata list
+ /// \brief Move the rdata cursor to the next RDATA in the rdata list
/// (if any).
///
/// This method should never throw an exception.
virtual void next() = 0;
- /// \brief Return the current \c Rdata corresponding to the %rdata cursor.
+ /// \brief Return the current \c Rdata corresponding to the rdata cursor.
///
/// \return A reference to an \c rdata::::Rdata object corresponding
- /// to the %rdata cursor.
+ /// to the rdata cursor.
virtual const rdata::Rdata& getCurrent() const = 0;
- /// \brief Return true iff the %rdata cursor has reached the end of the
- /// %rdata list.
+ /// \brief Return true iff the rdata cursor has reached the end of the
+ /// rdata list.
///
/// Once this method returns \c true, the behavior of any subsequent
/// call to \c next() or \c getCurrent() is undefined.
@@ -489,8 +493,8 @@
///
/// This method should never throw an exception.
///
- /// \return \c true if the %rdata cursor has reached the end of the
- /// %rdata list; otherwise \c false.
+ /// \return \c true if the rdata cursor has reached the end of the
+ /// rdata list; otherwise \c false.
virtual bool isLast() const = 0;
};
Modified: trunk/src/lib/dns/tests/message_unittest.cc
==============================================================================
--- trunk/src/lib/dns/tests/message_unittest.cc (original)
+++ trunk/src/lib/dns/tests/message_unittest.cc Mon Nov 22 12:52:59 2010
@@ -293,7 +293,6 @@
// TTL should be 3600, even though that of the 2nd RR is 7200
EXPECT_EQ(RRTTL(3600), rrset->getTTL());
RdataIteratorPtr it = rrset->getRdataIterator();
- it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_EQ("192.0.2.2", it->getCurrent().toText());
Modified: trunk/src/lib/dns/tests/rrset_unittest.cc
==============================================================================
--- trunk/src/lib/dns/tests/rrset_unittest.cc (original)
+++ trunk/src/lib/dns/tests/rrset_unittest.cc Mon Nov 22 12:52:59 2010
@@ -117,8 +117,7 @@
addRdataTestCommon(const RRset& rrset) {
EXPECT_EQ(2, rrset.getRdataCount());
- RdataIteratorPtr it = rrset.getRdataIterator();
- it->first();
+ RdataIteratorPtr it = rrset.getRdataIterator(); // cursor is set to the 1st
EXPECT_FALSE(it->isLast());
EXPECT_EQ(0, it->getCurrent().compare(in::A("192.0.2.1")));
it->next();
@@ -156,7 +155,6 @@
TEST_F(RRsetTest, iterator) {
// Iterator for an empty RRset.
RdataIteratorPtr it = rrset_a_empty.getRdataIterator();
- it->first();
EXPECT_TRUE(it->isLast());
// Normal case (already tested, but do it again just in case)
Modified: trunk/src/lib/dns/tests/rrsetlist_unittest.cc
==============================================================================
--- trunk/src/lib/dns/tests/rrsetlist_unittest.cc (original)
+++ trunk/src/lib/dns/tests/rrsetlist_unittest.cc Mon Nov 22 12:52:59 2010
@@ -150,7 +150,6 @@
RdataIteratorPtr it =
list.findRRset(RRType::A(), RRClass::IN())->getRdataIterator();
- it->first();
EXPECT_FALSE(it->isLast());
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
}
More information about the bind10-changes
mailing list