add disk usage info to packages, and start implementing the parser to add this info...
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 13 Feb 2006 15:17:44 +0000 (15:17 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 13 Feb 2006 15:17:44 +0000 (15:17 +0000)
zypp/Package.cc
zypp/Package.h
zypp/detail/PackageImplIf.cc
zypp/detail/PackageImplIf.h
zypp/source/susetags/PackagesParser.cc
zypp/source/susetags/PackagesParser.h

index c6b66d1..bfe2e63 100644 (file)
@@ -113,6 +113,9 @@ namespace zypp
   ByteCount Package::archivesize() const
   { return pimpl().archivesize(); }
 
+  DiskUsage Package::diskusage() const
+  { return pimpl().diskusage(); }
+
   /** */
   std::list<std::string> Package::authors() const
   { return pimpl().authors(); }
index 7adb61c..774113b 100644 (file)
@@ -77,6 +77,10 @@ namespace zypp
     std::list<std::string> authors() const;
     /** */
     std::list<std::string> filenames() const;
+
+    /** Disk usage per directory */
+    DiskUsage diskusage() const;
+    
     /** */
     License licenseToConfirm() const;
     /** */
index fcb6680..34dc0a5 100644 (file)
@@ -80,6 +80,9 @@ namespace zypp
       ByteCount PackageImplIf::archivesize() const
       { return ByteCount(); }
 
+      DiskUsage PackageImplIf::diskusage() const
+      { return DiskUsage(); }      
+
       std::list<std::string> PackageImplIf::authors() const
       { return std::list<std::string>(); }
 
index 74f37c6..1eb2e1c 100644 (file)
@@ -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<std::string> authors() const PURE_VIRTUAL;
       /** */
       virtual std::list<std::string> filenames() const PURE_VIRTUAL;
index a73f7d7..6618bbe 100644 (file)
@@ -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<std::string> 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;
index 07bd306..b5f5113 100644 (file)
@@ -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<SuseTagsPackageImpl> PkgImplPtr;
       typedef std::map<NVRAD, PkgImplPtr> PkgContent;
+      typedef std::map<NVRAD, DiskUsage> PkgDiskUsage;
 
       /** \deprecated Just temporary.
        * \throws ParseException and others.