~ubuntu-branches/debian/experimental/apt/experimental

« back to all changes in this revision

Viewing changes to apt-pkg/cacheiterators.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-02-18 22:07:23 UTC
  • mfrom: (9.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100218220723-zb7zdh6fmsmp30tr
Tags: 0.7.26~exp2
fix crash when LANGUAGE is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#define PKGLIB_CACHEITERATORS_H
33
33
 
34
34
 
35
 
// Package Iterator
 
35
// Package Iterator                                                     /*{{{*/
36
36
class pkgCache::PkgIterator
37
37
{
38
38
   friend class pkgCache;
80
80
   inline PrvIterator ProvidesList() const;
81
81
   inline unsigned long Index() const {return Pkg - Owner->PkgP;};
82
82
   OkState State() const;
83
 
   
 
83
 
 
84
   //Nice printable representation
 
85
   friend std::ostream& operator<<(std::ostream& out, pkgCache::PkgIterator Pkg);
 
86
 
 
87
   const char *CandVersion() const;
 
88
   const char *CurVersion() const;
 
89
 
84
90
   // Constructors
85
91
   inline PkgIterator(pkgCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner),
86
92
          HashIndex(0) 
90
96
   };
91
97
   inline PkgIterator() : Pkg(0), Owner(0), HashIndex(0) {};
92
98
};
93
 
 
94
 
// Version Iterator
 
99
                                                                        /*}}}*/
 
100
// Version Iterator                                                     /*{{{*/
95
101
class pkgCache::VerIterator
96
102
{
97
103
   Version *Ver;
104
110
   // Iteration
105
111
   void operator ++(int) {if (Ver != Owner->VerP) Ver = Owner->VerP + Ver->NextVer;};
106
112
   inline void operator ++() {operator ++(0);};
107
 
   inline bool end() const {return Owner == NULL || (Ver == Owner->VerP?true:false);};
 
113
   inline bool end() const {return Owner == 0 || (Ver == Owner->VerP?true:false);};
108
114
   inline void operator =(const VerIterator &B) {Ver = B.Ver; Owner = B.Owner;};
109
115
   
110
116
   // Comparison
111
117
   inline bool operator ==(const VerIterator &B) const {return Ver == B.Ver;};
112
118
   inline bool operator !=(const VerIterator &B) const {return Ver != B.Ver;};
113
119
   int CompareVer(const VerIterator &B) const;
114
 
   
 
120
 
 
121
   // Testing
 
122
   inline bool IsGood() const { return Ver && Owner && ! end();};
 
123
 
115
124
   // Accessors
116
125
   inline Version *operator ->() {return Ver;};
117
126
   inline Version const *operator ->() const {return Ver;};
146
155
         Ver = Owner.VerP;
147
156
   };
148
157
};
149
 
 
150
 
// Description Iterator
 
158
                                                                        /*}}}*/
 
159
// Description Iterator                                                 /*{{{*/
151
160
class pkgCache::DescIterator
152
161
{
153
162
   Description *Desc;
160
169
   // Iteration
161
170
   void operator ++(int) {if (Desc != Owner->DescP) Desc = Owner->DescP + Desc->NextDesc;};
162
171
   inline void operator ++() {operator ++(0);};
163
 
   inline bool end() const {return Desc == Owner->DescP?true:false;};
 
172
   inline bool end() const {return Owner == 0 || Desc == Owner->DescP?true:false;};
164
173
   inline void operator =(const DescIterator &B) {Desc = B.Desc; Owner = B.Owner;};
165
174
   
166
175
   // Comparison
190
199
         Desc = Owner.DescP;
191
200
   };
192
201
};
193
 
 
194
 
// Dependency iterator
 
202
                                                                        /*}}}*/
 
203
// Dependency iterator                                                  /*{{{*/
195
204
class pkgCache::DepIterator
196
205
{
197
206
   Dependency *Dep;
249
258
   };
250
259
   inline DepIterator() : Dep(0), Type(DepVer), Owner(0) {};
251
260
};
252
 
 
253
 
// Provides iterator
 
261
                                                                        /*}}}*/
 
262
// Provides iterator                                                    /*{{{*/
254
263
class pkgCache::PrvIterator
255
264
{
256
265
   Provides *Prv;
302
311
         Prv = Owner.ProvideP;
303
312
   };
304
313
};
305
 
 
306
 
// Package file 
 
314
                                                                        /*}}}*/
 
315
// Package file                                                         /*{{{*/
307
316
class pkgCache::PkgFileIterator
308
317
{
309
318
   pkgCache *Owner;
314
323
   // Iteration
315
324
   void operator ++(int) {if (File!= Owner->PkgFileP) File = Owner->PkgFileP + File->NextFile;};
316
325
   inline void operator ++() {operator ++(0);};
317
 
   inline bool end() const {return File == Owner->PkgFileP?true:false;};
 
326
   inline bool end() const {return Owner == 0 || File == Owner->PkgFileP?true:false;};
318
327
 
319
328
   // Comparison
320
329
   inline bool operator ==(const PkgFileIterator &B) const {return File == B.File;};
333
342
   inline const char *Component() const {return File->Component == 0?0:Owner->StrP + File->Component;};
334
343
   inline const char *Version() const {return File->Version == 0?0:Owner->StrP + File->Version;};
335
344
   inline const char *Origin() const {return File->Origin == 0?0:Owner->StrP + File->Origin;};
 
345
   inline const char *Codename() const {return File->Codename ==0?0:Owner->StrP + File->Codename;};
336
346
   inline const char *Label() const {return File->Label == 0?0:Owner->StrP + File->Label;};
337
347
   inline const char *Site() const {return File->Site == 0?0:Owner->StrP + File->Site;};
338
348
   inline const char *Architecture() const {return File->Architecture == 0?0:Owner->StrP + File->Architecture;};
348
358
   inline PkgFileIterator(pkgCache &Owner) : Owner(&Owner), File(Owner.PkgFileP) {};
349
359
   inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Owner(&Owner), File(Trg) {};
350
360
};
351
 
 
352
 
// Version File 
 
361
                                                                        /*}}}*/
 
362
// Version File                                                         /*{{{*/
353
363
class pkgCache::VerFileIterator
354
364
{
355
365
   pkgCache *Owner;
360
370
   // Iteration
361
371
   void operator ++(int) {if (FileP != Owner->VerFileP) FileP = Owner->VerFileP + FileP->NextFile;};
362
372
   inline void operator ++() {operator ++(0);};
363
 
   inline bool end() const {return FileP == Owner->VerFileP?true:false;};
 
373
   inline bool end() const {return Owner == 0 || FileP == Owner->VerFileP?true:false;};
364
374
 
365
375
   // Comparison
366
376
   inline bool operator ==(const VerFileIterator &B) const {return FileP == B.FileP;};
380
390
   inline VerFileIterator() : Owner(0), FileP(0) {};
381
391
   inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
382
392
};
383
 
 
384
 
// Description File 
 
393
                                                                        /*}}}*/
 
394
// Description File                                                     /*{{{*/
385
395
class pkgCache::DescFileIterator
386
396
{
387
397
   pkgCache *Owner;
392
402
   // Iteration
393
403
   void operator ++(int) {if (FileP != Owner->DescFileP) FileP = Owner->DescFileP + FileP->NextFile;};
394
404
   inline void operator ++() {operator ++(0);};
395
 
   inline bool end() const {return FileP == Owner->DescFileP?true:false;};
 
405
   inline bool end() const {return Owner == 0 ||  FileP == Owner->DescFileP?true:false;};
396
406
 
397
407
   // Comparison
398
408
   inline bool operator ==(const DescFileIterator &B) const {return FileP == B.FileP;};
412
422
   inline DescFileIterator() : Owner(0), FileP(0) {};
413
423
   inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Owner(&Owner), FileP(Trg) {};
414
424
};
415
 
 
416
 
// Inlined Begin functions cant be in the class because of order problems
 
425
                                                                        /*}}}*/
 
426
// Inlined Begin functions cant be in the class because of order problems /*{{{*/
417
427
inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
418
428
       {return VerIterator(*Owner,Owner->VerP + Pkg->VersionList);};
419
429
inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
432
442
       {return VerFileIterator(*Owner,Owner->VerFileP + Ver->FileList);};
433
443
inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
434
444
       {return DescFileIterator(*Owner,Owner->DescFileP + Desc->FileList);};
435
 
 
 
445
                                                                        /*}}}*/
436
446
#endif