libzypp  17.23.8
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 
19 namespace zypp
20 {
21  namespace sat
23  {
24 
26  //
27  // CLASS NAME : LookupAttr::TransformIterator
28  //
55  template<class TResult, class TAttr>
56  class LookupAttr::TransformIterator : public boost::iterator_adaptor<
57  TransformIterator<TResult,TAttr> // Derived
58  , LookupAttr::iterator // Base
59  , TResult // Value
60  , boost::forward_traversal_tag // CategoryOrTraversal
61  , TResult // Reference
62  >
63  {
64  public:
66  {}
67 
68  explicit
70  { this->base_reference() = val_r; }
71 
72  public:
73 
78  { this->base_reference().nextSkipSolvAttr(); }
79 
82  { this->base_reference().nextSkipSolvable(); }
83 
85  void nextSkipRepo()
86  { this->base_reference().nextSkipRepo(); }
87 
89  void skipSolvAttr()
90  { this->base_reference().skipSolvAttr(); }
91 
93  void skipSolvable()
94  { this->base_reference().skipSolvable(); }
95 
97  void skipRepo()
98  { this->base_reference().skipRepo(); }
100 
105  { return this->base_reference().inRepo(); }
106 
109  { return this->base_reference().inSolvable(); }
110 
113  { return this->base_reference().inSolvAttr(); }
115 
116  private:
118 
119  TResult dereference() const
120  {
121  const LookupAttr::iterator lit( this->base_reference() );
122  return TResult( lit.asType<TAttr>() );
123  }
124  };
126 
127  template<class TResult, class TAttr>
128  class ArrayAttr;
129 
130  template<class TResult, class TAttr>
131  std::ostream & operator<<( std::ostream & str, const ArrayAttr<TResult,TAttr> & obj );
132 
134  //
135  // CLASS NAME : ArrayAttr
136  //
153  template<class TResult, class TAttr>
154  class ArrayAttr
155  {
156  friend std::ostream & operator<< <TResult,TAttr>( std::ostream & str, const ArrayAttr<TResult,TAttr> & obj );
157 
158  public:
160  {}
161 
163  : _q( attr_r, loc_r )
164  {}
165 
167  : _q( attr_r, repo_r, loc_r )
168  {}
169 
170  ArrayAttr( SolvAttr attr_r, Solvable solv_r )
171  : _q( attr_r, solv_r )
172  {}
173 
174  public:
177 
178  iterator begin() const
179  { return iterator( _q.begin() ); }
180 
181  iterator end() const
182  { return iterator( _q.end() ); }
183 
184  bool empty() const
185  { return _q.empty(); }
186 
187  size_type size() const
188  {
189  size_type count = 0;
190  for_( it, begin(), end() )
191  ++count;
192  return count;
193  }
194 
195  public:
196 
197  iterator find( const TResult & key_r ) const
198  {
199  for_( it, begin(), end() )
200  {
201  if ( *it == key_r )
202  return it;
203  }
204  return end();
205  }
206 
207  private:
209  };
211 
213  template<class TResult, class TAttr>
214  inline std::ostream & operator<<( std::ostream & str, const ArrayAttr<TResult,TAttr> & obj )
215  { return dumpOn( str, obj._q ); }
216 
218  } // namespace sat
221 } // namespace zypp
223 #endif // ZYPP_SAT_LOOKUPATTRTOOLS_H
zypp::sat::LookupAttr::iterator::asType
Tp asType() const
Templated return type.
Definition: LookupAttr.h:528
zypp::sat::LookupAttr::TransformIterator::inSolvable
Solvable inSolvable() const
The current Solvabele.
Definition: LookupAttrTools.h:108
zypp::sat::LookupAttr::TransformIterator::dereference
TResult dereference() const
Definition: LookupAttrTools.h:119
zypp::sat::ArrayAttr::size_type
LookupAttr::size_type size_type
Definition: LookupAttrTools.h:176
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition: Solvable.h:53
zypp::sat::LookupAttr::empty
bool empty() const
Whether the query is empty.
Definition: LookupAttr.cc:242
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr(SolvAttr attr_r, Repository repo_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
Definition: LookupAttrTools.h:166
zypp::sat::LookupAttr::TransformIterator::nextSkipRepo
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
Definition: LookupAttrTools.h:85
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr(SolvAttr attr_r, Solvable solv_r)
Definition: LookupAttrTools.h:170
zypp::sat::LookupAttr::TransformIterator::TransformIterator
TransformIterator()
Definition: LookupAttrTools.h:65
zypp::sat::LookupAttr::begin
iterator begin() const
Iterator to the begin of query results.
Definition: LookupAttr.cc:236
zypp::sat::LookupAttr::TransformIterator::skipSolvable
void skipSolvable()
Immediately advance to the next Solvable.
Definition: LookupAttrTools.h:93
zypp::sat::ArrayAttr::empty
bool empty() const
Definition: LookupAttrTools.h:184
zypp::sat::ArrayAttr::size
size_type size() const
Definition: LookupAttrTools.h:187
zypp::sat::LookupAttr::TransformIterator::iterator_core_access
friend class boost::iterator_core_access
Definition: LookupAttrTools.h:117
zypp::sat::LookupAttr::Location
Location
Specify the where to look for the attribule.
Definition: LookupAttr.h:116
zypp::sat::LookupAttr::SOLV_ATTR
Search for solvable attributes (default)
Definition: LookupAttr.h:117
zypp::sat::LookupAttr::TransformIterator::nextSkipSolvable
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
Definition: LookupAttrTools.h:81
zypp::sat::ArrayAttr::end
iterator end() const
Definition: LookupAttrTools.h:181
zypp::sat::dumpOn
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
Definition: LocaleSupport.cc:39
zypp::sat::SolvAttr
Solvable attribute keys.
Definition: SolvAttr.h:40
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr()
Definition: LookupAttrTools.h:159
zypp::sat::ArrayAttr::begin
iterator begin() const
Definition: LookupAttrTools.h:178
zypp::sat::ArrayAttr::find
iterator find(const TResult &key_r) const
Definition: LookupAttrTools.h:197
zypp::sat::LookupAttr::TransformIterator::nextSkipSolvAttr
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
Definition: LookupAttrTools.h:77
zypp::sat::operator<<
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
Definition: FileConflicts.cc:109
zypp::sat::LookupAttr::TransformIterator::TransformIterator
TransformIterator(const LookupAttr::iterator &val_r)
Definition: LookupAttrTools.h:69
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::sat::LookupAttr::TransformIterator::inRepo
Repository inRepo() const
The current Repository.
Definition: LookupAttrTools.h:104
LookupAttr.h
zypp::sat::ArrayAttr
LookupAttr::TransformIterator based container to retrieve list attributes.
Definition: LookupAttr.h:592
zypp::sat::ArrayAttr::_q
LookupAttr _q
Definition: LookupAttrTools.h:208
zypp::sat::LookupAttr::iterator::operator<<
std::ostream & operator<<(std::ostream &str, const ArrayAttr< TResult, TAttr > &obj)
Definition: LookupAttrTools.h:214
zypp::sat::LookupAttr::iterator
Result iterator.
Definition: LookupAttr.h:350
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
zypp::sat::LookupAttr::TransformIterator::skipSolvAttr
void skipSolvAttr()
Immediately advance to the next SolvAttr.
Definition: LookupAttrTools.h:89
zypp::sat::LookupAttr::end
iterator end() const
Iterator behind the end of query results.
Definition: LookupAttr.cc:239
Repository.h
zypp::sat::LookupAttr::TransformIterator::skipRepo
void skipRepo()
Immediately advance to the next Repository.
Definition: LookupAttrTools.h:97
str
String related utilities and Regular expression matching.
zypp::sat::ArrayAttr::ArrayAttr
ArrayAttr(SolvAttr attr_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
Definition: LookupAttrTools.h:162
zypp::sat::LookupAttr::TransformIterator
TransformIterator returning an iterator vaue of type TResult.
Definition: LookupAttr.h:162
zypp::Repository
Definition: Repository.h:39
zypp::sat::ArrayAttr::iterator
LookupAttr::TransformIterator< TResult, TAttr > iterator
Definition: LookupAttrTools.h:175
zypp::sat::LookupAttr
Lightweight attribute value lookup.
Definition: LookupAttr.h:107
zypp::sat::LookupAttr::size_type
unsigned size_type
Definition: LookupAttr.h:113
zypp::sat::LookupAttr::TransformIterator::inSolvAttr
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition: LookupAttrTools.h:112