]> git.saurik.com Git - apt.git/blob - apt-pkg/srcrecords.h
apt-pkg/contrib/netrc.cc: use a slightly smaller login/password size
[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
17 #include <string>
18 #include <vector>
19
20 #ifndef APT_8_CLEANER_HEADERS
21 using std::string;
22 using std::vector;
23 #endif
24
25 class pkgSourceList;
26 class pkgIndexFile;
27 class pkgSrcRecords
28 {
29 public:
30
31 // Describes a single file
32 struct File
33 {
34 std::string MD5Hash;
35 unsigned long Size;
36 std::string Path;
37 std::string Type;
38 };
39
40 // Abstract parser for each source record
41 class Parser
42 {
43 protected:
44
45 const pkgIndexFile *iIndex;
46
47 public:
48
49 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
50 BuildConflict=0x2,BuildConflictIndep=0x3};
51
52 struct BuildDepRec
53 {
54 std::string Package;
55 std::string Version;
56 unsigned int Op;
57 unsigned char Type;
58 };
59
60 inline const pkgIndexFile &Index() const {return *iIndex;};
61
62 virtual bool Restart() = 0;
63 virtual bool Step() = 0;
64 virtual bool Jump(unsigned long const &Off) = 0;
65 virtual unsigned long Offset() = 0;
66 virtual std::string AsStr() = 0;
67
68 virtual std::string Package() const = 0;
69 virtual std::string Version() const = 0;
70 virtual std::string Maintainer() const = 0;
71 virtual std::string Section() const = 0;
72 virtual const char **Binaries() = 0; // Ownership does not transfer
73
74 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
75 static const char *BuildDepType(unsigned char const &Type);
76
77 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
78
79 Parser(const pkgIndexFile *Index) : iIndex(Index) {};
80 virtual ~Parser() {};
81 };
82
83 private:
84 /** \brief dpointer placeholder (for later in case we need it) */
85 void *d;
86
87 // The list of files and the current parser pointer
88 std::vector<Parser*> Files;
89 std::vector<Parser *>::iterator Current;
90
91 public:
92
93 // Reset the search
94 bool Restart();
95
96 // Locate a package by name
97 Parser *Find(const char *Package,bool const &SrcOnly = false);
98
99 pkgSrcRecords(pkgSourceList &List);
100 virtual ~pkgSrcRecords();
101 };
102
103 #endif