apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cacheset.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /** \file cacheset.h
4  Wrappers around std::set to have set::iterators which behave
5  similar to the Iterators of the cache structures.
6 
7  Provides also a few helper methods which work with these sets */
8  /*}}}*/
9 #ifndef APT_CACHESET_H
10 #define APT_CACHESET_H
11 // Include Files /*{{{*/
12 #include <fstream>
13 #include <map>
14 #include <set>
15 #if __cplusplus >= 201103L
16 #include <forward_list>
17 #include <initializer_list>
18 #include <unordered_set>
19 #endif
20 #include <algorithm>
21 #include <deque>
22 #include <iterator>
23 #include <list>
24 #include <string>
25 #include <vector>
26 
27 #include <stddef.h>
28 
29 #include <apt-pkg/error.h>
30 #include <apt-pkg/macros.h>
31 #include <apt-pkg/pkgcache.h>
32 
33  /*}}}*/
34 
35 class pkgCacheFile;
36 
37 namespace APT {
39 class VersionContainerInterface;
40 
41 class APT_PUBLIC CacheSetHelper { /*{{{*/
42 /** \class APT::CacheSetHelper
43  Simple base class with a lot of virtual methods which can be overridden
44  to alter the behavior or the output of the CacheSets.
45 
46  This helper is passed around by the static methods in the CacheSets and
47  used every time they hit an error condition or something could be
48  printed out.
49 */
50 public: /*{{{*/
51  CacheSetHelper(bool const ShowError = true,
53  virtual ~~CacheSetHelper();
54 
55  enum PkgSelector { UNKNOWN, REGEX, TASK, FNMATCH, PACKAGENAME, STRING, PATTERN };
56 
57  virtual bool PackageFrom(enum PkgSelector const select, PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &pattern);
58 
59  virtual bool PackageFromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline);
60 
61  struct PkgModifier {
62  enum Position { NONE, PREFIX, POSTFIX };
63  unsigned short ID;
64  const char * const Alias;
66  PkgModifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {}
67  };
68  virtual bool PackageFromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
69  pkgCacheFile &Cache, const char * cmdline,
70  std::list<PkgModifier> const &mods);
71 
72 
73  /** \brief be notified about the package being selected via pattern
74  *
75  * Main use is probably to show a message to the user what happened
76  *
77  * \param pkg is the package which was selected
78  * \param select is the selection method which choose the package
79  * \param pattern is the string used by the selection method to pick the package
80  */
81  virtual void showPackageSelection(pkgCache::PkgIterator const &pkg, PkgSelector const select, std::string const &pattern);
82 
83  /** \brief be notified if a package can't be found via pattern
84  *
85  * Can be used to show a message as well as to try something else to make it match
86  *
87  * \param select is the method tried for selection
88  * \param pci is the container the package should be inserted in
89  * \param Cache is the package universe available
90  * \param pattern is the string not matching anything
91  */
92  virtual void canNotFindPackage(enum PkgSelector const select, PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &pattern);
93 
94  /** \brief specifies which version(s) we want to refer to */
95  enum VerSelector {
96  /** by release string */
98  /** by version number string */
100  /** All versions */
102  /** Candidate and installed version */
104  /** Candidate version */
106  /** Installed version */
108  /** Candidate or if non installed version */
110  /** Installed or if non candidate version */
112  /** Newest version */
113  NEWEST
114  };
115 
116  /** \brief be notified about the version being selected via pattern
117  *
118  * Main use is probably to show a message to the user what happened
119  * Note that at the moment this method is only called for RELEASE
120  * and VERSION selections, not for the others.
121  *
122  * \param Pkg is the package which was selected for
123  * \param Ver is the version selected
124  * \param select is the selection method which choose the version
125  * \param pattern is the string used by the selection method to pick the version
126  */
127  virtual void showVersionSelection(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver,
128  enum VerSelector const select, std::string const &pattern);
129 
130  /** \brief be notified if a version can't be found for a package
131  *
132  * Main use is probably to show a message to the user what happened
133  *
134  * \param select is the method tried for selection
135  * \param vci is the container the version should be inserted in
136  * \param Cache is the package universe available
137  * \param Pkg is the package we wanted a version from
138  */
139  virtual void canNotFindVersion(enum VerSelector const select, VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
140 
141  // the difference between canNotFind and canNotGet is that the later is more low-level
142  // and called from other places: In this case looking into the code is the only real answer…
143  virtual pkgCache::VerIterator canNotGetVersion(enum VerSelector const select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
144 
145  virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str);
146 
147  bool showErrors() const { return ShowError; }
148  bool showErrors(bool const newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); }
149  GlobalError::MsgType errorType() const { return ErrorType; }
151  {
152  if (ErrorType == newValue) return ErrorType;
153  else {
154  GlobalError::MsgType const &oldValue = ErrorType;
155  ErrorType = newValue;
156  return oldValue;
157  }
158  }
159 
160  /*}}}*/
161 protected:
162  bool ShowError;
164 
165  pkgCache::VerIterator canNotGetInstCandVer(pkgCacheFile &Cache,
166  pkgCache::PkgIterator const &Pkg);
167  pkgCache::VerIterator canNotGetCandInstVer(pkgCacheFile &Cache,
168  pkgCache::PkgIterator const &Pkg);
169 
170  bool PackageFromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
171  bool PackageFromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
172  bool PackageFromFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
173  bool PackageFromPackageName(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
174  bool PackageFromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &pattern);
175  bool PackageFromPattern(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &pattern);
176 private:
177  void showTaskSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
178  void showRegExSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
179  void showFnmatchSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
180  void showPatternSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
181  void canNotFindTask(PackageContainerInterface *const pci, pkgCacheFile &Cache, std::string pattern);
182  void canNotFindRegEx(PackageContainerInterface *const pci, pkgCacheFile &Cache, std::string pattern);
183  void canNotFindFnmatch(PackageContainerInterface *const pci, pkgCacheFile &Cache, std::string pattern);
184  void canNotFindPackage(PackageContainerInterface *const pci, pkgCacheFile &Cache, std::string const &str);
185  void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
186  std::string const &ver, bool const verIsRel);
187  void canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
188  void canNotFindInstCandVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
189  void canNotFindCandInstVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
190  pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
191  pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
192  pkgCache::VerIterator canNotFindInstalledVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
193 
194  void * const d;
195 }; /*}}}*/
196 // Iterator templates for our Containers /*{{{*/
197 template<typename Interface, typename Master, typename iterator_type, typename container_iterator, typename container_value> class Container_iterator_base :
198  public std::iterator<typename std::iterator_traits<container_iterator>::iterator_category, container_value>,
199  public Interface::template iterator_base<iterator_type>
200 {
201 protected:
202  container_iterator _iter;
203 public:
204  explicit Container_iterator_base(container_iterator const &i) : _iter(i) {}
205  inline container_value operator*(void) const { return static_cast<iterator_type const*>(this)->getType(); };
206  operator container_iterator(void) const { return _iter; }
207  inline iterator_type& operator++() { ++_iter; return static_cast<iterator_type&>(*this); }
208  inline iterator_type operator++(int) { iterator_type tmp(*this); operator++(); return tmp; }
209  inline iterator_type operator+(typename container_iterator::difference_type const &n) { return iterator_type(_iter + n); }
210  inline iterator_type operator+=(typename container_iterator::difference_type const &n) { _iter += n; return static_cast<iterator_type&>(*this); }
211  inline iterator_type& operator--() { --_iter;; return static_cast<iterator_type&>(*this); }
212  inline iterator_type operator--(int) { iterator_type tmp(*this); operator--(); return tmp; }
213  inline iterator_type operator-(typename container_iterator::difference_type const &n) { return iterator_type(_iter - n); }
214  inline typename container_iterator::difference_type operator-(iterator_type const &b) { return (_iter - b._iter); }
215  inline iterator_type operator-=(typename container_iterator::difference_type const &n) { _iter -= n; return static_cast<iterator_type&>(*this); }
216  inline bool operator!=(iterator_type const &i) const { return _iter != i._iter; }
217  inline bool operator==(iterator_type const &i) const { return _iter == i._iter; }
218  inline bool operator<(iterator_type const &i) const { return _iter < i._iter; }
219  inline bool operator>(iterator_type const &i) const { return _iter > i._iter; }
220  inline bool operator<=(iterator_type const &i) const { return _iter <= i._iter; }
221  inline bool operator>=(iterator_type const &i) const { return _iter >= i._iter; }
222  inline typename container_iterator::reference operator[](typename container_iterator::difference_type const &n) const { return _iter[n]; }
223 
224  friend std::ostream& operator<<(std::ostream& out, iterator_type i) { return operator<<(out, *i); }
225  friend Master;
226 };
227 template<class Interface, class Container, class Master> class Container_const_iterator :
228  public Container_iterator_base<Interface, Master, Container_const_iterator<Interface, Container, Master>, typename Container::const_iterator, typename Container::value_type>
229 {
231  typedef typename Container::const_iterator container_iterator;
232 public:
234  Container_iterator_base<Interface, Master, iterator_type, container_iterator, typename Container::value_type>(i) {}
235 
236  inline typename Container::value_type getType(void) const { return *this->_iter; }
237 };
238 template<class Interface, class Container, class Master> class Container_iterator :
239  public Container_iterator_base<Interface, Master, Container_iterator<Interface, Container, Master>, typename Container::iterator, typename Container::value_type>
240 {
242  typedef typename Container::iterator container_iterator;
243 public:
245  Container_iterator_base<Interface, Master, iterator_type, container_iterator, typename Container::value_type>(i) {}
246 
247  operator typename Master::const_iterator() { return typename Master::const_iterator(this->_iter); }
248  inline typename Container::iterator::reference operator*(void) const { return *this->_iter; }
249 
250  inline typename Container::value_type getType(void) const { return *this->_iter; }
251 };
252 template<class Interface, class Container, class Master> class Container_const_reverse_iterator :
253  public Container_iterator_base<Interface, Master, Container_const_reverse_iterator<Interface, Container, Master>, typename Container::const_reverse_iterator, typename Container::value_type>
254 {
256  typedef typename Container::const_reverse_iterator container_iterator;
257 public:
259  Container_iterator_base<Interface, Master, iterator_type, container_iterator, typename Container::value_type>(i) {}
260 
261  inline typename Container::value_type getType(void) const { return *this->_iter; }
262 };
263 template<class Interface, class Container, class Master> class Container_reverse_iterator :
264  public Container_iterator_base<Interface, Master, Container_reverse_iterator<Interface, Container, Master>, typename Container::reverse_iterator, typename Container::value_type>
265 {
267  typedef typename Container::reverse_iterator container_iterator;
268 public:
270  Container_iterator_base<Interface, Master, iterator_type, container_iterator, typename Container::value_type>(i) {}
271 
272  operator typename Master::const_iterator() { return typename Master::const_iterator(this->_iter); }
273  inline iterator_type& operator=(iterator_type const &i) { this->_iter = i._iter; return static_cast<iterator_type&>(*this); }
274  inline iterator_type& operator=(container_iterator const &i) { this->_iter = i; return static_cast<iterator_type&>(*this); }
275  inline typename Container::reverse_iterator::reference operator*(void) const { return *this->_iter; }
276 
277  inline typename Container::value_type getType(void) const { return *this->_iter; }
278 };
279  /*}}}*/
281 /** \class PackageContainerInterface
282 
283  * Interface ensuring that all operations can be executed on the yet to
284  * define concrete PackageContainer - access to all methods is possible,
285  * but in general the wrappers provided by the PackageContainer template
286  * are nicer to use.
287 
288  * This class mostly protects use from the need to write all implementation
289  * of the methods working on containers in the template */
290 public:
291  template<class Itr> class iterator_base { /*{{{*/
292  pkgCache::PkgIterator getType() const { return static_cast<Itr const*>(this)->getType(); };
293  public:
294  operator pkgCache::PkgIterator(void) const { return getType(); }
295 
296  inline const char *Name() const {return getType().Name(); }
297  inline std::string FullName(bool const Pretty) const { return getType().FullName(Pretty); }
298  inline std::string FullName() const { return getType().FullName(); }
299  inline bool Purge() const {return getType().Purge(); }
300  inline const char *Arch() const {return getType().Arch(); }
301  inline pkgCache::GrpIterator Group() const { return getType().Group(); }
302  inline pkgCache::VerIterator VersionList() const { return getType().VersionList(); }
303  inline pkgCache::VerIterator CurrentVer() const { return getType().CurrentVer(); }
304  inline pkgCache::DepIterator RevDependsList() const { return getType().RevDependsList(); }
305  inline pkgCache::PrvIterator ProvidesList() const { return getType().ProvidesList(); }
306  inline pkgCache::PkgIterator::OkState State() const { return getType().State(); }
307  inline const char *CurVersion() const { return getType().CurVersion(); }
308  inline pkgCache *Cache() const { return getType().Cache(); }
309  inline unsigned long Index() const {return getType().Index();}
310  // we have only valid iterators here
311  inline bool end() const { return false; }
312 
313  inline pkgCache::Package const * operator->() const {return &*getType();}
314  };
315  /*}}}*/
316 
317  virtual bool insert(pkgCache::PkgIterator const &P) = 0;
318  virtual bool empty() const = 0;
319  virtual void clear() = 0;
320  virtual size_t size() const = 0;
321 
322  void setConstructor(CacheSetHelper::PkgSelector const by) { ConstructedBy = by; }
323  CacheSetHelper::PkgSelector getConstructor() const { return ConstructedBy; }
327  PackageContainerInterface& operator=(PackageContainerInterface const &other);
328  virtual ~~PackageContainerInterface();
329 
330 private:
332  void * const d;
333 };
334  /*}}}*/
335 template<class Container> class APT_PUBLIC PackageContainer : public PackageContainerInterface {/*{{{*/
336 /** \class APT::PackageContainer
337 
338  Simple wrapper around a container class like std::set to provide a similar
339  interface to a set of packages as to the complete set of all packages in the
340  pkgCache. */
341  Container _cont;
342 public: /*{{{*/
343  /** \brief smell like a pkgCache::PkgIterator */
348  typedef typename Container::value_type value_type;
349  typedef typename Container::pointer pointer;
350  typedef typename Container::const_pointer const_pointer;
351  typedef typename Container::reference reference;
352  typedef typename Container::const_reference const_reference;
353  typedef typename Container::difference_type difference_type;
354  typedef typename Container::size_type size_type;
355  typedef typename Container::allocator_type allocator_type;
356 
357  bool insert(pkgCache::PkgIterator const &P) APT_OVERRIDE { if (P.end() == true) return false; _cont.insert(P); return true; }
358  template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); }
359  void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }
360 
361  bool empty() const APT_OVERRIDE { return _cont.empty(); }
362  void clear() APT_OVERRIDE { return _cont.clear(); }
363  size_t size() const APT_OVERRIDE { return _cont.size(); }
364 #if __GNUC__ >= 5 || (__GNUC_MINOR__ >= 9 && __GNUC__ >= 4)
365  iterator erase( const_iterator pos ) { return iterator(_cont.erase(pos._iter)); }
366  iterator erase( const_iterator first, const_iterator last ) { return iterator(_cont.erase(first._iter, last._iter)); }
367 #else
368  iterator erase( iterator pos ) { return iterator(_cont.erase(pos._iter)); }
369  iterator erase( iterator first, iterator last ) { return iterator(_cont.erase(first._iter, last._iter)); }
370 #endif
371  const_iterator begin() const { return const_iterator(_cont.begin()); }
372  const_iterator end() const { return const_iterator(_cont.end()); }
373  const_reverse_iterator rbegin() const { return const_reverse_iterator(_cont.rbegin()); }
374  const_reverse_iterator rend() const { return const_reverse_iterator(_cont.rend()); }
375 #if __cplusplus >= 201103L
376  const_iterator cbegin() const { return const_iterator(_cont.cbegin()); }
377  const_iterator cend() const { return const_iterator(_cont.cend()); }
378  const_reverse_iterator crbegin() const { return const_reverse_iterator(_cont.crbegin()); }
379  const_reverse_iterator crend() const { return const_reverse_iterator(_cont.crend()); }
380 #endif
381  iterator begin() { return iterator(_cont.begin()); }
382  iterator end() { return iterator(_cont.end()); }
383  reverse_iterator rbegin() { return reverse_iterator(_cont.rbegin()); }
384  reverse_iterator rend() { return reverse_iterator(_cont.rend()); }
385  const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); }
386 
389  template<typename Itr> PackageContainer(Itr first, Itr last) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(first, last) {}
390 #if __cplusplus >= 201103L
391  PackageContainer(std::initializer_list<value_type> list) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(list) {}
392  void push_back(value_type&& P) { _cont.emplace_back(std::move(P)); }
393  template<typename... Args> void emplace_back(Args&&... args) { _cont.emplace_back(std::forward<Args>(args)...); }
394 #endif
395  void push_back(const value_type& P) { _cont.push_back(P); }
396 
397  /** \brief sort all included versions with given comparer
398 
399  Some containers are sorted by default, some are not and can't be,
400  but a few like std::vector can be sorted if need be, so this can be
401  specialized in later on. The default is that this will fail though.
402  Specifically, already sorted containers like std::set will return
403  false as well as there is no easy way to check that the given comparer
404  would sort in the same way the set is currently sorted
405 
406  \return \b true if the set was sorted, \b false if not. */
407  template<class Compare> bool sort(Compare /*Comp*/) { return false; }
408 
409  /** \brief returns all packages in the cache who belong to the given task
410 
411  A simple helper responsible for search for all members of a task
412  in the cache. Optional it prints a notice about the
413  packages chosen cause of the given task.
414  \param Cache the packages are in
415  \param pattern name of the task
416  \param helper responsible for error and message handling */
417  static PackageContainer FromTask(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) {
419  helper.PackageFrom(CacheSetHelper::TASK, &cont, Cache, pattern);
420  return cont;
421  }
422  static PackageContainer FromTask(pkgCacheFile &Cache, std::string const &pattern) {
423  CacheSetHelper helper;
424  return FromTask(Cache, pattern, helper);
425  }
426 
427  /** \brief returns all packages in the cache whose name matches a given pattern
428 
429  A simple helper responsible for executing a regular expression on all
430  package names in the cache. Optional it prints a notice about the
431  packages chosen cause of the given package.
432  \param Cache the packages are in
433  \param pattern regular expression for package names
434  \param helper responsible for error and message handling */
435  static PackageContainer FromRegEx(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) {
437  helper.PackageFrom(CacheSetHelper::REGEX, &cont, Cache, pattern);
438  return cont;
439  }
440 
441  static PackageContainer FromRegEx(pkgCacheFile &Cache, std::string const &pattern) {
442  CacheSetHelper helper;
443  return FromRegEx(Cache, pattern, helper);
444  }
445 
446  static PackageContainer FromFnmatch(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) {
448  helper.PackageFrom(CacheSetHelper::FNMATCH, &cont, Cache, pattern);
449  return cont;
450  }
451  static PackageContainer FromFnMatch(pkgCacheFile &Cache, std::string const &pattern) {
452  CacheSetHelper helper;
453  return FromFnmatch(Cache, pattern, helper);
454  }
455 
456  /** \brief returns all packages specified by a string
457 
458  \param Cache the packages are in
459  \param pattern String the package name(s) should be extracted from
460  \param helper responsible for error and message handling */
461  static PackageContainer FromString(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) {
462  PackageContainer cont;
463  helper.PackageFrom(CacheSetHelper::PACKAGENAME, &cont, Cache, pattern);
464  return cont;
465  }
466  static PackageContainer FromString(pkgCacheFile &Cache, std::string const &pattern) {
467  CacheSetHelper helper;
468  return FromString(Cache, pattern, helper);
469  }
470 
471  /** \brief returns all packages specified on the commandline
472 
473  Get all package names from the commandline and executes regex's if needed.
474  No special package command is supported, just plain names.
475  \param Cache the packages are in
476  \param cmdline Command line the package names should be extracted from
477  \param helper responsible for error and message handling */
478  static PackageContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper) {
479  PackageContainer cont;
480  helper.PackageFromCommandLine(&cont, Cache, cmdline);
481  return cont;
482  }
483  static PackageContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline) {
484  CacheSetHelper helper;
485  return FromCommandLine(Cache, cmdline, helper);
486  }
487 
488  /** \brief group packages by a action modifiers
489 
490  At some point it is needed to get from the same commandline
491  different package sets grouped by a modifier. Take
492  apt-get install apt awesome-
493  as an example.
494  \param Cache the packages are in
495  \param cmdline Command line the package names should be extracted from
496  \param mods list of modifiers the method should accept
497  \param fallback the default modifier group for a package
498  \param helper responsible for error and message handling */
499  static std::map<unsigned short, PackageContainer> GroupedFromCommandLine(
500  pkgCacheFile &Cache,
501  const char **cmdline,
502  std::list<CacheSetHelper::PkgModifier> const &mods,
503  unsigned short const &fallback,
504  CacheSetHelper &helper) {
505  std::map<unsigned short, PackageContainer> pkgsets;
506  for (const char **I = cmdline; *I != 0; ++I) {
507  unsigned short modID = fallback;
508  PackageContainer pkgset;
509  helper.PackageFromModifierCommandLine(modID, &pkgset, Cache, *I, mods);
510  pkgsets[modID].insert(pkgset);
511  }
512  return pkgsets;
513  }
514  static std::map<unsigned short, PackageContainer> GroupedFromCommandLine(
515  pkgCacheFile &Cache,
516  const char **cmdline,
517  std::list<CacheSetHelper::PkgModifier> const &mods,
518  unsigned short const &fallback) {
519  CacheSetHelper helper;
520  return GroupedFromCommandLine(Cache, cmdline,
521  mods, fallback, helper);
522  }
523  /*}}}*/
524 }; /*}}}*/
525 // various specialisations for PackageContainer /*{{{*/
526 template<> template<class Cont> void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
527  for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
528  _cont.push_back(*p);
529 }
530 #if __cplusplus >= 201103L
531 template<> template<class Cont> void PackageContainer<std::forward_list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
532  for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
533  _cont.push_front(*p);
534 }
535 #endif
536 template<> template<class Cont> void PackageContainer<std::deque<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
537  for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
538  _cont.push_back(*p);
539 }
540 template<> template<class Cont> void PackageContainer<std::vector<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
541  for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
542  _cont.push_back(*p);
543 }
544 // these are 'inline' as otherwise the linker has problems with seeing these untemplated
545 // specializations again and again - but we need to see them, so that library users can use them
547  if (P.end() == true)
548  return false;
549  _cont.push_back(P);
550  return true;
551 }
552 #if __cplusplus >= 201103L
553 template<> inline bool PackageContainer<std::forward_list<pkgCache::PkgIterator> >::insert(pkgCache::PkgIterator const &P) {
554  if (P.end() == true)
555  return false;
556  _cont.push_front(P);
557  return true;
558 }
559 #endif
561  if (P.end() == true)
562  return false;
563  _cont.push_back(P);
564  return true;
565 }
567  if (P.end() == true)
568  return false;
569  _cont.push_back(P);
570  return true;
571 }
573  for (const_iterator p = begin; p != end; ++p)
574  _cont.push_back(*p);
575 }
576 #if __cplusplus >= 201103L
577 template<> inline void PackageContainer<std::forward_list<pkgCache::PkgIterator> >::insert(const_iterator begin, const_iterator end) {
578  for (const_iterator p = begin; p != end; ++p)
579  _cont.push_front(*p);
580 }
581 #endif
583  for (const_iterator p = begin; p != end; ++p)
584  _cont.push_back(*p);
585 }
587  for (const_iterator p = begin; p != end; ++p)
588  _cont.push_back(*p);
589 }
590 #if APT_GCC_VERSION < 0x409
592  _cont.erase(i._iter);
593  return end();
594 }
596  _cont.erase(first, last);
597  return end();
598 }
599 #endif
600 template<> template<class Compare> inline bool PackageContainer<std::vector<pkgCache::PkgIterator> >::sort(Compare Comp) {
601  std::sort(_cont.begin(), _cont.end(), Comp);
602  return true;
603 }
604 template<> template<class Compare> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::sort(Compare Comp) {
605  _cont.sort(Comp);
606  return true;
607 }
608 #if __cplusplus >= 201103L
609 template<> template<class Compare> inline bool PackageContainer<std::forward_list<pkgCache::PkgIterator> >::sort(Compare Comp) {
610  _cont.sort(Comp);
611  return true;
612 }
613 #endif
614 template<> template<class Compare> inline bool PackageContainer<std::deque<pkgCache::PkgIterator> >::sort(Compare Comp) {
615  std::sort(_cont.begin(), _cont.end(), Comp);
616  return true;
617 }
618  /*}}}*/
619 
620 // class PackageUniverse - pkgCache as PackageContainerInterface /*{{{*/
621 /** \class PackageUniverse
622 
623  Wraps around our usual pkgCache, so that it can be stuffed into methods
624  expecting a PackageContainer.
625 
626  The wrapping is read-only in practice modeled by making erase and co
627  private methods. */
629  pkgCache * const _cont;
630  void * const d;
631 public:
632  class const_iterator : public APT::Container_iterator_base<APT::PackageContainerInterface, PackageUniverse, PackageUniverse::const_iterator, pkgCache::PkgIterator, pkgCache::PkgIterator>
633  {
634  public:
637 
638  inline pkgCache::PkgIterator getType(void) const { return _iter; }
639  };
642  typedef typename pkgCache::PkgIterator* pointer;
643  typedef typename pkgCache::PkgIterator const* const_pointer;
646  typedef const_iterator::difference_type difference_type;
647  typedef std::make_unsigned<const_iterator::difference_type>::type size_type;
648 
649 
650  bool empty() const APT_OVERRIDE { return false; }
651  size_t size() const APT_OVERRIDE { return _cont->Head().PackageCount; }
652 
653  const_iterator begin() const { return const_iterator(_cont->PkgBegin()); }
654  const_iterator end() const { return const_iterator(_cont->PkgEnd()); }
655  const_iterator cbegin() const { return const_iterator(_cont->PkgBegin()); }
656  const_iterator cend() const { return const_iterator(_cont->PkgEnd()); }
657  iterator begin() { return iterator(_cont->PkgBegin()); }
658  iterator end() { return iterator(_cont->PkgEnd()); }
659 
660  pkgCache * data() const { return _cont; }
661 
662  explicit PackageUniverse(pkgCache * const Owner);
663  explicit PackageUniverse(pkgCacheFile * const Owner);
664  virtual ~~PackageUniverse();
665 
666 private:
667  APT_HIDDEN bool insert(pkgCache::PkgIterator const &) APT_OVERRIDE { return true; }
668  template<class Cont> APT_HIDDEN void insert(PackageContainer<Cont> const &) { }
670 
674 };
675  /*}}}*/
677 #if __cplusplus >= 201103L
680 #endif
684 
686 /** \class APT::VersionContainerInterface
687 
688  Same as APT::PackageContainerInterface, just for Versions */
689 public:
690  /** \brief smell like a pkgCache::VerIterator */
691  template<class Itr> class iterator_base { /*{{{*/
692  pkgCache::VerIterator getType() const { return static_cast<Itr const*>(this)->getType(); };
693  public:
694  operator pkgCache::VerIterator(void) { return getType(); }
695 
696  inline pkgCache *Cache() const { return getType().Cache(); }
697  inline unsigned long Index() const {return getType().Index();}
698  inline int CompareVer(const pkgCache::VerIterator &B) const { return getType().CompareVer(B); }
699  inline const char *VerStr() const { return getType().VerStr(); }
700  inline const char *Section() const { return getType().Section(); }
701  inline const char *Arch() const { return getType().Arch(); }
702  inline pkgCache::PkgIterator ParentPkg() const { return getType().ParentPkg(); }
703  inline pkgCache::DescIterator DescriptionList() const { return getType().DescriptionList(); }
704  inline pkgCache::DescIterator TranslatedDescription() const { return getType().TranslatedDescription(); }
705  inline pkgCache::DepIterator DependsList() const { return getType().DependsList(); }
706  inline pkgCache::PrvIterator ProvidesList() const { return getType().ProvidesList(); }
707  inline pkgCache::VerFileIterator FileList() const { return getType().FileList(); }
708  inline bool Downloadable() const { return getType().Downloadable(); }
709  inline const char *PriorityType() const { return getType().PriorityType(); }
710  inline std::string RelStr() const { return getType().RelStr(); }
711  inline bool Automatic() const { return getType().Automatic(); }
712  inline pkgCache::VerFileIterator NewestFile() const { return getType().NewestFile(); }
713  // we have only valid iterators here
714  inline bool end() const { return false; }
715 
716  inline pkgCache::Version const * operator->() const { return &*getType(); }
717  };
718  /*}}}*/
719 
720  virtual bool insert(pkgCache::VerIterator const &V) = 0;
721  virtual bool empty() const = 0;
722  virtual void clear() = 0;
723  virtual size_t size() const = 0;
724 
725  struct Modifier {
726  unsigned short const ID;
727  const char * const Alias;
728  enum Position { NONE, PREFIX, POSTFIX } const Pos;
729  enum CacheSetHelper::VerSelector const SelectVersion;
730  Modifier (unsigned short const &id, const char * const alias, Position const &pos,
731  enum CacheSetHelper::VerSelector const select) : ID(id), Alias(alias), Pos(pos),
732  SelectVersion(select) {}
733  };
734 
735  static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache,
736  const char **cmdline, CacheSetHelper::VerSelector const fallback,
737  CacheSetHelper &helper);
738 
739  static bool FromString(VersionContainerInterface * const vci, pkgCacheFile &Cache,
740  std::string pkg, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper,
741  bool const onlyFromName = false);
742 
743  static bool FromPattern(VersionContainerInterface *const vci, pkgCacheFile &Cache,
744  std::string pkg, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper);
745 
746  static bool FromPackage(VersionContainerInterface * const vci, pkgCacheFile &Cache,
747  pkgCache::PkgIterator const &P, CacheSetHelper::VerSelector const fallback,
748  CacheSetHelper &helper);
749 
750  static bool FromModifierCommandLine(unsigned short &modID,
751  VersionContainerInterface * const vci,
752  pkgCacheFile &Cache, const char * cmdline,
753  std::list<Modifier> const &mods,
754  CacheSetHelper &helper);
755 
756 
757  static bool FromDependency(VersionContainerInterface * const vci,
758  pkgCacheFile &Cache,
759  pkgCache::DepIterator const &D,
760  CacheSetHelper::VerSelector const selector,
761  CacheSetHelper &helper);
762 
765  VersionContainerInterface& operator=(VersionContainerInterface const &other);
766  virtual ~~VersionContainerInterface();
767 private:
768  void * const d;
769 
770 protected: /*{{{*/
771 
772  /** \brief returns the candidate version of the package
773 
774  \param Cache to be used to query for information
775  \param Pkg we want the candidate version from this package
776  \param helper used in this container instance */
777  static pkgCache::VerIterator getCandidateVer(pkgCacheFile &Cache,
778  pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
779 
780  /** \brief returns the installed version of the package
781 
782  \param Cache to be used to query for information
783  \param Pkg we want the installed version from this package
784  \param helper used in this container instance */
785  static pkgCache::VerIterator getInstalledVer(pkgCacheFile &Cache,
786  pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
787  /*}}}*/
788 };
789  /*}}}*/
790 template<class Container> class APT_PUBLIC VersionContainer : public VersionContainerInterface {/*{{{*/
791 /** \class APT::VersionContainer
792 
793  Simple wrapper around a container class like std::set to provide a similar
794  interface to a set of versions as to the complete set of all versions in the
795  pkgCache. */
796  Container _cont;
797 public: /*{{{*/
798 
803  typedef typename Container::value_type value_type;
804  typedef typename Container::pointer pointer;
805  typedef typename Container::const_pointer const_pointer;
806  typedef typename Container::reference reference;
807  typedef typename Container::const_reference const_reference;
808  typedef typename Container::difference_type difference_type;
809  typedef typename Container::size_type size_type;
810  typedef typename Container::allocator_type allocator_type;
811 
812  bool insert(pkgCache::VerIterator const &V) APT_OVERRIDE { if (V.end() == true) return false; _cont.insert(V); return true; }
813  template<class Cont> void insert(VersionContainer<Cont> const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); }
814  void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }
815  bool empty() const APT_OVERRIDE { return _cont.empty(); }
816  void clear() APT_OVERRIDE { return _cont.clear(); }
817  size_t size() const APT_OVERRIDE { return _cont.size(); }
818 #if APT_GCC_VERSION >= 0x409
819  iterator erase( const_iterator pos ) { return iterator(_cont.erase(pos._iter)); }
820  iterator erase( const_iterator first, const_iterator last ) { return iterator(_cont.erase(first._iter, last._iter)); }
821 #else
822  iterator erase( iterator pos ) { return iterator(_cont.erase(pos._iter)); }
823  iterator erase( iterator first, iterator last ) { return iterator(_cont.erase(first._iter, last._iter)); }
824 #endif
825  const_iterator begin() const { return const_iterator(_cont.begin()); }
826  const_iterator end() const { return const_iterator(_cont.end()); }
827  const_reverse_iterator rbegin() const { return const_reverse_iterator(_cont.rbegin()); }
828  const_reverse_iterator rend() const { return const_reverse_iterator(_cont.rend()); }
829 #if __cplusplus >= 201103L
830  const_iterator cbegin() const { return const_iterator(_cont.cbegin()); }
831  const_iterator cend() const { return const_iterator(_cont.cend()); }
832  const_reverse_iterator crbegin() const { return const_reverse_iterator(_cont.crbegin()); }
833  const_reverse_iterator crend() const { return const_reverse_iterator(_cont.crend()); }
834 #endif
835  iterator begin() { return iterator(_cont.begin()); }
836  iterator end() { return iterator(_cont.end()); }
837  reverse_iterator rbegin() { return reverse_iterator(_cont.rbegin()); }
838  reverse_iterator rend() { return reverse_iterator(_cont.rend()); }
839  const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); }
840 
842  template<typename Itr> VersionContainer(Itr first, Itr last) : VersionContainerInterface(), _cont(first, last) {}
843 #if __cplusplus >= 201103L
844  VersionContainer(std::initializer_list<value_type> list) : VersionContainerInterface(), _cont(list) {}
845  void push_back(value_type&& P) { _cont.emplace_back(std::move(P)); }
846  template<typename... Args> void emplace_back(Args&&... args) { _cont.emplace_back(std::forward<Args>(args)...); }
847 #endif
848  void push_back(const value_type& P) { _cont.push_back(P); }
849 
850  /** \brief sort all included versions with given comparer
851 
852  Some containers are sorted by default, some are not and can't be,
853  but a few like std::vector can be sorted if need be, so this can be
854  specialized in later on. The default is that this will fail though.
855  Specifically, already sorted containers like std::set will return
856  false as well as there is no easy way to check that the given comparer
857  would sort in the same way the set is currently sorted
858 
859  \return \b true if the set was sorted, \b false if not. */
860  template<class Compare> bool sort(Compare /*Comp*/) { return false; }
861 
862  /** \brief returns all versions specified on the commandline
863 
864  Get all versions from the commandline, uses given default version if
865  non specifically requested and executes regex's if needed on names.
866  \param Cache the packages and versions are in
867  \param cmdline Command line the versions should be extracted from
868  \param fallback version specification
869  \param helper responsible for error and message handling */
870  static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
871  CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper) {
872  VersionContainer vercon;
873  VersionContainerInterface::FromCommandLine(&vercon, Cache, cmdline, fallback, helper);
874  return vercon;
875  }
876  static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
877  CacheSetHelper::VerSelector const fallback) {
878  CacheSetHelper helper;
879  return FromCommandLine(Cache, cmdline, fallback, helper);
880  }
881  static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline) {
882  return FromCommandLine(Cache, cmdline, CacheSetHelper::CANDINST);
883  }
884  static VersionContainer FromString(pkgCacheFile &Cache, std::string const &pkg,
885  CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper,
886  bool const /*onlyFromName = false*/) {
887  VersionContainer vercon;
888  VersionContainerInterface::FromString(&vercon, Cache, pkg, fallback, helper);
889  return vercon;
890  }
891  static VersionContainer FromString(pkgCacheFile &Cache, std::string pkg,
892  CacheSetHelper::VerSelector const fallback) {
893  CacheSetHelper helper;
894  return FromString(Cache, pkg, fallback, helper);
895  }
896  static VersionContainer FromString(pkgCacheFile &Cache, std::string pkg) {
897  return FromString(Cache, pkg, CacheSetHelper::CANDINST);
898  }
899 
900 
901  /** \brief returns all versions specified for the package
902 
903  \param Cache the package and versions are in
904  \param P the package in question
905  \param fallback the version(s) you want to get
906  \param helper the helper used for display and error handling */
908  CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper) {
909  VersionContainer vercon;
910  VersionContainerInterface::FromPackage(&vercon, Cache, P, fallback, helper);
911  return vercon;
912  }
914  CacheSetHelper::VerSelector const fallback) {
915  CacheSetHelper helper;
916  return FromPackage(Cache, P, fallback, helper);
917  }
919  return FromPackage(Cache, P, CacheSetHelper::CANDIDATE);
920  }
921 
922  static std::map<unsigned short, VersionContainer> GroupedFromCommandLine(
923  pkgCacheFile &Cache,
924  const char **cmdline,
925  std::list<Modifier> const &mods,
926  unsigned short const fallback,
927  CacheSetHelper &helper) {
928  std::map<unsigned short, VersionContainer> versets;
929  for (const char **I = cmdline; *I != 0; ++I) {
930  unsigned short modID = fallback;
931  VersionContainer verset;
932  VersionContainerInterface::FromModifierCommandLine(modID, &verset, Cache, *I, mods, helper);
933  versets[modID].insert(verset);
934  }
935  return versets;
936 
937  }
938  static std::map<unsigned short, VersionContainer> GroupedFromCommandLine(
939  pkgCacheFile &Cache, const char **cmdline,
940  std::list<Modifier> const &mods,
941  unsigned short const fallback) {
942  CacheSetHelper helper;
943  return GroupedFromCommandLine(Cache, cmdline,
944  mods, fallback, helper);
945  }
946 
948  CacheSetHelper::VerSelector const selector, CacheSetHelper &helper) {
949  VersionContainer vercon;
950  VersionContainerInterface::FromDependency(&vercon, Cache, D, selector, helper);
951  return vercon;
952  }
954  CacheSetHelper::VerSelector const selector) {
955  CacheSetHelper helper;
956  return FromDependency(Cache, D, selector, helper);
957  }
959  return FromDependency(Cache, D, CacheSetHelper::CANDIDATE);
960  }
961  /*}}}*/
962 }; /*}}}*/
963 // various specialisations for VersionContainer /*{{{*/
964 template<> template<class Cont> void VersionContainer<std::list<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
965  for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
966  _cont.push_back(*v);
967 }
968 #if __cplusplus >= 201103L
969 template<> template<class Cont> void VersionContainer<std::forward_list<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
970  for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
971  _cont.push_front(*v);
972 }
973 #endif
974 template<> template<class Cont> void VersionContainer<std::deque<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
975  for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
976  _cont.push_back(*v);
977 }
978 template<> template<class Cont> void VersionContainer<std::vector<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
979  for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
980  _cont.push_back(*v);
981 }
982 // these are 'inline' as otherwise the linker has problems with seeing these untemplated
983 // specializations again and again - but we need to see them, so that library users can use them
985  if (V.end() == true)
986  return false;
987  _cont.push_back(V);
988  return true;
989 }
990 #if __cplusplus >= 201103L
991 template<> inline bool VersionContainer<std::forward_list<pkgCache::VerIterator> >::insert(pkgCache::VerIterator const &V) {
992  if (V.end() == true)
993  return false;
994  _cont.push_front(V);
995  return true;
996 }
997 #endif
999  if (V.end() == true)
1000  return false;
1001  _cont.push_back(V);
1002  return true;
1003 }
1005  if (V.end() == true)
1006  return false;
1007  _cont.push_back(V);
1008  return true;
1009 }
1011  for (const_iterator v = begin; v != end; ++v)
1012  _cont.push_back(*v);
1013 }
1014 #if __cplusplus >= 201103L
1015 template<> inline void VersionContainer<std::forward_list<pkgCache::VerIterator> >::insert(const_iterator begin, const_iterator end) {
1016  for (const_iterator v = begin; v != end; ++v)
1017  _cont.push_front(*v);
1018 }
1019 #endif
1021  for (const_iterator v = begin; v != end; ++v)
1022  _cont.push_back(*v);
1023 }
1025  for (const_iterator v = begin; v != end; ++v)
1026  _cont.push_back(*v);
1027 }
1028 #if APT_GCC_VERSION < 0x409
1030  _cont.erase(i._iter);
1031  return end();
1032 }
1034  _cont.erase(first, last);
1035  return end();
1036 }
1037 #endif
1038 template<> template<class Compare> inline bool VersionContainer<std::vector<pkgCache::VerIterator> >::sort(Compare Comp) {
1039  std::sort(_cont.begin(), _cont.end(), Comp);
1040  return true;
1041 }
1042 template<> template<class Compare> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::sort(Compare Comp) {
1043  _cont.sort(Comp);
1044  return true;
1045 }
1046 #if __cplusplus >= 201103L
1047 template<> template<class Compare> inline bool VersionContainer<std::forward_list<pkgCache::VerIterator> >::sort(Compare Comp) {
1048  _cont.sort(Comp);
1049  return true;
1050 }
1051 #endif
1052 template<> template<class Compare> inline bool VersionContainer<std::deque<pkgCache::VerIterator> >::sort(Compare Comp) {
1053  std::sort(_cont.begin(), _cont.end(), Comp);
1054  return true;
1055 }
1056  /*}}}*/
1057 
1059 #if __cplusplus >= 201103L
1062 #endif
1066 }
1067 #endif
static bool std::string const metaIndex const *const pkgAcqMetaClearSig *const pkgAcquire::Item *const I
virtual bool PackageFromCommandLine(PackageContainerInterface *const pci, pkgCacheFile &Cache, const char **cmdline)
Definition: cacheset.cc:342
VerSelector
specifies which version(s) we want to refer to
Definition: cacheset.h:95
virtual bool PackageFrom(enum PkgSelector const select, PackageContainerInterface *const pci, pkgCacheFile &Cache, std::string const &pattern)
Definition: cacheset.cc:40
GlobalError::MsgType ErrorType
Definition: cacheset.h:163
bool showErrors() const
Definition: cacheset.h:147
virtual bool PackageFromModifierCommandLine(unsigned short &modID, PackageContainerInterface *const pci, pkgCacheFile &Cache, const char *cmdline, std::list< PkgModifier > const &mods)
Definition: cacheset.cc:350
GlobalError::MsgType errorType(GlobalError::MsgType const &newValue)
Definition: cacheset.h:150
GlobalError::MsgType errorType() const
Definition: cacheset.h:149
void *const d
Definition: cacheset.h:194
bool showErrors(bool const newValue)
Definition: cacheset.h:148
Container_const_iterator< Interface, Container, Master > iterator_type
Definition: cacheset.h:230
Container::const_iterator container_iterator
Definition: cacheset.h:231
Container_const_iterator(container_iterator i)
Definition: cacheset.h:233
Container::value_type getType(void) const
Definition: cacheset.h:236
Container_const_reverse_iterator< Interface, Container, Master > iterator_type
Definition: cacheset.h:255
Container_const_reverse_iterator(container_iterator i)
Definition: cacheset.h:258
Container::value_type getType(void) const
Definition: cacheset.h:261
Container::const_reverse_iterator container_iterator
Definition: cacheset.h:256
iterator_type operator-(typename container_iterator::difference_type const &n)
Definition: cacheset.h:213
bool operator<(iterator_type const &i) const
Definition: cacheset.h:218
iterator_type operator--(int)
Definition: cacheset.h:212
container_iterator::difference_type operator-(iterator_type const &b)
Definition: cacheset.h:214
friend std::ostream & operator<<(std::ostream &out, iterator_type i)
Definition: cacheset.h:224
container_value operator*(void) const
Definition: cacheset.h:205
bool operator<=(iterator_type const &i) const
Definition: cacheset.h:220
bool operator!=(iterator_type const &i) const
Definition: cacheset.h:216
iterator_type operator+=(typename container_iterator::difference_type const &n)
Definition: cacheset.h:210
Container_iterator_base(container_iterator const &i)
Definition: cacheset.h:204
iterator_type operator-=(typename container_iterator::difference_type const &n)
Definition: cacheset.h:215
bool operator==(iterator_type const &i) const
Definition: cacheset.h:217
iterator_type & operator--()
Definition: cacheset.h:211
bool operator>(iterator_type const &i) const
Definition: cacheset.h:219
iterator_type & operator++()
Definition: cacheset.h:207
iterator_type operator++(int)
Definition: cacheset.h:208
container_iterator _iter
Definition: cacheset.h:202
iterator_type operator+(typename container_iterator::difference_type const &n)
Definition: cacheset.h:209
container_iterator::reference operator[](typename container_iterator::difference_type const &n) const
Definition: cacheset.h:222
bool operator>=(iterator_type const &i) const
Definition: cacheset.h:221
Container::iterator::reference operator*(void) const
Definition: cacheset.h:248
Container_iterator< Interface, Container, Master > iterator_type
Definition: cacheset.h:241
Container::iterator container_iterator
Definition: cacheset.h:242
Container_iterator(container_iterator const &i)
Definition: cacheset.h:244
Container::value_type getType(void) const
Definition: cacheset.h:250
iterator_type & operator=(container_iterator const &i)
Definition: cacheset.h:274
Container_reverse_iterator(container_iterator i)
Definition: cacheset.h:269
Container_reverse_iterator< Interface, Container, Master > iterator_type
Definition: cacheset.h:266
Container::reverse_iterator container_iterator
Definition: cacheset.h:267
Container::reverse_iterator::reference operator*(void) const
Definition: cacheset.h:275
Container::value_type getType(void) const
Definition: cacheset.h:277
iterator_type & operator=(iterator_type const &i)
Definition: cacheset.h:273
pkgCache::VerIterator CurrentVer() const
Definition: cacheset.h:303
pkgCache::PkgIterator getType() const
Definition: cacheset.h:292
pkgCache::DepIterator RevDependsList() const
Definition: cacheset.h:304
pkgCache::VerIterator VersionList() const
Definition: cacheset.h:302
pkgCache::PkgIterator::OkState State() const
Definition: cacheset.h:306
pkgCache::GrpIterator Group() const
Definition: cacheset.h:301
pkgCache::Package const * operator->() const
Definition: cacheset.h:313
pkgCache::PrvIterator ProvidesList() const
Definition: cacheset.h:305
std::string FullName(bool const Pretty) const
Definition: cacheset.h:297
virtual bool insert(pkgCache::PkgIterator const &P)=0
void setConstructor(CacheSetHelper::PkgSelector const by)
Definition: cacheset.h:322
CacheSetHelper::PkgSelector ConstructedBy
Definition: cacheset.h:331
CacheSetHelper::PkgSelector getConstructor() const
Definition: cacheset.h:323
virtual size_t size() const =0
virtual bool empty() const =0
Container::reference reference
Definition: cacheset.h:351
const_iterator find(pkgCache::PkgIterator const &P) const
Definition: cacheset.h:385
bool empty() const APT_OVERRIDE
Definition: cacheset.h:361
static PackageContainer FromFnMatch(pkgCacheFile &Cache, std::string const &pattern)
Definition: cacheset.h:451
Container_iterator< PackageContainerInterface, Container, PackageContainer > iterator
Definition: cacheset.h:345
const_reverse_iterator rend() const
Definition: cacheset.h:374
static PackageContainer FromTask(pkgCacheFile &Cache, std::string const &pattern)
Definition: cacheset.h:422
Container::size_type size_type
Definition: cacheset.h:354
size_t size() const APT_OVERRIDE
Definition: cacheset.h:363
const_iterator begin() const
Definition: cacheset.h:371
Container::const_pointer const_pointer
Definition: cacheset.h:350
void insert(const_iterator begin, const_iterator end)
Definition: cacheset.h:359
void clear() APT_OVERRIDE
Definition: cacheset.h:362
static PackageContainer FromString(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper)
returns all packages specified by a string
Definition: cacheset.h:461
Container::value_type value_type
Definition: cacheset.h:348
Container::allocator_type allocator_type
Definition: cacheset.h:355
bool insert(pkgCache::PkgIterator const &P) APT_OVERRIDE
Definition: cacheset.h:357
reverse_iterator rend()
Definition: cacheset.h:384
bool sort(Compare)
sort all included versions with given comparer
Definition: cacheset.h:407
Container::difference_type difference_type
Definition: cacheset.h:353
void insert(PackageContainer< Cont > const &pkgcont)
Definition: cacheset.h:358
Container::const_reference const_reference
Definition: cacheset.h:352
Container_const_reverse_iterator< PackageContainerInterface, Container, PackageContainer > const_reverse_iterator
Definition: cacheset.h:346
static PackageContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper)
returns all packages specified on the commandline
Definition: cacheset.h:478
static PackageContainer FromTask(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper)
returns all packages in the cache who belong to the given task
Definition: cacheset.h:417
Container_const_iterator< PackageContainerInterface, Container, PackageContainer > const_iterator
smell like a pkgCache::PkgIterator
Definition: cacheset.h:344
static PackageContainer FromString(pkgCacheFile &Cache, std::string const &pattern)
Definition: cacheset.h:466
static PackageContainer FromFnmatch(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper)
Definition: cacheset.h:446
Container::pointer pointer
Definition: cacheset.h:349
const_iterator end() const
Definition: cacheset.h:372
reverse_iterator rbegin()
Definition: cacheset.h:383
static std::map< unsigned short, PackageContainer > GroupedFromCommandLine(pkgCacheFile &Cache, const char **cmdline, std::list< CacheSetHelper::PkgModifier > const &mods, unsigned short const &fallback)
Definition: cacheset.h:514
PackageContainer(Itr first, Itr last)
Definition: cacheset.h:389
iterator begin()
Definition: cacheset.h:381
void push_back(const value_type &P)
Definition: cacheset.h:395
Container_reverse_iterator< PackageContainerInterface, Container, PackageContainer > reverse_iterator
Definition: cacheset.h:347
static std::map< unsigned short, PackageContainer > GroupedFromCommandLine(pkgCacheFile &Cache, const char **cmdline, std::list< CacheSetHelper::PkgModifier > const &mods, unsigned short const &fallback, CacheSetHelper &helper)
group packages by a action modifiers
Definition: cacheset.h:499
const_reverse_iterator rbegin() const
Definition: cacheset.h:373
iterator erase(iterator pos)
Definition: cacheset.h:368
static PackageContainer FromRegEx(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper)
returns all packages in the cache whose name matches a given pattern
Definition: cacheset.h:435
iterator erase(iterator first, iterator last)
Definition: cacheset.h:369
PackageContainer(CacheSetHelper::PkgSelector const &by)
Definition: cacheset.h:388
static PackageContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline)
Definition: cacheset.h:483
static PackageContainer FromRegEx(pkgCacheFile &Cache, std::string const &pattern)
Definition: cacheset.h:441
const_iterator(pkgCache::PkgIterator i)
Definition: cacheset.h:635
pkgCache::PkgIterator getType(void) const
Definition: cacheset.h:638
bool empty() const APT_OVERRIDE
Definition: cacheset.h:650
size_t size() const APT_OVERRIDE
Definition: cacheset.h:651
std::make_unsigned< const_iterator::difference_type >::type size_type
Definition: cacheset.h:647
const_iterator begin() const
Definition: cacheset.h:653
APT_HIDDEN bool insert(pkgCache::PkgIterator const &) APT_OVERRIDE
Definition: cacheset.h:667
const_iterator cbegin() const
Definition: cacheset.h:655
pkgCache *const _cont
Definition: cacheset.h:629
pkgCache * data() const
Definition: cacheset.h:660
pkgCache::PkgIterator value_type
Definition: cacheset.h:641
APT_HIDDEN void insert(const_iterator, const_iterator)
Definition: cacheset.h:669
const_iterator::difference_type difference_type
Definition: cacheset.h:646
pkgCache::PkgIterator * pointer
Definition: cacheset.h:642
APT_HIDDEN void insert(PackageContainer< Cont > const &)
Definition: cacheset.h:668
const_iterator cend() const
Definition: cacheset.h:656
const_reference reference
Definition: cacheset.h:645
const pkgCache::PkgIterator & const_reference
Definition: cacheset.h:644
APT_HIDDEN iterator erase(const_iterator pos)
iterator end()
Definition: cacheset.h:658
const_iterator iterator
Definition: cacheset.h:640
const_iterator end() const
Definition: cacheset.h:654
iterator begin()
Definition: cacheset.h:657
void *const d
Definition: cacheset.h:630
APT_HIDDEN iterator erase(const_iterator first, const_iterator last)
APT_HIDDEN void clear() APT_OVERRIDE
Definition: cacheset.h:671
pkgCache::PkgIterator const * const_pointer
Definition: cacheset.h:643
smell like a pkgCache::VerIterator
Definition: cacheset.h:691
pkgCache::VerFileIterator NewestFile() const
Definition: cacheset.h:712
pkgCache::VerIterator getType() const
Definition: cacheset.h:692
pkgCache::DescIterator DescriptionList() const
Definition: cacheset.h:703
pkgCache::DescIterator TranslatedDescription() const
Definition: cacheset.h:704
pkgCache::PrvIterator ProvidesList() const
Definition: cacheset.h:706
pkgCache::Version const * operator->() const
Definition: cacheset.h:716
pkgCache::PkgIterator ParentPkg() const
Definition: cacheset.h:702
int CompareVer(const pkgCache::VerIterator &B) const
Definition: cacheset.h:698
pkgCache::VerFileIterator FileList() const
Definition: cacheset.h:707
pkgCache::DepIterator DependsList() const
Definition: cacheset.h:705
static bool FromPackage(VersionContainerInterface *const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &P, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper)
Definition: cacheset.cc:516
static bool FromString(VersionContainerInterface *const vci, pkgCacheFile &Cache, std::string pkg, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper, bool const onlyFromName=false)
Definition: cacheset.cc:445
static bool FromPattern(VersionContainerInterface *const vci, pkgCacheFile &Cache, std::string pkg, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper)
virtual size_t size() const =0
virtual bool insert(pkgCache::VerIterator const &V)=0
static bool FromDependency(VersionContainerInterface *const vci, pkgCacheFile &Cache, pkgCache::DepIterator const &D, CacheSetHelper::VerSelector const selector, CacheSetHelper &helper)
Definition: cacheset.cc:579
static bool FromCommandLine(VersionContainerInterface *const vci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper)
Definition: cacheset.cc:434
static bool FromModifierCommandLine(unsigned short &modID, VersionContainerInterface *const vci, pkgCacheFile &Cache, const char *cmdline, std::list< Modifier > const &mods, CacheSetHelper &helper)
Definition: cacheset.cc:388
virtual bool empty() const =0
static VersionContainer FromString(pkgCacheFile &Cache, std::string pkg, CacheSetHelper::VerSelector const fallback)
Definition: cacheset.h:891
Container::reference reference
Definition: cacheset.h:806
bool empty() const APT_OVERRIDE
Definition: cacheset.h:815
static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper)
returns all versions specified for the package
Definition: cacheset.h:907
const_reverse_iterator rend() const
Definition: cacheset.h:828
Container::size_type size_type
Definition: cacheset.h:809
size_t size() const APT_OVERRIDE
Definition: cacheset.h:817
void insert(VersionContainer< Cont > const &vercont)
Definition: cacheset.h:813
const_iterator begin() const
Definition: cacheset.h:825
Container::const_pointer const_pointer
Definition: cacheset.h:805
VersionContainer(Itr first, Itr last)
Definition: cacheset.h:842
static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D)
Definition: cacheset.h:958
void insert(const_iterator begin, const_iterator end)
Definition: cacheset.h:814
void clear() APT_OVERRIDE
Definition: cacheset.h:816
static std::map< unsigned short, VersionContainer > GroupedFromCommandLine(pkgCacheFile &Cache, const char **cmdline, std::list< Modifier > const &mods, unsigned short const fallback, CacheSetHelper &helper)
Definition: cacheset.h:922
static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P)
Definition: cacheset.h:918
Container::value_type value_type
Definition: cacheset.h:803
Container_iterator< VersionContainerInterface, Container, VersionContainer > iterator
Definition: cacheset.h:800
static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P, CacheSetHelper::VerSelector const fallback)
Definition: cacheset.h:913
Container_const_iterator< VersionContainerInterface, Container, VersionContainer > const_iterator
Definition: cacheset.h:799
Container::allocator_type allocator_type
Definition: cacheset.h:810
Container_const_reverse_iterator< VersionContainerInterface, Container, VersionContainer > const_reverse_iterator
Definition: cacheset.h:801
reverse_iterator rend()
Definition: cacheset.h:838
bool sort(Compare)
sort all included versions with given comparer
Definition: cacheset.h:860
Container::difference_type difference_type
Definition: cacheset.h:808
static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D, CacheSetHelper::VerSelector const selector, CacheSetHelper &helper)
Definition: cacheset.h:947
Container::const_reference const_reference
Definition: cacheset.h:807
static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D, CacheSetHelper::VerSelector const selector)
Definition: cacheset.h:953
static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper)
returns all versions specified on the commandline
Definition: cacheset.h:870
static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline)
Definition: cacheset.h:881
bool insert(pkgCache::VerIterator const &V) APT_OVERRIDE
Definition: cacheset.h:812
const_iterator find(pkgCache::VerIterator const &V) const
Definition: cacheset.h:839
static VersionContainer FromString(pkgCacheFile &Cache, std::string pkg)
Definition: cacheset.h:896
Container::pointer pointer
Definition: cacheset.h:804
const_iterator end() const
Definition: cacheset.h:826
reverse_iterator rbegin()
Definition: cacheset.h:837
iterator begin()
Definition: cacheset.h:835
void push_back(const value_type &P)
Definition: cacheset.h:848
const_reverse_iterator rbegin() const
Definition: cacheset.h:827
static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper::VerSelector const fallback)
Definition: cacheset.h:876
Container_reverse_iterator< VersionContainerInterface, Container, VersionContainer > reverse_iterator
Definition: cacheset.h:802
static VersionContainer FromString(pkgCacheFile &Cache, std::string const &pkg, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper, bool const)
Definition: cacheset.h:884
iterator erase(iterator pos)
Definition: cacheset.h:822
static std::map< unsigned short, VersionContainer > GroupedFromCommandLine(pkgCacheFile &Cache, const char **cmdline, std::list< Modifier > const &mods, unsigned short const fallback)
Definition: cacheset.h:938
iterator erase(iterator first, iterator last)
Definition: cacheset.h:823
MsgType
a message can have one of following severity
Definition: error.h:55
@ ERROR
An error does hinder the correct execution and should be corrected.
Definition: error.h:60
pkgCache * Cache() const
STRING
#define APT_OVERRIDE
Definition: macros.h:111
#define APT_PUBLIC
Definition: macros.h:77
#define APT_HIDDEN
Definition: macros.h:78
VersionContainer< std::vector< pkgCache::VerIterator > > VersionVector
Definition: cacheset.h:1065
VersionContainer< std::deque< pkgCache::VerIterator > > VersionDeque
Definition: cacheset.h:1064
PackageContainer< std::vector< pkgCache::PkgIterator > > PackageVector
Definition: cacheset.h:683
PackageContainer< std::deque< pkgCache::PkgIterator > > PackageDeque
Definition: cacheset.h:682
VersionContainer< std::list< pkgCache::VerIterator > > VersionList
Definition: cacheset.h:1063
PackageContainer< std::set< pkgCache::PkgIterator > > PackageSet
Definition: cacheset.h:676
VersionContainer< std::set< pkgCache::VerIterator > > VersionSet
Definition: cacheset.h:1058
PackageContainer< std::list< pkgCache::PkgIterator > > PackageList
Definition: cacheset.h:681
pkgCache - Structure definitions for the cache file
const char *const Alias
Definition: cacheset.h:64
PkgModifier(unsigned short const &id, const char *const alias, Position const &pos)
Definition: cacheset.h:66
Modifier(unsigned short const &id, const char *const alias, Position const &pos, enum CacheSetHelper::VerSelector const select)
Definition: cacheset.h:730
contains information for a single unique package
Definition: pkgcache.h:450
information for a single version of a package
Definition: pkgcache.h:625