diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-01-08 21:07:37 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-03-16 18:01:13 +0100 |
commit | 2f6a2fbbdc9f76dc4eace83a427013f4e1c03afc (patch) | |
tree | c831f594596241ef1ef56c20dbd1f4e39a6840b9 /apt-pkg/deb/debrecords.h | |
parent | 3de7789a75c58204bcc979c72899cfdacba4e2ac (diff) |
properly implement pkgRecord::Parser for *.deb files
Implementing FileName() works for most cases for us, but other
frontends might need more and even for us its not very stable as
the normal Jump() implementation is pretty bad on a deb file and
produce errors on its own at times.
So, replacing this makeshift with a complete implementation by
mostly just shuffling code around.
Diffstat (limited to 'apt-pkg/deb/debrecords.h')
-rw-r--r-- | apt-pkg/deb/debrecords.h | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index 7091c38e6..38e071940 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -25,21 +25,12 @@ #include <apt-pkg/indexfile.h> #endif -class APT_HIDDEN debRecordParser : public pkgRecords::Parser +class APT_HIDDEN debRecordParserBase : public pkgRecords::Parser { - /** \brief dpointer placeholder (for later in case we need it) */ - void *d; - protected: - FileFd File; - pkgTagFile Tags; pkgTagSection Section; - - virtual bool Jump(pkgCache::VerFileIterator const &Ver); - virtual bool Jump(pkgCache::DescFileIterator const &Desc); - - public: + public: // These refer to the archive file for the Version virtual std::string FileName(); virtual std::string SourcePkg(); @@ -58,20 +49,42 @@ class APT_HIDDEN debRecordParser : public pkgRecords::Parser virtual std::string RecordField(const char *fieldName); virtual void GetRec(const char *&Start,const char *&Stop); - + + debRecordParserBase() : Parser() {} + virtual ~debRecordParserBase(); +}; + +class APT_HIDDEN debRecordParser : public debRecordParserBase +{ + protected: + FileFd File; + pkgTagFile Tags; + + virtual bool Jump(pkgCache::VerFileIterator const &Ver); + virtual bool Jump(pkgCache::DescFileIterator const &Desc); + + public: debRecordParser(std::string FileName,pkgCache &Cache); virtual ~debRecordParser(); }; // custom record parser that reads deb files directly -class APT_HIDDEN debDebFileRecordParser : public debRecordParser +class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase { + std::string debFileName; + std::string controlContent; + + APT_HIDDEN bool LoadContent(); + protected: + // single file files, so no jumping whatsoever + bool Jump(pkgCache::VerFileIterator const &) { return LoadContent(); } + bool Jump(pkgCache::DescFileIterator const &) { return LoadContent(); } + public: - virtual std::string FileName() { - return File.Name(); - } - debDebFileRecordParser(std::string FileName,pkgCache &Cache) - : debRecordParser(FileName, Cache) {}; + virtual std::string FileName() { return debFileName; } + + debDebFileRecordParser(std::string FileName) + : debRecordParserBase(), debFileName(FileName) {}; }; #endif |