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