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