]>
git.saurik.com Git - apt.git/blob - apt-pkg/pkgrecords.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgrecords.cc,v 1.8 2003/09/02 04:52:16 mdz Exp $
4 /* ######################################################################
6 Package Records - Allows access to complete package description records
7 directly from the file.
9 ##################################################################### */
11 // Include Files /*{{{*/
13 #pragma implementation "apt-pkg/pkgrecords.h"
15 #include <apt-pkg/pkgrecords.h>
16 #include <apt-pkg/indexfile.h>
17 #include <apt-pkg/error.h>
18 #include <apt-pkg/configuration.h>
23 // Records::pkgRecords - Constructor /*{{{*/
24 // ---------------------------------------------------------------------
25 /* This will create the necessary structures to access the status files */
26 pkgRecords::pkgRecords(pkgCache
&Cache
) : Cache(Cache
),
27 Files(Cache
.HeaderP
->PackageFileCount
)
29 for (pkgCache::PkgFileIterator I
= Cache
.FileBegin();
30 I
.end() == false; I
++)
32 const pkgIndexFile::Type
*Type
= pkgIndexFile::Type::GetType(I
.IndexType());
35 _error
->Error(_("Index file type '%s' is not supported"),I
.IndexType());
39 Files
[I
->ID
] = Type
->CreatePkgParser(I
);
40 if (Files
[I
->ID
] == 0)
45 // Records::~pkgRecords - Destructor /*{{{*/
46 // ---------------------------------------------------------------------
48 pkgRecords::~pkgRecords()
50 for ( vector
<Parser
*>::iterator it
= Files
.begin();
59 // Records::Lookup - Get a parser for the package version file /*{{{*/
60 // ---------------------------------------------------------------------
62 pkgRecords::Parser
&pkgRecords::Lookup(pkgCache::VerFileIterator
const &Ver
)
64 Files
[Ver
.File()->ID
]->Jump(Ver
);
65 return *Files
[Ver
.File()->ID
];
68 // Records::Lookup - Get a parser for the package description file /*{{{*/
69 // ---------------------------------------------------------------------
71 pkgRecords::Parser
&pkgRecords::Lookup(pkgCache::DescFileIterator
const &Desc
)
73 Files
[Desc
.File()->ID
]->Jump(Desc
);
74 return *Files
[Desc
.File()->ID
];