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