libzypp  17.36.7
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 
21 namespace zypp
22 {
23  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:
68  {}
69 
70  explicit
72  { this->base_reference() = val_r; }
73 
74  public:
75 
80  { this->base_reference().nextSkipSolvAttr(); }
81 
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(); }
102 
107  { return this->base_reference().inRepo(); }
108 
111  { return this->base_reference().inSolvable(); }
112 
115  { return this->base_reference().inSolvAttr(); }
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  };
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:
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 
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:
211  };
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
A Solvable object within the sat Pool.
Definition: Solvable.h:53
void skipRepo()
Immediately advance to the next Repository.
Lightweight attribute value lookup.
Definition: LookupAttr.h:109
void skipSolvable()
Immediately advance to the next Solvable.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
String related utilities and Regular expression matching.
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
Definition: Arch.h:363
Search for solvable attributes (default)
Definition: LookupAttr.h:119
LookupAttr::TransformIterator based container to retrieve list attributes.
Definition: LookupAttr.h:599
TransformIterator returning an iterator vaue of type TResult.
Definition: LookupAttr.h:169
ArrayAttr(SolvAttr attr_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
unsigned int size_type
Definition: LookupAttr.h:115
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
ArrayAttr(SolvAttr attr_r, Solvable solv_r)
iterator end() const
Iterator behind the end of query results.
Definition: LookupAttr.cc:240
Solvable attribute keys.
Definition: SolvAttr.h:40
Tp asType() const
Templated return type.
Definition: LookupAttr.h:535
iterator find(const TResult &key_r) const
TransformIterator(const LookupAttr::iterator &val_r)
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
iterator end() const
Repository inRepo() const
The current Repository.
ArrayAttr(SolvAttr attr_r, Repository repo_r, LookupAttr::Location loc_r=LookupAttr::SOLV_ATTR)
SolvAttr inSolvAttr() const
The current SolvAttr.
Solvable inSolvable() const
The current Solvabele.
LookupAttr::size_type size_type
LookupAttr::TransformIterator< TResult, TAttr > iterator
iterator begin() const
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
size_type size() const
Location
Specify the where to look for the attribule.
Definition: LookupAttr.h:118
bool empty() const
Whether the query is empty.
Definition: LookupAttr.cc:243
void skipSolvAttr()
Immediately advance to the next SolvAttr.
iterator begin() const
Iterator to the begin of query results.
Definition: LookupAttr.cc:237