]> git.saurik.com Git - apt.git/blame - apt-pkg/srcrecords.h
Of *course* I managed to get this check backwards.
[apt.git] / apt-pkg / srcrecords.h
CommitLineData
11e7af84
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
11e7af84
AL
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
a02db58f 15#include <apt-pkg/macros.h>
1262d358 16#include <apt-pkg/hashes.h>
11e7af84 17
b2e465d6 18#include <string>
8f3ba4e8 19#include <vector>
0a843901 20
a4f6bdc8
DK
21#ifndef APT_8_CLEANER_HEADERS
22using std::string;
23using std::vector;
24#endif
25
b2e465d6
AL
26class pkgSourceList;
27class pkgIndexFile;
11e7af84
AL
28class pkgSrcRecords
29{
30 public:
36f610f1 31
586d8704 32APT_IGNORE_DEPRECATED_PUSH
36f610f1
AL
33 // Describes a single file
34 struct File
35 {
5dd00edb
DK
36 APT_DEPRECATED_MSG("Use Hashes member instead of hardcoded hash algorithm") std::string MD5Hash;
37 APT_DEPRECATED_MSG("Use FileSize member instead") unsigned long Size;
8f3ba4e8
DK
38 std::string Path;
39 std::string Type;
36f610f1 40 };
3a2b39ee
DK
41 struct File2 : public File
42 {
43 unsigned long long FileSize;
1262d358 44 HashStringList Hashes;
36f610f1 45 };
586d8704 46APT_IGNORE_DEPRECATED_POP
1262d358 47
36f610f1 48 // Abstract parser for each source record
11e7af84
AL
49 class Parser
50 {
6c55f07a 51 void * const d;
b2e465d6
AL
52 protected:
53
54 const pkgIndexFile *iIndex;
36375005 55
11e7af84
AL
56 public:
57
b2e465d6 58 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
c5f22e48
JS
59 BuildConflict=0x2,BuildConflictIndep=0x3,
60 BuildDependArch=0x4,BuildConflictArch=0x5};
b2e465d6
AL
61
62 struct BuildDepRec
63 {
8f3ba4e8
DK
64 std::string Package;
65 std::string Version;
b2e465d6
AL
66 unsigned int Op;
67 unsigned char Type;
68 };
69
70 inline const pkgIndexFile &Index() const {return *iIndex;};
36375005 71
11e7af84
AL
72 virtual bool Restart() = 0;
73 virtual bool Step() = 0;
41c81fd8 74 virtual bool Jump(unsigned long const &Off) = 0;
11e7af84 75 virtual unsigned long Offset() = 0;
8f3ba4e8 76 virtual std::string AsStr() = 0;
11e7af84 77
8f3ba4e8
DK
78 virtual std::string Package() const = 0;
79 virtual std::string Version() const = 0;
80 virtual std::string Maintainer() const = 0;
81 virtual std::string Section() const = 0;
b2e465d6
AL
82 virtual const char **Binaries() = 0; // Ownership does not transfer
83
65f99834 84 //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
8f3ba4e8 85 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
a02db58f 86 static const char *BuildDepType(unsigned char const &Type) APT_PURE;
b2e465d6 87
8f3ba4e8 88 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
3a2b39ee 89 bool Files2(std::vector<pkgSrcRecords::File2> &F);
e8afd168
DK
90
91 explicit Parser(const pkgIndexFile *Index);
92 virtual ~Parser();
11e7af84
AL
93 };
94
95 private:
be9b62f7 96 /** \brief dpointer placeholder (for later in case we need it) */
6c55f07a 97 void * const d;
11e7af84
AL
98
99 // The list of files and the current parser pointer
8f3ba4e8
DK
100 std::vector<Parser*> Files;
101 std::vector<Parser *>::iterator Current;
11e7af84
AL
102
103 public:
104
105 // Reset the search
106 bool Restart();
107
46255701
MV
108 // Step to the next SourcePackage and return pointer to the
109 // next SourceRecord. The pointer is owned by libapt.
401e5db1 110 const Parser* Step();
46255701
MV
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);
e8afd168
DK
115
116 explicit pkgSrcRecords(pkgSourceList &List);
ff72bd0d 117 virtual ~pkgSrcRecords();
11e7af84
AL
118};
119
11e7af84 120#endif