libzypp: zypp/sat/LookupAttrTools.h Source File

libzypp 17.38.5

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:
67 TransformIterator()
68 {}
69
70 explicit
71 TransformIterator( const LookupAttr::iterator & val_r )
72 { this->base_reference() = val_r; }
73
74 public:
75
78
79 void nextSkipSolvAttr()
80 { this->base_reference().nextSkipSolvAttr(); }
81
83 void nextSkipSolvable()
84 { this->base_reference().nextSkipSolvable(); }
85
87 void nextSkipRepo()
88 { this->base_reference().nextSkipRepo(); }
89
91 void skipSolvAttr()
92 { this->base_reference().skipSolvAttr(); }
93
95 void skipSolvable()
96 { this->base_reference().skipSolvable(); }
97
99 void skipRepo()
100 { this->base_reference().skipRepo(); }
101
102
105
106 Repository inRepo() const
107 { return this->base_reference().inRepo(); }
108
110 Solvable inSolvable() const
111 { return this->base_reference().inSolvable(); }
112
114 SolvAttr inSolvAttr() const
115 { return this->base_reference().inSolvAttr(); }
116
117
118 private:
119 friend class boost::iterator_core_access;
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>
156 class ArrayAttr
157 {
158 friend std::ostream & operator<< <TResult,TAttr>( std::ostream & str, const ArrayAttr<TResult,TAttr> & obj );
159
160 public:
161 ArrayAttr()
162 {}
163
164 ArrayAttr( SolvAttr attr_r, LookupAttr::Location loc_r = LookupAttr::SOLV_ATTR )
165 : _q( std::move(attr_r), loc_r )
166 {}
167
168 ArrayAttr( SolvAttr attr_r, Repository repo_r, LookupAttr::Location loc_r = LookupAttr::SOLV_ATTR )
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:
177 using iterator = LookupAttr::TransformIterator<TResult, TAttr>;
178 using size_type = LookupAttr::size_type;
179
180 iterator begin() const
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
189 size_type size() const
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:
210 LookupAttr _q;
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
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
LookupAttr.h
Repository.h
zypp::Repository
Definition Repository.h:40
zypp::sat::ArrayAttr
LookupAttr::TransformIterator based container to retrieve list attributes.
Definition LookupAttrTools.h:157
zypp::sat::ArrayAttr::end
iterator end() const
Definition LookupAttrTools.h:183
zypp::sat::ArrayAttr::begin
iterator begin() const
Definition LookupAttrTools.h:180
zypp::sat::ArrayAttr::empty
bool empty() const
Definition LookupAttrTools.h:186
zypp::sat::ArrayAttr::find
iterator find(const TResult &key_r) const
Definition LookupAttrTools.h:199
zypp::sat::ArrayAttr< PackageKeyword, IdString >::size_type
LookupAttr::size_type size_type
Definition LookupAttrTools.h:178
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr(SolvAttr attr_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
Definition LookupAttrTools.h:164
zypp::sat::ArrayAttr::operator
friend std::ostream & operator(std::ostream &str, const ArrayAttr< TResult, TAttr > &obj)
zypp::sat::ArrayAttr::size
size_type size() const
Definition LookupAttrTools.h:189
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr(SolvAttr attr_r, Solvable solv_r)
Definition LookupAttrTools.h:172
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr(SolvAttr attr_r, Repository repo_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
Definition LookupAttrTools.h:168
zypp::sat::ArrayAttr< PackageKeyword, IdString >::iterator
LookupAttr::TransformIterator< PackageKeyword, IdString > iterator
Definition LookupAttrTools.h:177
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr()
Definition LookupAttrTools.h:161
zypp::sat::ArrayAttr< PackageKeyword, IdString >::_q
LookupAttr _q
Definition LookupAttrTools.h:210
zypp::sat::LookupAttr::TransformIterator
TransformIterator returning an iterator vaue of type TResult.
Definition LookupAttrTools.h:65
zypp::sat::LookupAttr::TransformIterator::skipRepo
void skipRepo()
Immediately advance to the next Repository.
Definition LookupAttrTools.h:99
zypp::sat::LookupAttr::TransformIterator::inRepo
Repository inRepo() const
The current Repository.
Definition LookupAttrTools.h:106
zypp::sat::LookupAttr::TransformIterator::skipSolvable
void skipSolvable()
Immediately advance to the next Solvable.
Definition LookupAttrTools.h:95
zypp::sat::LookupAttr::TransformIterator::skipSolvAttr
void skipSolvAttr()
Immediately advance to the next SolvAttr.
Definition LookupAttrTools.h:91
zypp::sat::LookupAttr::TransformIterator::inSolvable
Solvable inSolvable() const
The current Solvabele.
Definition LookupAttrTools.h:110
zypp::sat::LookupAttr::TransformIterator::nextSkipRepo
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
Definition LookupAttrTools.h:87
zypp::sat::LookupAttr::TransformIterator::TransformIterator
TransformIterator(const LookupAttr::iterator &val_r)
Definition LookupAttrTools.h:71
zypp::sat::LookupAttr::TransformIterator::nextSkipSolvable
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
Definition LookupAttrTools.h:83
zypp::sat::LookupAttr::TransformIterator::TransformIterator
TransformIterator()
Definition LookupAttrTools.h:67
zypp::sat::LookupAttr::TransformIterator::inSolvAttr
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition LookupAttrTools.h:114
zypp::sat::LookupAttr::TransformIterator::iterator_core_access
friend class boost::iterator_core_access
Definition LookupAttrTools.h:119
zypp::sat::LookupAttr::TransformIterator::nextSkipSolvAttr
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
Definition LookupAttrTools.h:79
zypp::sat::LookupAttr::TransformIterator::dereference
TResult dereference() const
Definition LookupAttrTools.h:121
zypp::sat::LookupAttr::iterator
Result iterator.
Definition LookupAttr.h:364
zypp::sat::LookupAttr::iterator::asType
Tp asType() const
Templated return type.
Definition LookupAttr.h:535
zypp::sat::LookupAttr::iterator::operator<<
std::ostream & operator<<(std::ostream &str, const ArrayAttr< TResult, TAttr > &obj)
Stream output.
Definition LookupAttrTools.h:216
zypp::sat::LookupAttr
Lightweight attribute value lookup.
Definition LookupAttr.h:110
zypp::sat::LookupAttr::size_type
unsigned int size_type
Definition LookupAttr.h:115
zypp::sat::LookupAttr::Location
Location
Specify the where to look for the attribule.
Definition LookupAttr.h:118
zypp::sat::LookupAttr::SOLV_ATTR
@ SOLV_ATTR
Search for solvable attributes (default).
Definition LookupAttr.h:119
zypp::sat::SolvAttr
Solvable attribute keys.
Definition SolvAttr.h:41
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
std
Definition ansi.h:855
str
String related utilities and Regular expression matching.
zypp::sat
Libsolv interface
zypp::sat::operator<<
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
Definition FileConflicts.cc:109
zypp::sat::dumpOn
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
Definition LocaleSupport.cc:41
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2