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