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)  

pkgrecords.cc
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  Package Records - Allows access to complete package description records
6  directly from the file.
7 
8  ##################################################################### */
9  /*}}}*/
10 // Include Files /*{{{*/
11 #include <config.h>
12 
13 #include <apt-pkg/error.h>
14 #include <apt-pkg/indexfile.h>
15 #include <apt-pkg/pkgcache.h>
16 #include <apt-pkg/pkgrecords.h>
17 
18 #include <vector>
19 #include <stddef.h>
20 
21 #include <apti18n.h>
22  /*}}}*/
23 
24 // Records::pkgRecords - Constructor /*{{{*/
25 // ---------------------------------------------------------------------
26 /* This will create the necessary structures to access the status files */
27 pkgRecords::pkgRecords(pkgCache &aCache) : d(NULL), Cache(aCache),
28  Files(Cache.HeaderP->PackageFileCount)
29 {
31  I.end() == false; ++I)
32  {
33  const pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(I.IndexType());
34  if (Type == 0)
35  {
36  _error->Error(_("Index file type '%s' is not supported"),I.IndexType());
37  return;
38  }
39 
40  Files[I->ID] = Type->CreatePkgParser(I);
41  if (Files[I->ID] == 0)
42  return;
43  }
44 }
45  /*}}}*/
46 // Records::~pkgRecords - Destructor /*{{{*/
47 // ---------------------------------------------------------------------
48 /* */
50 {
51  for ( std::vector<Parser*>::iterator it = Files.begin();
52  it != Files.end();
53  ++it)
54  {
55  delete *it;
56  }
57 }
58  /*}}}*/
59 // Records::Lookup - Get a parser for the package version file /*{{{*/
60 // ---------------------------------------------------------------------
61 /* */
63 {
64  Files[Ver.File()->ID]->Jump(Ver);
65  return *Files[Ver.File()->ID];
66 }
67  /*}}}*/
68 // Records::Lookup - Get a parser for the package description file /*{{{*/
69 // ---------------------------------------------------------------------
70 /* */
72 {
73  Files[Desc.File()->ID]->Jump(Desc);
74  return *Files[Desc.File()->ID];
75 }
76  /*}}}*/
77 
78 pkgRecords::Parser::Parser() : d(NULL) {}
79 pkgRecords::Parser::~Parser() {}
static bool std::string const metaIndex const *const pkgAcqMetaClearSig *const pkgAcquire::Item *const I
PkgFileIterator FileBegin()
Definition: pkgcache.h:814
virtual pkgRecords::Parser * CreatePkgParser(pkgCache::PkgFileIterator const &) const
Definition: indexfile.h:120
static Type * GetType(const char *const Type) APT_PURE
Definition: indexfile.cc:55
pkgCache & Cache
Definition: pkgrecords.h:35
friend class pkgRecords
Definition: pkgrecords.h:56
std::vector< Parser * > Files
Definition: pkgrecords.h:36
Parser & Lookup(pkgCache::VerFileIterator const &Ver)
Definition: pkgrecords.cc:62
virtual ~pkgRecords()
Definition: pkgrecords.cc:49
pkgCache - Structure definitions for the cache file