Author: jreidinger Date: Thu Apr 10 15:26:04 2008 New Revision: 9510 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9510&view=rev Log: fix operator== for PoolQuery. add != Modified: trunk/libzypp/tests/zypp/PoolQuery_test.cc trunk/libzypp/zypp/PoolQuery.cc trunk/libzypp/zypp/PoolQuery.h Modified: trunk/libzypp/tests/zypp/PoolQuery_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/PoolQuery_test.cc?rev=9510&r1=9509&r2=9510&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/PoolQuery_test.cc (original) +++ trunk/libzypp/tests/zypp/PoolQuery_test.cc Thu Apr 10 15:26:04 2008 @@ -437,11 +437,10 @@ q4.addAttribute(sat::SolvAttr::name,"zypp"); q4.setMatchGlob(); - BOOST_CHECK(equal(q,q2)); - BOOST_CHECK(!equal(q,q3)); - //only exact equal! \TODO maybe change - BOOST_CHECK(!equal(q,q4)); - BOOST_CHECK(!equal(q4,q3)); + BOOST_CHECK(q==q2); + BOOST_CHECK(q!=q3); + BOOST_CHECK(q==q4); + BOOST_CHECK(q4!=q3); } // save/load query Modified: trunk/libzypp/zypp/PoolQuery.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9510&r1=9509&r2=9510&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.cc (original) +++ trunk/libzypp/zypp/PoolQuery.cc Thu Apr 10 15:26:04 2008 @@ -59,8 +59,8 @@ string asString() const; - private: void compile() const; + private: string createRegex(const StrContainer & container) const; public: @@ -944,15 +944,13 @@ ostream & operator<<( ostream & str, const PoolQuery & obj ) { return str << obj.asString(); } - bool operator==(const PoolQuery& a, const PoolQuery& b) - { - return equal(a,b); - } - //internal matching two containers O(n^2) template <class Container> bool equalContainers(const Container& a, const Container& b) { + if (a.size()!=b.size()) + return false; + for_(it,a.begin(),a.end()) { bool finded = false; @@ -971,21 +969,27 @@ return true; } - bool equal(const PoolQuery& a, const PoolQuery& b) + bool PoolQuery::operator==(const PoolQuery& a) const { - if( a.matchType()!=b.matchType() ) + if (!_pimpl->_compiled) + _pimpl->compile(); + if (!a._pimpl->_compiled) + a._pimpl->compile(); + if( matchType()!=a.matchType() ) + return false; + if( a.matchWord()!=matchWord()) return false; - if( a.matchWord()!=b.matchWord()) + if( a.requireAll()!=requireAll() ) return false; - if( a.requireAll()!=b.requireAll() ) + if(!equalContainers(a.kinds(), kinds())) return false; - if(!equalContainers(a.strings(), b.strings())) + if(!equalContainers(a.repos(), repos())) return false; - if(!equalContainers(a.kinds(), b.kinds())) + if(a._pimpl->_rcstrings!=_pimpl->_rcstrings) return false; - if(!equalContainers(a.repos(), b.repos())) + if(!equalContainers(a._pimpl->_rcattrs, _pimpl->_rcattrs)) return false; - if(!equalContainers(a.attributes(), b.attributes())) + if(a._pimpl->_cflags!= _pimpl->_cflags) return false; return true; Modified: trunk/libzypp/zypp/PoolQuery.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.h?rev=9510&r1=9509&r2=9510&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.h (original) +++ trunk/libzypp/zypp/PoolQuery.h Thu Apr 10 15:26:04 2008 @@ -249,6 +249,8 @@ /** Return a human-readable description of the query */ std::string asString() const; + bool operator==(const PoolQuery& b) const; + bool operator!=(const PoolQuery& b) const { return !(*this == b ); } // low level API @@ -276,8 +278,6 @@ /** \relates PoolQuery Stream output. */ std::ostream & operator<<( std::ostream & str, const PoolQuery & obj ); - bool equal(const PoolQuery& a, const PoolQuery& b); - bool operator==(const PoolQuery& a, const PoolQuery& b); /////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org