apt 3.0.3
commandline package manager
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/hashes.h>
16#include <apt-pkg/macros.h>
17
18#include <string>
19#include <vector>
20
21
22class pkgSourceList;
23class pkgIndexFile;
24class APT_PUBLIC pkgSrcRecords
25{
26 public:
27
28 // Describes a single file
29 struct File
30 {
31 std::string Path;
32 std::string Type;
33 unsigned long long FileSize;
35 };
36
37 // Abstract parser for each source record
38 class Parser
39 {
40 void * const d;
41 protected:
42
43 const pkgIndexFile *iIndex;
44
45 public:
46
47 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
48 BuildConflict=0x2,BuildConflictIndep=0x3,
49 BuildDependArch=0x4,BuildConflictArch=0x5};
50
52 {
53 std::string Package;
54 std::string Version;
55 unsigned int Op;
56 unsigned char Type;
57 };
58
59 inline const pkgIndexFile &Index() const {return *iIndex;};
60
61 virtual bool Restart() = 0;
62 virtual bool Step() = 0;
63 virtual bool Jump(unsigned long const &Off) = 0;
64 virtual unsigned long Offset() = 0;
65 virtual std::string AsStr() = 0;
66
67 virtual std::string Package() const = 0;
68 virtual std::string Version() const = 0;
69 virtual std::string Maintainer() const = 0;
70 virtual std::string Section() const = 0;
71 virtual const char **Binaries() = 0; // Ownership does not transfer
72
73 //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
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) APT_PURE;
76
77 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
78
79 explicit Parser(const pkgIndexFile *Index);
80 virtual ~Parser();
81 };
82
83 private:
85 void * const 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 // Step to the next SourcePackage and return pointer to the
97 // next SourceRecord. The pointer is owned by libapt.
98 const Parser* Step();
99
100 // Locate a package by name and return pointer to the Parser.
101 // The pointer is owned by libapt.
102 Parser* Find(const char *Package,bool const &SrcOnly = false);
103
104 explicit pkgSrcRecords(pkgSourceList &List);
105 virtual ~pkgSrcRecords();
106};
107
108#endif
Definition hashes.h:79
Definition hashes.h:184
Definition indexfile.h:103
Definition sourcelist.h:43
Definition srcrecords.h:39
virtual bool BuildDepends(std::vector< BuildDepRec > &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch=true)=0
Definition srcrecords.h:25
Definition srcrecords.h:30
Definition srcrecords.h:52