]> git.saurik.com Git - apt.git/blob - apt-pkg/srcrecords.h
make errors more consistent
[apt.git] / apt-pkg / srcrecords.h
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
23 using std::string;
24 using std::vector;
25 #endif
26
27 class pkgSourceList;
28 class pkgIndexFile;
29 class pkgSrcRecords
30 {
31 public:
32
33 #if __GNUC__ >= 4
34 // ensure that con- & de-structor don't trigger this warning
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
37 #endif
38 // Describes a single file
39 struct File
40 {
41 std::string Path;
42 std::string Type;
43 unsigned long long Size;
44 HashStringList Hashes;
45 APT_DEPRECATED std::string MD5Hash;
46 };
47 #if __GNUC__ >= 4
48 #pragma GCC diagnostic pop
49 #endif
50
51 // Abstract parser for each source record
52 class Parser
53 {
54 protected:
55
56 const pkgIndexFile *iIndex;
57
58 public:
59
60 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
61 BuildConflict=0x2,BuildConflictIndep=0x3};
62
63 struct BuildDepRec
64 {
65 std::string Package;
66 std::string Version;
67 unsigned int Op;
68 unsigned char Type;
69 };
70
71 inline const pkgIndexFile &Index() const {return *iIndex;};
72
73 virtual bool Restart() = 0;
74 virtual bool Step() = 0;
75 virtual bool Jump(unsigned long const &Off) = 0;
76 virtual unsigned long Offset() = 0;
77 virtual std::string AsStr() = 0;
78
79 virtual std::string Package() const = 0;
80 virtual std::string Version() const = 0;
81 virtual std::string Maintainer() const = 0;
82 virtual std::string Section() const = 0;
83 virtual const char **Binaries() = 0; // Ownership does not transfer
84
85 //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
86 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
87 static const char *BuildDepType(unsigned char const &Type) APT_PURE;
88
89 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
90
91 Parser(const pkgIndexFile *Index) : iIndex(Index) {};
92 virtual ~Parser() {};
93 };
94
95 private:
96 /** \brief dpointer placeholder (for later in case we need it) */
97 void *d;
98
99 // The list of files and the current parser pointer
100 std::vector<Parser*> Files;
101 std::vector<Parser *>::iterator Current;
102
103 public:
104
105 // Reset the search
106 bool Restart();
107
108 // Step to the next SourcePackage and return pointer to the
109 // next SourceRecord. The pointer is owned by libapt.
110 const Parser* Step();
111
112 // Locate a package by name and return pointer to the Parser.
113 // The pointer is owned by libapt.
114 Parser* Find(const char *Package,bool const &SrcOnly = false);
115
116 pkgSrcRecords(pkgSourceList &List);
117 virtual ~pkgSrcRecords();
118 };
119
120 #endif