libzypp 17.37.17
LookupAttrTools.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_SAT_LOOKUPATTRTOOLS_H
13#define ZYPP_SAT_LOOKUPATTRTOOLS_H
14
15#include <zypp/sat/LookupAttr.h>
16#include <zypp/Repository.h>
17
18#include <utility>
19
21namespace zypp
22{
24 namespace sat
25 {
26
28 //
29 // CLASS NAME : LookupAttr::TransformIterator
30 //
57 template<class TResult, class TAttr>
58 class LookupAttr::TransformIterator : public boost::iterator_adaptor<
59 TransformIterator<TResult,TAttr> // Derived
60 , LookupAttr::iterator // Base
61 , TResult // Value
62 , boost::forward_traversal_tag // CategoryOrTraversal
63 , TResult // Reference
64 >
65 {
66 public:
69
70 explicit
72 { this->base_reference() = val_r; }
73
74 public:
75
78
80 { this->base_reference().nextSkipSolvAttr(); }
81
84 { this->base_reference().nextSkipSolvable(); }
85
88 { this->base_reference().nextSkipRepo(); }
89
92 { this->base_reference().skipSolvAttr(); }
93
96 { this->base_reference().skipSolvable(); }
97
99 void skipRepo()
100 { this->base_reference().skipRepo(); }
101
102
105
107 { return this->base_reference().inRepo(); }
108
111 { return this->base_reference().inSolvable(); }
112
115 { return this->base_reference().inSolvAttr(); }
116
117
118 private:
120
121 TResult dereference() const
122 {
123 const LookupAttr::iterator lit( this->base_reference() );
124 return TResult( lit.asType<TAttr>() );
125 }
126 };
127
128
129 template<class TResult, class TAttr>
130 class ArrayAttr;
131
132 template<class TResult, class TAttr>
133 std::ostream & operator<<( std::ostream & str, const ArrayAttr<TResult,TAttr> & obj );
134
136 //
137 // CLASS NAME : ArrayAttr
138 //
155 template<class TResult, class TAttr>
157 {
158 friend std::ostream & operator<< <TResult,TAttr>( std::ostream & str, const ArrayAttr<TResult,TAttr> & obj );
159
160 public:
162 {}
163
165 : _q( std::move(attr_r), loc_r )
166 {}
167
169 : _q( std::move(attr_r), repo_r, loc_r )
170 {}
171
172 ArrayAttr( SolvAttr attr_r, Solvable solv_r )
173 : _q( std::move(attr_r), solv_r )
174 {}
175
176 public:
179
181 { return iterator( _q.begin() ); }
182
183 iterator end() const
184 { return iterator( _q.end() ); }
185
186 bool empty() const
187 { return _q.empty(); }
188
190 {
191 size_type count = 0;
192 for_( it, begin(), end() )
193 ++count;
194 return count;
195 }
196
197 public:
198
199 iterator find( const TResult & key_r ) const
200 {
201 for_( it, begin(), end() )
202 {
203 if ( *it == key_r )
204 return it;
205 }
206 return end();
207 }
208
209 private:
211 };
212
213
215 template<class TResult, class TAttr>
216 inline std::ostream & operator<<( std::ostream & str, const ArrayAttr<TResult,TAttr> & obj )
217 { return dumpOn( str, obj._q ); }
218
220 } // namespace sat
223} // namespace zypp
225#endif // ZYPP_SAT_LOOKUPATTRTOOLS_H
LookupAttr::TransformIterator based container to retrieve list attributes.
iterator end() const
iterator begin() const
iterator find(const TResult &key_r) const
ArrayAttr(SolvAttr attr_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
friend std::ostream & operator(std::ostream &str, const ArrayAttr< TResult, TAttr > &obj)
size_type size() const
ArrayAttr(SolvAttr attr_r, Solvable solv_r)
ArrayAttr(SolvAttr attr_r, Repository repo_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
LookupAttr::TransformIterator< PackageKeyword, IdString > iterator
TransformIterator returning an iterator vaue of type TResult.
void skipRepo()
Immediately advance to the next Repository.
Repository inRepo() const
The current Repository.
void skipSolvable()
Immediately advance to the next Solvable.
void skipSolvAttr()
Immediately advance to the next SolvAttr.
Solvable inSolvable() const
The current Solvabele.
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
TransformIterator(const LookupAttr::iterator &val_r)
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
SolvAttr inSolvAttr() const
The current SolvAttr.
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
Tp asType() const
Templated return type.
Definition LookupAttr.h:535
std::ostream & operator<<(std::ostream &str, const ArrayAttr< TResult, TAttr > &obj)
Stream output.
Lightweight attribute value lookup.
Definition LookupAttr.h:110
unsigned int size_type
Definition LookupAttr.h:115
Location
Specify the where to look for the attribule.
Definition LookupAttr.h:118
@ SOLV_ATTR
Search for solvable attributes (default)
Definition LookupAttr.h:119
Solvable attribute keys.
Definition SolvAttr.h:41
A Solvable object within the sat Pool.
Definition Solvable.h:54
Definition Arch.h:364
String related utilities and Regular expression matching.
Libsolv interface
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
Easy-to use interface to the ZYPP dependency resolver.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27