]>
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 /*{{{*/ | |
ea542140 DK |
12 | #include<config.h> |
13 | ||
f55ece0e | 14 | #include <apt-pkg/pkgrecords.h> |
b2e465d6 | 15 | #include <apt-pkg/indexfile.h> |
f55ece0e | 16 | #include <apt-pkg/error.h> |
3164dff9 | 17 | #include <apt-pkg/configuration.h> |
ea542140 DK |
18 | |
19 | #include <apti18n.h> | |
f55ece0e AL |
20 | /*}}}*/ |
21 | ||
22 | // Records::pkgRecords - Constructor /*{{{*/ | |
23 | // --------------------------------------------------------------------- | |
24 | /* This will create the necessary structures to access the status files */ | |
dcaa1185 | 25 | pkgRecords::pkgRecords(pkgCache &Cache) : d(NULL), Cache(Cache), |
30257943 | 26 | Files(Cache.HeaderP->PackageFileCount) |
f55ece0e | 27 | { |
30257943 | 28 | for (pkgCache::PkgFileIterator I = Cache.FileBegin(); |
f7f0d6c7 | 29 | I.end() == false; ++I) |
f55ece0e | 30 | { |
b2e465d6 AL |
31 | const pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(I.IndexType()); |
32 | if (Type == 0) | |
3164dff9 | 33 | { |
30257943 MV |
34 | _error->Error(_("Index file type '%s' is not supported"),I.IndexType()); |
35 | return; | |
3164dff9 | 36 | } |
b2e465d6 AL |
37 | |
38 | Files[I->ID] = Type->CreatePkgParser(I); | |
39 | if (Files[I->ID] == 0) | |
30257943 MV |
40 | return; |
41 | } | |
f55ece0e AL |
42 | } |
43 | /*}}}*/ | |
44 | // Records::~pkgRecords - Destructor /*{{{*/ | |
45 | // --------------------------------------------------------------------- | |
46 | /* */ | |
47 | pkgRecords::~pkgRecords() | |
48 | { | |
8f3ba4e8 | 49 | for ( std::vector<Parser*>::iterator it = Files.begin(); |
30257943 MV |
50 | it != Files.end(); |
51 | ++it) | |
52 | { | |
53 | delete *it; | |
54 | } | |
f55ece0e AL |
55 | } |
56 | /*}}}*/ | |
57 | // Records::Lookup - Get a parser for the package version file /*{{{*/ | |
58 | // --------------------------------------------------------------------- | |
59 | /* */ | |
03e39e59 AL |
60 | pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator const &Ver) |
61 | { | |
b2e465d6 AL |
62 | Files[Ver.File()->ID]->Jump(Ver); |
63 | return *Files[Ver.File()->ID]; | |
f55ece0e AL |
64 | } |
65 | /*}}}*/ | |
a52f938b OS |
66 | // Records::Lookup - Get a parser for the package description file /*{{{*/ |
67 | // --------------------------------------------------------------------- | |
68 | /* */ | |
69 | pkgRecords::Parser &pkgRecords::Lookup(pkgCache::DescFileIterator const &Desc) | |
70 | { | |
71 | Files[Desc.File()->ID]->Jump(Desc); | |
72 | return *Files[Desc.File()->ID]; | |
73 | } | |
74 | /*}}}*/ |