|
apt @VERSION@
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: srcrecords.h,v 1.8.2.1 2003/12/26 16:27:34 mdz Exp $ 00004 /* ###################################################################### 00005 00006 Source Package Records - Allows access to source package records 00007 00008 Parses and allows access to the list of source records and searching by 00009 source name on that list. 00010 00011 ##################################################################### */ 00012 /*}}}*/ 00013 #ifndef PKGLIB_SRCRECORDS_H 00014 #define PKGLIB_SRCRECORDS_H 00015 00016 00017 #include <string> 00018 #include <vector> 00019 00020 class pkgSourceList; 00021 class pkgIndexFile; 00022 class pkgSrcRecords 00023 { 00024 public: 00025 00026 // Describes a single file 00027 struct File 00028 { 00029 std::string MD5Hash; 00030 unsigned long Size; 00031 std::string Path; 00032 std::string Type; 00033 }; 00034 00035 // Abstract parser for each source record 00036 class Parser 00037 { 00038 protected: 00039 00040 const pkgIndexFile *iIndex; 00041 00042 public: 00043 00044 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1, 00045 BuildConflict=0x2,BuildConflictIndep=0x3}; 00046 00047 struct BuildDepRec 00048 { 00049 std::string Package; 00050 std::string Version; 00051 unsigned int Op; 00052 unsigned char Type; 00053 }; 00054 00055 inline const pkgIndexFile &Index() const {return *iIndex;}; 00056 00057 virtual bool Restart() = 0; 00058 virtual bool Step() = 0; 00059 virtual bool Jump(unsigned long const &Off) = 0; 00060 virtual unsigned long Offset() = 0; 00061 virtual std::string AsStr() = 0; 00062 00063 virtual std::string Package() const = 0; 00064 virtual std::string Version() const = 0; 00065 virtual std::string Maintainer() const = 0; 00066 virtual std::string Section() const = 0; 00067 virtual const char **Binaries() = 0; // Ownership does not transfer 00068 00069 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0; 00070 static const char *BuildDepType(unsigned char const &Type); 00071 00072 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0; 00073 00074 Parser(const pkgIndexFile *Index) : iIndex(Index) {}; 00075 virtual ~Parser() {}; 00076 }; 00077 00078 private: 00080 void *d; 00081 00082 // The list of files and the current parser pointer 00083 std::vector<Parser*> Files; 00084 std::vector<Parser *>::iterator Current; 00085 00086 public: 00087 00088 // Reset the search 00089 bool Restart(); 00090 00091 // Locate a package by name 00092 Parser *Find(const char *Package,bool const &SrcOnly = false); 00093 00094 pkgSrcRecords(pkgSourceList &List); 00095 virtual ~pkgSrcRecords(); 00096 }; 00097 00098 #endif
1.7.4