/usr/include/x86_64-linux-gnu/zypp/PoolQueryResult.h is in libzypp-dev 15.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | /*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
| / / \ V /| _/ _/ |
| / /__ | | | | | | |
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
/** \file zypp/PoolQueryResult.h
*
*/
#ifndef ZYPP_POOLQUERYRESULT_H
#define ZYPP_POOLQUERYRESULT_H
#include <iosfwd>
#include "zypp/base/Tr1hash.h"
#include "zypp/base/Exception.h"
#include "zypp/sat/SolvIterMixin.h"
#include "zypp/PoolItem.h"
#include "zypp/PoolQuery.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PoolQueryResult
//
/** Helper class to collect (not only) \ref PoolQuery results.
*
* \note Unfortunately \ref PoolQuery::begin might throw. Exceptions
* are caught and the query is treated as empty.
*
* \ref PoolQueryResult maintains a set of \ref sat::Solvable. You can
* add/remove solvables to/from the set defined by:
*
* \li a single \ref sat::Solvable
* \li a single \ref PoolItem
* \li a \ref PoolQuery
* \li an other \ref PoolQueryResult
* \li any iterator pair with \c value_type \ref sat::Solvable
* or \ref PoolItem or \ref PoolQuery or any type that fits
* \c operator+=.
*
* The class is a \ref sat::SolvIterMixin, so you can iterate the result
* not just as \ref sat::Solvable, but also as \ref PoolItem or
* \ref ui::Selectable.
*
* \code
* // Constructed from PoolItem iterator pair
* PoolQueryResult result( pool.byKindBegin<Package>(), pool.byKindEnd<Package>() );
* MIL << result.size() << endl;
*
* {
* // Removing a PoolQuery result
* PoolQuery q;
* q.addAttribute( sat::SolvAttr::name, "[a-zA-Z]*" );
* q.setMatchGlob();
* result -= q;
* MIL << result.size() << endl;
* }
* MIL << result << endl;
*
* // Removing a range of sat::Solvables
* sat::WhatProvides poviders( Capability("3ddiag") );
* result -= PoolQueryResult( poviders.begin(), poviders.end() );
*
* // packages not starting with a letter, except 3ddiag
* MIL << result << endl;
* \endcode
*/
class PoolQueryResult : public sat::SolvIterMixin<PoolQueryResult,std::tr1::unordered_set<sat::Solvable>::const_iterator>
{
public:
typedef std::tr1::unordered_set<sat::Solvable> ResultSet;
typedef ResultSet::size_type size_type;
typedef ResultSet::const_iterator const_iterator;
public:
/** Default ctor (empty result) */
PoolQueryResult()
{}
/** Ctor adding one \ref sat::Solvable. */
explicit PoolQueryResult( sat::Solvable result_r )
{ operator+=( result_r ); }
/** Ctor adding one \ref PoolItem. */
explicit PoolQueryResult( const PoolItem & result_r )
{ operator+=( result_r ); }
/** Ctor adding one \ref PoolQuery result. */
explicit PoolQueryResult( const PoolQuery & query_r )
{ operator+=( query_r ); }
/** Ctor adding a range of items for which \ref operator+= is defined. */
template<class _QueryResultIter>
PoolQueryResult( _QueryResultIter begin_r, _QueryResultIter end_r )
{
for_( it, begin_r, end_r )
{
operator+=( *it );
}
}
public:
/** Whether the result is empty. */
bool empty() const
{ return _result.empty(); }
/** The number of \ref sat::Solvables. */
size_type size() const
{ return _result.size(); }
/** */
const_iterator begin() const
{ return _result.begin(); }
/** */
const_iterator end() const
{ return _result.end(); }
/** Test whether some item is in the result set. */
bool contains(sat::Solvable result_r ) const
{ return( _result.find( result_r ) != _result.end() ); }
/** \overload */
bool contains( const PoolItem & result_r ) const
{ return contains( result_r.satSolvable() ); }
public:
/** Clear the result. */
void clear()
{ _result.clear(); }
/** Add items to the result. */
PoolQueryResult & operator+=( const PoolQueryResult & query_r )
{
if ( ! query_r.empty() )
_result.insert( query_r.begin(), query_r.end() );
return *this;
}
/** \overload */
PoolQueryResult & operator+=( const PoolQuery & query_r )
{
try
{
for_( it, query_r.begin(), query_r.end() )
_result.insert( *it );
}
catch ( const Exception & )
{}
return *this;
}
/** \overload */
PoolQueryResult & operator+=( sat::Solvable result_r )
{
_result.insert( result_r );
return *this;
}
/** \overload */
PoolQueryResult & operator+=( const PoolItem & result_r )
{
_result.insert( result_r.satSolvable() );
return *this;
}
/** Remove Items from the result. */
PoolQueryResult & operator-=( const PoolQueryResult & query_r )
{
if ( &query_r == this ) // catch self removal!
clear();
else
for_( it, query_r.begin(), query_r.end() )
_result.erase( *it );
return *this;
}
/** \overload */
PoolQueryResult & operator-=( const PoolQuery & query_r )
{
try
{
for_( it, query_r.begin(), query_r.end() )
_result.erase( *it );
}
catch ( const Exception & )
{}
return *this;
}
/** \overload */
PoolQueryResult & operator-=( sat::Solvable result_r )
{
_result.erase( result_r );
return *this;
}
/** \overload */
PoolQueryResult & operator-=( const PoolItem & result_r )
{
_result.erase( result_r.satSolvable() );
return *this;
}
public:
/** Combine results. */
PoolQueryResult operator+( const PoolQueryResult & query_r ) const
{ return PoolQueryResult(*this) += query_r; }
/** \overload */
PoolQueryResult operator+( const PoolQuery & query_r ) const
{ return PoolQueryResult(*this) += query_r; }
/** \overload */
PoolQueryResult operator+( sat::Solvable result_r ) const
{ return PoolQueryResult(*this) += result_r; }
/** Intersect results. */
PoolQueryResult operator-( const PoolQueryResult & query_r ) const
{ return PoolQueryResult(*this) -= query_r; }
/** \overload */
PoolQueryResult operator-( const PoolQuery & query_r ) const
{ return PoolQueryResult(*this) -= query_r; }
/** \overload */
PoolQueryResult operator-( sat::Solvable result_r ) const
{ return PoolQueryResult(*this) -= result_r; }
private:
ResultSet _result;
};
///////////////////////////////////////////////////////////////////
/** \relates PoolQueryResult Stream output */
std::ostream & operator<<( std::ostream & str, const PoolQueryResult & obj );
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_POOLQUERYRESULT_H
|