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