]>
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/pkgcache.h>
18 #include <apt-pkg/cacheiterators.h>
26 // Records::pkgRecords - Constructor /*{{{*/
27 // ---------------------------------------------------------------------
28 /* This will create the necessary structures to access the status files */
29 pkgRecords::pkgRecords(pkgCache
&aCache
) : d(NULL
), Cache(aCache
),
30 Files(Cache
.HeaderP
->PackageFileCount
)
32 for (pkgCache::PkgFileIterator I
= Cache
.FileBegin();
33 I
.end() == false; ++I
)
35 const pkgIndexFile::Type
*Type
= pkgIndexFile::Type::GetType(I
.IndexType());
38 _error
->Error(_("Index file type '%s' is not supported"),I
.IndexType());
42 Files
[I
->ID
] = Type
->CreatePkgParser(I
);
43 if (Files
[I
->ID
] == 0)
48 // Records::~pkgRecords - Destructor /*{{{*/
49 // ---------------------------------------------------------------------
51 pkgRecords::~pkgRecords()
53 for ( std::vector
<Parser
*>::iterator it
= Files
.begin();
61 // Records::Lookup - Get a parser for the package version file /*{{{*/
62 // ---------------------------------------------------------------------
64 pkgRecords::Parser
&pkgRecords::Lookup(pkgCache::VerFileIterator
const &Ver
)
66 Files
[Ver
.File()->ID
]->Jump(Ver
);
67 return *Files
[Ver
.File()->ID
];
70 // Records::Lookup - Get a parser for the package description file /*{{{*/
71 // ---------------------------------------------------------------------
73 pkgRecords::Parser
&pkgRecords::Lookup(pkgCache::DescFileIterator
const &Desc
)
75 Files
[Desc
.File()->ID
]->Jump(Desc
);
76 return *Files
[Desc
.File()->ID
];
80 pkgRecords::Parser::Parser() : d(NULL
) {}
81 pkgRecords::Parser::~Parser() {}