Author: jkupec Date: Tue Apr 29 23:27:31 2008 New Revision: 9895 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9895&view=rev Log: - don't throw in begin() if the specified repo is not found in pool, return end() instead (bnc #384337) - catch exceptions within size() and empty(), act as if the result is empty in such case (bnc #384337) 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=9895&r1=9894&r2=9895&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/PoolQuery_test.cc (original) +++ trunk/libzypp/tests/zypp/PoolQuery_test.cc Tue Apr 29 23:27:31 2008 @@ -222,7 +222,7 @@ PoolQuery q2; q2.addString("zypp\\"); q2.setMatchRegex(); - BOOST_CHECK_THROW(q2.size(), Exception); + BOOST_CHECK_THROW(q2.begin(), Exception); } Modified: trunk/libzypp/zypp/PoolQuery.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9895&r1=9894&r2=9895&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.cc (original) +++ trunk/libzypp/zypp/PoolQuery.cc Tue Apr 29 23:27:31 2008 @@ -377,9 +377,8 @@ repo = pool.reposFind(theone); if (repo == Repository::noRepository) { - RepoInfo info; info.setAlias(theone); - ERR << "Repository not found in sat pool." << endl; - ZYPP_THROW(repo::RepoNotFoundException(info)); + DBG << "Repository '" << theone << "' not found in sat pool." << endl; + return end(); } } @@ -850,13 +849,22 @@ bool PoolQuery::empty() const - { return _pimpl->begin() == _pimpl->end(); } + { + try { return _pimpl->begin() == _pimpl->end(); } + catch (const Exception & ex) {} + return true; + } + - //! \todo collect the result, reuse if not dirty PoolQuery::size_type PoolQuery::size() const { size_type count = 0; - for(const_iterator it = _pimpl->begin(); it != _pimpl->end(); ++it, ++count); + try + { + for(const_iterator it = _pimpl->begin(); it != _pimpl->end(); ++it, ++count); + } + catch (const Exception & ex) {} + return count; } Modified: trunk/libzypp/zypp/PoolQuery.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.h?rev=9895&r1=9894&r2=9895&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.h (original) +++ trunk/libzypp/zypp/PoolQuery.h Tue Apr 29 23:27:31 2008 @@ -66,15 +66,28 @@ /** Query result accessers. */ //@{ - class PoolQueryIterator; - /** */ + /** + * Compile the query and return an iterator to the result. + * + * \return An iterator (\ref detail::PoolQueryIterator) returning + * sat::Solvable objects pointing at the beginning of the query result. + * \throws \ref Exception if the query was about to use a regex which + * failed to compile. + * + * \note Note that PoolQuery is derived from \ref sat::SolvIterMixin which + * makes PoolItem and Selectable iterators automatically available. + * \see sat::SolvIterMixin + */ const_iterator begin() const; - /** */ + + /** An iterator pointing to the end of the query result. */ const_iterator end() const; - /** */ + + /** Whether the result is empty. */ bool empty() const; - /** */ + + /** Number of solvables in the query result. */ size_type size() const; //@} -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org