]>
Commit | Line | Data |
---|---|---|
f55ece0e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
f50d1cfa | 3 | // $Id: pkgrecords.cc,v 1.8 2003/09/02 04:52:16 mdz Exp $ |
f55ece0e AL |
4 | /* ###################################################################### |
5 | ||
6 | Package Records - Allows access to complete package description records | |
7 | directly from the file. | |
8 | ||
9 | ##################################################################### */ | |
10 | /*}}}*/ | |
11 | // Include Files /*{{{*/ | |
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "apt-pkg/pkgrecords.h" | |
14 | #endif | |
15 | #include <apt-pkg/pkgrecords.h> | |
b2e465d6 | 16 | #include <apt-pkg/indexfile.h> |
f55ece0e | 17 | #include <apt-pkg/error.h> |
3164dff9 | 18 | #include <apt-pkg/configuration.h> |
b2e465d6 AL |
19 | |
20 | #include <apti18n.h> | |
f55ece0e AL |
21 | /*}}}*/ |
22 | ||
23 | // Records::pkgRecords - Constructor /*{{{*/ | |
24 | // --------------------------------------------------------------------- | |
25 | /* This will create the necessary structures to access the status files */ | |
d715b9c9 MV |
26 | pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), |
27 | Files(Cache.HeaderP->PackageFileCount) | |
f55ece0e | 28 | { |
f55ece0e AL |
29 | for (pkgCache::PkgFileIterator I = Cache.FileBegin(); |
30 | I.end() == false; I++) | |
31 | { | |
b2e465d6 AL |
32 | const pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(I.IndexType()); |
33 | if (Type == 0) | |
3164dff9 | 34 | { |
b2e465d6 | 35 | _error->Error(_("Index file type '%s' is not supported"),I.IndexType()); |
3164dff9 AL |
36 | return; |
37 | } | |
b2e465d6 AL |
38 | |
39 | Files[I->ID] = Type->CreatePkgParser(I); | |
40 | if (Files[I->ID] == 0) | |
f55ece0e AL |
41 | return; |
42 | } | |
43 | } | |
44 | /*}}}*/ | |
45 | // Records::~pkgRecords - Destructor /*{{{*/ | |
46 | // --------------------------------------------------------------------- | |
47 | /* */ | |
48 | pkgRecords::~pkgRecords() | |
49 | { | |
d715b9c9 MV |
50 | for ( vector<Parser*>::iterator it = Files.begin(); |
51 | it != Files.end(); | |
52 | ++it) | |
53 | { | |
54 | delete *it; | |
55 | } | |
56 | ||
f55ece0e AL |
57 | } |
58 | /*}}}*/ | |
59 | // Records::Lookup - Get a parser for the package version file /*{{{*/ | |
60 | // --------------------------------------------------------------------- | |
61 | /* */ | |
03e39e59 AL |
62 | pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator const &Ver) |
63 | { | |
b2e465d6 AL |
64 | Files[Ver.File()->ID]->Jump(Ver); |
65 | return *Files[Ver.File()->ID]; | |
f55ece0e AL |
66 | } |
67 | /*}}}*/ | |
a52f938b OS |
68 | // Records::Lookup - Get a parser for the package description file /*{{{*/ |
69 | // --------------------------------------------------------------------- | |
70 | /* */ | |
71 | pkgRecords::Parser &pkgRecords::Lookup(pkgCache::DescFileIterator const &Desc) | |
72 | { | |
73 | Files[Desc.File()->ID]->Jump(Desc); | |
74 | return *Files[Desc.File()->ID]; | |
75 | } | |
76 | /*}}}*/ |