]>
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 /*{{{*/
14 #include <apt-pkg/pkgrecords.h>
15 #include <apt-pkg/indexfile.h>
16 #include <apt-pkg/error.h>
17 #include <apt-pkg/configuration.h>
22 // Records::pkgRecords - Constructor /*{{{*/
23 // ---------------------------------------------------------------------
24 /* This will create the necessary structures to access the status files */
25 pkgRecords::pkgRecords(pkgCache
&Cache
) : d(NULL
), Cache(Cache
),
26 Files(Cache
.HeaderP
->PackageFileCount
)
28 for (pkgCache::PkgFileIterator I
= Cache
.FileBegin();
29 I
.end() == false; ++I
)
31 const pkgIndexFile::Type
*Type
= pkgIndexFile::Type::GetType(I
.IndexType());
34 _error
->Error(_("Index file type '%s' is not supported"),I
.IndexType());
38 Files
[I
->ID
] = Type
->CreatePkgParser(I
);
39 if (Files
[I
->ID
] == 0)
44 // Records::~pkgRecords - Destructor /*{{{*/
45 // ---------------------------------------------------------------------
47 pkgRecords::~pkgRecords()
49 for ( std::vector
<Parser
*>::iterator it
= Files
.begin();
57 // Records::Lookup - Get a parser for the package version file /*{{{*/
58 // ---------------------------------------------------------------------
60 pkgRecords::Parser
&pkgRecords::Lookup(pkgCache::VerFileIterator
const &Ver
)
62 Files
[Ver
.File()->ID
]->Jump(Ver
);
63 return *Files
[Ver
.File()->ID
];
66 // Records::Lookup - Get a parser for the package description file /*{{{*/
67 // ---------------------------------------------------------------------
69 pkgRecords::Parser
&pkgRecords::Lookup(pkgCache::DescFileIterator
const &Desc
)
71 Files
[Desc
.File()->ID
]->Jump(Desc
);
72 return *Files
[Desc
.File()->ID
];