From bf6675d0fa43debb4dcdac2ae22d48f848393314 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Mon, 13 Feb 2006 15:17:44 +0000 Subject: [PATCH] add disk usage info to packages, and start implementing the parser to add this info to suse tags, commiting as backup --- zypp/Package.cc | 3 ++ zypp/Package.h | 4 +++ zypp/detail/PackageImplIf.cc | 3 ++ zypp/detail/PackageImplIf.h | 3 ++ zypp/source/susetags/PackagesParser.cc | 51 ++++++++++++++++++++++++++++++++++ zypp/source/susetags/PackagesParser.h | 2 ++ 6 files changed, 66 insertions(+) diff --git a/zypp/Package.cc b/zypp/Package.cc index c6b66d1..bfe2e63 100644 --- a/zypp/Package.cc +++ b/zypp/Package.cc @@ -113,6 +113,9 @@ namespace zypp ByteCount Package::archivesize() const { return pimpl().archivesize(); } + DiskUsage Package::diskusage() const + { return pimpl().diskusage(); } + /** */ std::list Package::authors() const { return pimpl().authors(); } diff --git a/zypp/Package.h b/zypp/Package.h index 7adb61c..774113b 100644 --- a/zypp/Package.h +++ b/zypp/Package.h @@ -77,6 +77,10 @@ namespace zypp std::list authors() const; /** */ std::list filenames() const; + + /** Disk usage per directory */ + DiskUsage diskusage() const; + /** */ License licenseToConfirm() const; /** */ diff --git a/zypp/detail/PackageImplIf.cc b/zypp/detail/PackageImplIf.cc index fcb6680..34dc0a5 100644 --- a/zypp/detail/PackageImplIf.cc +++ b/zypp/detail/PackageImplIf.cc @@ -80,6 +80,9 @@ namespace zypp ByteCount PackageImplIf::archivesize() const { return ByteCount(); } + DiskUsage PackageImplIf::diskusage() const + { return DiskUsage(); } + std::list PackageImplIf::authors() const { return std::list(); } diff --git a/zypp/detail/PackageImplIf.h b/zypp/detail/PackageImplIf.h index 74f37c6..1eb2e1c 100644 --- a/zypp/detail/PackageImplIf.h +++ b/zypp/detail/PackageImplIf.h @@ -20,6 +20,7 @@ #include "zypp/Changelog.h" #include "zypp/PatchRpm.h" #include "zypp/DeltaRpm.h" +#include "zypp/DiskUsage.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -101,6 +102,8 @@ namespace zypp /** */ virtual ByteCount archivesize() const PURE_VIRTUAL; /** */ + virtual DiskUsage diskusage() const PURE_VIRTUAL; + /** */ virtual std::list authors() const PURE_VIRTUAL; /** */ virtual std::list filenames() const PURE_VIRTUAL; diff --git a/zypp/source/susetags/PackagesParser.cc b/zypp/source/susetags/PackagesParser.cc index a73f7d7..6618bbe 100644 --- a/zypp/source/susetags/PackagesParser.cc +++ b/zypp/source/susetags/PackagesParser.cc @@ -33,6 +33,57 @@ namespace zypp using namespace parser::tagfile; + + struct PackageDiskUsageParser : public parser::tagfile::TagFileParser + { + PkgDiskUsage result; + NVRAD _current_nvrad; + bool _pkg_pending; + + virtual void beginParse() + { + _pkg_pending = false; + } + + /* Consume SingleTag data. */ + virtual void consume( const SingleTag & stag_r ) + { + if ( stag_r.name == "Pkg" ) + { + std::vector words; + str::split( stag_r.value, std::back_inserter(words) ); + + if ( str::split( stag_r.value, std::back_inserter(words) ) != 4 ) + ZYPP_THROW( ParseException( "Pkg" ) ); + + _pkg_pending = true; + _current_nvrad = NVRAD( words[0], Edition(words[1],words[2]), Arch(words[3]) ); + } + else + { + //ZYPP_THROW( ParseException( "Loc" ) ); + ERR << "warning found unexpected tag " << stag_r.name << std::endl; + } + } + + /* Consume MulitTag data. */ + virtual void consume( const MultiTag & mtag_r ) + { + if ( ! _pkg_pending ) + return; + + if ( mtag_r.name == "Dir" ) + { + //collectDeps( mtag_r.values, _nvrad[Dep::PROVIDES] ); + } + } + + virtual void endParse() + {} + + }; + + struct PackagesParser : public parser::tagfile::TagFileParser { PkgContent _result; diff --git a/zypp/source/susetags/PackagesParser.h b/zypp/source/susetags/PackagesParser.h index 07bd306..b5f5113 100644 --- a/zypp/source/susetags/PackagesParser.h +++ b/zypp/source/susetags/PackagesParser.h @@ -18,6 +18,7 @@ #include "zypp/base/PtrTypes.h" #include "zypp/Pathname.h" #include "zypp/Package.h" +#include "zypp/DiskUsage.h" #include "zypp/NVRAD.h" #include "zypp/source/susetags/SuseTagsImpl.h" #include "zypp/source/susetags/SuseTagsPackageImpl.h" @@ -34,6 +35,7 @@ namespace zypp typedef shared_ptr PkgImplPtr; typedef std::map PkgContent; + typedef std::map PkgDiskUsage; /** \deprecated Just temporary. * \throws ParseException and others. -- 2.7.4