]> git.saurik.com Git - apt.git/blame_incremental - apt-pkg/srcrecords.h
rework dpkg-wrapping in test framework
[apt.git] / apt-pkg / srcrecords.h
... / ...
CommitLineData
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3// $Id: srcrecords.h,v 1.8.2.1 2003/12/26 16:27:34 mdz Exp $
4/* ######################################################################
5
6 Source Package Records - Allows access to source package records
7
8 Parses and allows access to the list of source records and searching by
9 source name on that list.
10
11 ##################################################################### */
12 /*}}}*/
13#ifndef PKGLIB_SRCRECORDS_H
14#define PKGLIB_SRCRECORDS_H
15
16#include <apt-pkg/macros.h>
17#include <apt-pkg/hashes.h>
18
19#include <string>
20#include <vector>
21
22#ifndef APT_8_CLEANER_HEADERS
23using std::string;
24using std::vector;
25#endif
26
27class pkgSourceList;
28class pkgIndexFile;
29class pkgSrcRecords
30{
31 public:
32
33APT_IGNORE_DEPRECATED_PUSH
34 // Describes a single file
35 struct File
36 {
37 std::string Path;
38 std::string Type;
39 unsigned long long Size;
40 HashStringList Hashes;
41 APT_DEPRECATED std::string MD5Hash;
42 };
43APT_IGNORE_DEPRECATED_POP
44
45 // Abstract parser for each source record
46 class Parser
47 {
48 protected:
49
50 const pkgIndexFile *iIndex;
51
52 public:
53
54 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
55 BuildConflict=0x2,BuildConflictIndep=0x3};
56
57 struct BuildDepRec
58 {
59 std::string Package;
60 std::string Version;
61 unsigned int Op;
62 unsigned char Type;
63 };
64
65 inline const pkgIndexFile &Index() const {return *iIndex;};
66
67 virtual bool Restart() = 0;
68 virtual bool Step() = 0;
69 virtual bool Jump(unsigned long const &Off) = 0;
70 virtual unsigned long Offset() = 0;
71 virtual std::string AsStr() = 0;
72
73 virtual std::string Package() const = 0;
74 virtual std::string Version() const = 0;
75 virtual std::string Maintainer() const = 0;
76 virtual std::string Section() const = 0;
77 virtual const char **Binaries() = 0; // Ownership does not transfer
78
79 //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
80 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
81 static const char *BuildDepType(unsigned char const &Type) APT_PURE;
82
83 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
84
85 Parser(const pkgIndexFile *Index) : iIndex(Index) {};
86 virtual ~Parser() {};
87 };
88
89 private:
90 /** \brief dpointer placeholder (for later in case we need it) */
91 void *d;
92
93 // The list of files and the current parser pointer
94 std::vector<Parser*> Files;
95 std::vector<Parser *>::iterator Current;
96
97 public:
98
99 // Reset the search
100 bool Restart();
101
102 // Step to the next SourcePackage and return pointer to the
103 // next SourceRecord. The pointer is owned by libapt.
104 const Parser* Step();
105
106 // Locate a package by name and return pointer to the Parser.
107 // The pointer is owned by libapt.
108 Parser* Find(const char *Package,bool const &SrcOnly = false);
109
110 pkgSrcRecords(pkgSourceList &List);
111 virtual ~pkgSrcRecords();
112};
113
114#endif