- Parser update
authorMichael Andres <ma@suse.de>
Wed, 16 May 2007 19:47:19 +0000 (19:47 +0000)
committerMichael Andres <ma@suse.de>
Wed, 16 May 2007 19:47:19 +0000 (19:47 +0000)
- added class ZConfig

13 files changed:
devel/devel.ma/Parse.cc
zypp/CMakeLists.txt
zypp/ZConfig.cc [new file with mode: 0644]
zypp/ZConfig.h [new file with mode: 0644]
zypp/parser/TagParser.cc
zypp/parser/TagParser.h
zypp/parser/susetags/ContentFileReader.cc [new file with mode: 0644]
zypp/parser/susetags/ContentFileReader.h [new file with mode: 0644]
zypp/parser/susetags/PackagesFileReader.cc
zypp/parser/susetags/PackagesLangFileReader.cc
zypp/parser/susetags/PatternFileReader.cc
zypp/parser/susetags/RepoIndex.cc [new file with mode: 0644]
zypp/parser/susetags/RepoIndex.h [new file with mode: 0644]

index 193dfba..6548d54 100644 (file)
@@ -26,6 +26,8 @@
 #include "zypp/parser/susetags/PackagesFileReader.h"
 #include "zypp/parser/susetags/PackagesLangFileReader.h"
 #include "zypp/parser/susetags/PatternFileReader.h"
+#include "zypp/parser/susetags/ContentFileReader.h"
+#include "zypp/parser/susetags/RepoIndex.h"
 
 using namespace std;
 using namespace zypp;
@@ -122,7 +124,7 @@ std::ostream & operator<<( std::ostream & str, const iostr::EachLine & obj )
 }
 
 #include "zypp/ProgressData.h"
-
+#include "zypp2/cache/CacheStore.h"
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -133,14 +135,72 @@ namespace zypp
    ///////////////////////////////////////////////////////////////////
     namespace susetags
     { /////////////////////////////////////////////////////////////////
-
-      bool exampleReceiver( ProgressData::value_type v )
+#if 0
+      class RepoParser
       {
-       WAR << "got ->" << v << "%" << endl;
-       return true;
-      }
+       public:
+         RepoParser( const Pathname & reporoot_r, data::RecordId catalogId_r, const Pathname & dbdir_r )
+         : _reporoot( reporoot_r )
+         , _catalogId( catalogId_r )
+         , _store( store_r );
+         {
+           if ( 1 )
+           {
+             std::string file( "content" );
+             Measure x( file );
+
+             ContentFileReader tp;
+
+
+           }
+
+
+           if ( 1 )
+           {
+             std::string file("packages");
+             Measure x( file );
+
+             PackagesFileReader tp;
+             tp.setPkgConsumer   ( bind( &RepoParser::consumePkg, this, _1 ) );
+             tp.setSrcPkgConsumer( bind( &RepoParser::consumeSrcPkg , this, _1 ) );
+             tp.parse(repodescr()/file );
+           }
+         }
 
 
+       public:
+         const Pathname & reporoot() const
+         { return _reporoot; }
+
+         Pathname repodescr() const
+         { return _reporoot/"suse/setup/descr"; }
+
+         Pathname repodata() const
+         { return _reporoot/"suse"; }
+
+       private:
+         void consumePkg( const data::Package_Ptr & pkg_r )
+         {
+            MIL << "[Pkg]" << pkg_r << endl;
+         }
+
+         void consumeSrcPkg( const data::SrcPackage_Ptr & pkg_r )
+         {
+            //DBG << "[Src]" << pkg_r << endl;
+         }
+
+         void consumePat( const data::Pattern_Ptr & pat_r )
+         {
+           MIL << "[Pat]" << pat_r << endl;
+         }
+       public:
+         Pathname          _reporoot;
+         data::RecordId    _catalogId;
+         cache::CacheStore _store;
+
+      };
+
+#endif
 
       /////////////////////////////////////////////////////////////////
     } // namespace susetags
@@ -153,23 +213,17 @@ namespace zypp
 ///////////////////////////////////////////////////////////////////
 
 using namespace zypp::parser::susetags;
-
 #include "zypp2/cache/CacheStore.h"
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  namespace str
-  { /////////////////////////////////////////////////////////////////
-    template<typename _It>
-      inline _It strtonum( const std::string & str );
-    template<>
-    inline ByteCount strtonum<ByteCount>( const std::string & str )
-    { return strtonum<ByteCount::SizeType>( str ); }
-    /////////////////////////////////////////////////////////////////
-  } // namespace str
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+
+void consumeIndex( const parser::susetags::RepoIndex_Ptr & index_r )
+{
+  SEC << "[Index]" << index_r << endl;
+}
+
+void consumeProd( const data::Product_Ptr & prod_r )
+{
+  SEC << "[Prod]" << prod_r << endl;
+}
 
 void consumePkg( const data::Package_Ptr & pkg_r )
 {
@@ -222,22 +276,32 @@ int main( int argc, char * argv[] )
   //zypp::base::LogControl::instance().logfile( "log.restrict" );
   INT << "===[START]==========================================" << endl;
 
+  Pathname p( "lmd/content" );
+
+  Measure x( p.basename() );
+  ContentFileReader tp;
+  tp.setProductConsumer( consumeProd );
+  tp.setRepoIndexConsumer( consumeIndex );
+  //tp.setSrcPkgConsumer( consumeSrcPkg );
+  tp.parse( p );
+
+
 #if 0
   //try
   {
     //Pathname dbdir( "/Local/ma/zypp-TRUNK/BUILD/libzypp/devel/devel.ma/store" );
-    Pathname dbdir( "./store" );
-    //filesystem::clean_dir( dbdir );
+
+
+    Pathname dbdir( "store" );
+    Pathname metadir( "lmd" );
+
     cache::CacheStore store( dbdir );
+    data::RecordId catalogId = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/" );
 
-    data::Resolvable_Ptr a;
-    data::Script_Ptr aa;
+    RepoParser( metadir, catalogId, store );
 
-    INT << a << endl;
-    INT << aa << endl;
   }
 
-#if 0
     try
     {
       ZYpp::Ptr z = getZYpp();
@@ -261,7 +325,6 @@ int main( int argc, char * argv[] )
   INT << "===[END]============================================" << endl << endl;
   zypp::base::LogControl::instance().logNothing();
   return 0;
-#endif
 
   Pathname proot( "lmd/suse/setup/descr" );
 
index 85e0fce..c24ca77 100644 (file)
@@ -11,6 +11,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CUR
 ADD_DEFINITIONS(-DLOCALEDIR=\\\"/usr/share/libzypp\\\" -DTEXTDOMAIN=\\\"zypp\\\" )
 
 SET( zypp_SRCS
+  ZConfig.cc
   LanguageCode.cc
   Arch.cc
   Atom.cc
@@ -87,7 +88,8 @@ SET( zypp_SRCS
   Fetcher.cc
 )
 
-SET( zypp_HEADERS
+SET( zypp_HEADERSZ
+  ZConfig.h
   Arch.h
   Atom.h
   AutoDispose.h
@@ -448,12 +450,16 @@ INSTALL(  FILES
 )
 
 SET( zypp_parser_susetags_SRCS
+  parser/susetags/RepoIndex.cc
+  parser/susetags/ContentFileReader.cc
   parser/susetags/PackagesFileReader.cc
   parser/susetags/PackagesLangFileReader.cc
   parser/susetags/PatternFileReader.cc
 )
 
 SET( zypp_parser_susetags_HEADERS
+  parser/susetags/RepoIndex.h
+  parser/susetags/ContentFileReader.h
   parser/susetags/FileReaderBase.h
   parser/susetags/FileReaderBaseImpl.h
   parser/susetags/PackagesFileReader.h
diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc
new file mode 100644 (file)
index 0000000..f38fe1a
--- /dev/null
@@ -0,0 +1,36 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/ZConfig.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/Logger.h"
+
+#include "zypp/ZConfig.h"
+#include "zypp/ZYppFactory.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : ZConfig::systemArchitecture
+  //   METHOD TYPE : Arch
+  //
+  Arch ZConfig::systemArchitecture() const
+  {
+    return getZYpp()->architecture();
+  }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/ZConfig.h b/zypp/ZConfig.h
new file mode 100644 (file)
index 0000000..8005b40
--- /dev/null
@@ -0,0 +1,43 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/ZConfig.h
+ *
+*/
+#ifndef ZYPP_ZCONFIG_H
+#define ZYPP_ZCONFIG_H
+
+#include <iosfwd>
+
+#include "zypp/Arch.h"
+#include "zypp/Pathname.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : ZConfig
+  //
+  /** Interim helper class to collect global options and settings.
+   * Use it to avoid hardcoded values and calls to getZypp() just
+   * to retrieve some value like architecture, languages or tmppath.
+  */
+  class ZConfig
+  {
+    public:
+      /** The system architecture. */
+      Arch systemArchitecture() const;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_ZCONFIG_H
index 76e73b4..fc52e34 100644 (file)
@@ -126,7 +126,7 @@ namespace zypp
     std::string TagParser::errPrefix( const MultiTagPtr & tag_r,
                                      const std::string & msg_r ) const
     {
-      return str::form( "%s:%u:+%s (@%lu) | %s",
+      return str::form( "%s:%u:+%s (@%u) | %s",
                        _inputname.c_str(),
                        tag_r->lineNo,
                        tag_r->asString().c_str(),
@@ -325,7 +325,6 @@ namespace zypp
          break;
        }
 
-
        if ( ! ticks.set( input_r.stream().tellg() ) )
          userRequestedAbort( line.lineNo() );
       }
index 52fd2e8..f17193e 100644 (file)
@@ -87,7 +87,7 @@ namespace zypp
        * Invokes \ref consume for each tag. \ref consume might throw
        * other exceptions as well.
       */
-      virtual void parse( const InputStream & imput_r,
+      virtual void parse( const InputStream & input_r,
                          const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() );
 
     protected:
diff --git a/zypp/parser/susetags/ContentFileReader.cc b/zypp/parser/susetags/ContentFileReader.cc
new file mode 100644 (file)
index 0000000..53dd32b
--- /dev/null
@@ -0,0 +1,476 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/parser/susetags/ContentFileReader.cc
+ *
+*/
+#include <iostream>
+#include <sstream>
+
+#include "zypp/base/LogTools.h"
+#include "zypp/base/String.h"
+#include "zypp/base/IOStream.h"
+#include "zypp/base/UserRequestException.h"
+#include "zypp/parser/tagfile/ParseException.h"
+
+#include "zypp/parser/susetags/ContentFileReader.h"
+#include "zypp/parser/susetags/RepoIndex.h"
+#include "zypp/data/ResolvableData.h"
+#include "zypp/CapFactory.h"
+
+#include "zypp/ZConfig.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace parser
+  { /////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////
+    namespace susetags
+    { /////////////////////////////////////////////////////////////////
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       CLASS NAME : ContentFileReader::Impl
+      //
+      /** ContentFileReader implementation. */
+      struct ContentFileReader::Impl
+      {
+       public:
+         Impl( const ContentFileReader & parent_r )
+         : _parent( parent_r )
+         {}
+
+         data::Product & product()
+         {
+           if ( !_product )
+             _product = new data::Product;
+           return *_product;
+         }
+
+         RepoIndex & repoindex()
+         {
+           if ( !_repoindex )
+             _repoindex = new RepoIndex;
+           return *_repoindex;
+         }
+
+         bool hasProduct() const
+         { return _product; }
+
+         bool hasRepoIndex() const
+         { return _repoindex; }
+
+         data::Product_Ptr handoutProduct()
+         {
+           data::Product_Ptr ret;
+           ret.swap( _product );
+           _product = 0;
+           return ret;
+         }
+
+         RepoIndex_Ptr handoutRepoIndex()
+         {
+           RepoIndex_Ptr ret;
+           ret.swap( _repoindex );
+           _repoindex = 0;
+           return ret;
+         }
+
+       public:
+         bool isRel( const std::string & rel_r ) const
+         {
+           try
+           {
+             Rel( rel_r );
+             return true;
+           }
+           catch (...)
+           {}
+           return false;
+         }
+
+         bool setUrlList( std::list<Url> & list_r, const std::string & value ) const
+         {
+           bool errors = false;
+           std::list<std::string> urls;
+           if ( str::split( value, std::back_inserter(urls) ) )
+           {
+             for ( std::list<std::string>::const_iterator it = urls.begin();
+                   it != urls.end(); ++it )
+             {
+               try
+               {
+                 list_r.push_back( *it );
+               }
+               catch( const Exception & excpt_r )
+               {
+                 WAR << *it << ": " << excpt_r << endl;
+                 errors = true;
+               }
+             }
+           }
+           return errors;
+         }
+
+         void setDependencies( data::DependencyList & deplist_r,const std::string & value ) const
+         {
+           std::list<std::string> words;
+           str::split( value, std::back_inserter( words ) );
+
+           for ( std::list<std::string>::const_iterator it = words.begin();
+                 it != words.end(); ++it )
+           {
+             Resolvable::Kind kind( ResTraits<Package>::kind );
+
+             std::string name = *it;
+             std::string::size_type colon = name.find( ":" );
+             if ( colon != std::string::npos )
+             {
+               std::string skind( name, 0, colon );
+               name.erase( 0, colon+1 );
+
+               if ( skind == ResTraits<Pattern>::kind )
+                 kind = ResTraits<Pattern>::kind;
+               else if ( skind == ResTraits<Patch>::kind )
+                 kind = ResTraits<Patch>::kind;
+               else if ( skind == ResTraits<Product>::kind )
+                 kind = ResTraits<Product>::kind;
+               else if ( skind == ResTraits<Selection>::kind )
+                 kind = ResTraits<Selection>::kind;
+               else if ( skind != ResTraits<Package>::kind )
+               {
+                 // colon but no kind ==> colon in a name
+                 name = skind + ":" + name;
+               }
+             }
+
+             // check for Rel:
+             std::list<std::string>::const_iterator next = it;
+             if ( ++next != words.end()
+                  && (*next).find_first_of( "<>=" ) != std::string::npos )
+             {
+               std::string op = *next;
+               if ( ++next != words.end() )
+               {
+                 name += " ";
+                 name += op;
+                 name += " ";
+                 name += *next;
+                 it = next;
+               }
+             }
+
+             // Add the dependency
+             deplist_r.insert( capability::parse( kind, name ) );
+           }
+         }
+
+       public:
+         std::string _inputname;
+
+       private:
+         const ContentFileReader & _parent;
+         data::Product_Ptr  _product;
+         RepoIndex_Ptr      _repoindex;
+      };
+      ///////////////////////////////////////////////////////////////////
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       CLASS NAME : ContentFileReader
+      //
+      ///////////////////////////////////////////////////////////////////
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       METHOD NAME : ContentFileReader::ContentFileReader
+      //       METHOD TYPE : Ctor
+      //
+      ContentFileReader::ContentFileReader()
+      {}
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       METHOD NAME : ContentFileReader::~ContentFileReader
+      //       METHOD TYPE : Dtor
+      //
+      ContentFileReader::~ContentFileReader()
+      {}
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       METHOD NAME : ContentFileReader::beginParse
+      //       METHOD TYPE : void
+      //
+      void ContentFileReader::beginParse()
+      {
+       _pimpl.reset( new Impl(*this) );
+      }
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       METHOD NAME : ContentFileReader::endParse
+      //       METHOD TYPE : void
+      //
+      void ContentFileReader::endParse()
+      {
+       // consume oldData
+       if ( _pimpl->hasProduct() )
+       {
+         if ( _productConsumer )
+           _productConsumer( _pimpl->handoutProduct() );
+       }
+       if ( _pimpl->hasRepoIndex() )
+       {
+         if ( _repoIndexConsumer )
+           _repoIndexConsumer( _pimpl->handoutRepoIndex() );
+       }
+
+       MIL << "[Content]" << endl;
+       _pimpl.reset();
+      }
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       METHOD NAME : ContentFileReader::userRequestedAbort
+      //       METHOD TYPE : void
+      //
+      void ContentFileReader::userRequestedAbort( unsigned lineNo_r )
+      {
+       ZYPP_THROW( AbortRequestException( errPrefix( lineNo_r ) ) );
+      }
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       METHOD NAME : ContentFileReader::errPrefix
+      //       METHOD TYPE : std::string
+      //
+      std::string ContentFileReader::errPrefix( unsigned lineNo_r,
+                                               const std::string & msg_r,
+                                               const std::string & line_r ) const
+      {
+       return str::form( "%s:%u:%s | %s",
+                         _pimpl->_inputname.c_str(),
+                         lineNo_r,
+                         line_r.c_str(),
+                         msg_r.c_str() );
+      }
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       METHOD NAME : ContentFileReader::parse
+      //       METHOD TYPE : void
+      //
+      void ContentFileReader::parse( const InputStream & input_r,
+                                    const ProgressData::ReceiverFnc & fnc_r )
+      {
+       MIL << "Start parsing " << input_r << endl;
+       beginParse();
+       _pimpl->_inputname = input_r.name();
+
+       ProgressData ticks( makeProgressData( input_r ) );
+       ticks.sendTo( fnc_r );
+       if ( ! ticks.toMin() )
+         userRequestedAbort( 0 );
+
+       iostr::EachLine line( input_r );
+       for( ; line; line.next() )
+       {
+         // strip 1st word from line to separate tag and value.
+         std::string value( *line );
+         std::string key( str::stripFirstWord( value, /*ltrim_first*/true ) );
+
+         if ( key.empty() || *key.c_str() == '#' ) // empty or comment line
+         {
+           continue;
+         }
+
+         // strip modifier if exists
+         std::string modifier;
+         std::string::size_type pos = key.rfind( '.' );
+         if ( pos != std::string::npos )
+         {
+           modifier = key.substr( pos+1 );
+           key.erase( pos );
+         }
+
+         if ( key == "PRODUCT" )
+         {
+           std::replace( value.begin(), value.end(), ' ', '_' );
+           _pimpl->product().name = value;
+         }
+         else if ( key == "VERSION" )
+         {
+           _pimpl->product().edition = value;
+         }
+         else if ( key == "DISTPRODUCT" )
+         {
+           _pimpl->product().distributionName = value;
+         }
+         else if ( key == "DISTVERSION" )
+         {
+           _pimpl->product().distributionEdition = value;
+         }
+         else if ( key == "VENDOR" )
+         {
+           _pimpl->product().vendor = value;
+         }
+         else if ( key == "SHORTLABEL" )
+         {
+           _pimpl->product().shortName.setText( value, Locale(modifier) );
+         }
+         else if ( key == "RELNOTESURL" )
+         {
+           for( std::string::size_type pos = value.find("%a");
+                pos != std::string::npos;
+                pos = value.find("%a") )
+           {
+             value.replace( pos, 2, ZConfig().systemArchitecture().asString() );
+           }
+           try
+           {
+             _pimpl->product().releasenotesUrl = value;
+           }
+           catch( const Exception & excpt_r )
+           {
+             WAR << errPrefix( line.lineNo(), excpt_r.asString(), *line ) << endl;
+           }
+         }
+         else if ( key == "UPDATEURLS" )
+         {
+           if ( _pimpl->setUrlList( _pimpl->product().updateUrls, value ) )
+           {
+             WAR << errPrefix( line.lineNo(), "Ignored malformed URL(s)", *line ) << endl;
+           }
+         }
+         else if ( key == "EXTRAURLS" )
+         {
+           if ( _pimpl->setUrlList( _pimpl->product().extraUrls, value ) )
+           {
+             WAR << errPrefix( line.lineNo(), "Ignored malformed URL(s)", *line ) << endl;
+           }
+         }
+         else if ( key == "OPTIONALURLS" )
+         {
+           if ( _pimpl->setUrlList( _pimpl->product().optionalUrls, value ) )
+           {
+             WAR << errPrefix( line.lineNo(), "Ignored malformed URL(s)", *line ) << endl;
+           }
+         }
+         else if ( key == "ARCH" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "DEFAULTBASE" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "PREREQUIRES" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::PREREQUIRES], value );
+         }
+         else if ( key == "REQUIRES" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::REQUIRES], value );
+         }
+         else if ( key == "PROVIDES" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::PROVIDES], value );
+         }
+         else if ( key == "CONFLICTS" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::CONFLICTS], value );
+         }
+         else if ( key == "OBSOLETES" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::OBSOLETES], value );
+         }
+         else if ( key == "RECOMMENDS" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::RECOMMENDS], value );
+         }
+         else if ( key == "SUGGESTS" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::SUGGESTS], value );
+         }
+         else if ( key == "SUPPLEMENTS" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::SUPPLEMENTS], value );
+         }
+         else if ( key == "ENHANCES" )
+         {
+           _pimpl->setDependencies( _pimpl->product().deps[Dep::ENHANCES], value );
+         }
+         else if ( key == "LINGUAS" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "LABEL" )
+         {
+           _pimpl->product().summary.setText( value, Locale(modifier) );
+         }
+         else if ( key == "DESCRDIR" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "DATADIR" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "FLAGS" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "LANGUAGE" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "TIMEZONE" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "META" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "KEY" )
+         {
+           /*unused ?*/;
+         }
+         else if ( key == "VOLATILE_CONTENT" )
+         {
+           /*unused ? add to FLAGS*/;
+         }
+         else
+         { WAR << errPrefix( line.lineNo(), "Unknown tag", *line ) << endl; }
+
+
+         if ( ! ticks.set( input_r.stream().tellg() ) )
+           userRequestedAbort( line.lineNo() );
+       }
+
+       if ( ! ticks.toMax() )
+         userRequestedAbort( line.lineNo() );
+
+       endParse();
+       MIL << "Done parsing " << input_r << endl;
+      }
+
+      /////////////////////////////////////////////////////////////////
+    } // namespace susetags
+    ///////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////
+  } // namespace parser
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/parser/susetags/ContentFileReader.h b/zypp/parser/susetags/ContentFileReader.h
new file mode 100644 (file)
index 0000000..68e1103
--- /dev/null
@@ -0,0 +1,115 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/parser/susetags/ContentFileReader.h
+ *
+*/
+#ifndef ZYPP_PARSER_SUSETAGS_CONTENTFILEREADER_H
+#define ZYPP_PARSER_SUSETAGS_CONTENTFILEREADER_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/Function.h"
+#include "zypp/base/InputStream.h"
+
+#include "zypp/ProgressData.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  namespace data
+  { /////////////////////////////////////////////////////////////////
+    class Product;
+    DEFINE_PTR_TYPE(Product);
+    /////////////////////////////////////////////////////////////////
+  } // namespace data
+  ///////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  namespace parser
+  { /////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////
+    namespace susetags
+    { /////////////////////////////////////////////////////////////////
+
+      class RepoIndex;
+      DEFINE_PTR_TYPE(RepoIndex);
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       CLASS NAME : ContentFileReader
+      //
+      /** */
+      class ContentFileReader
+      {
+       public:
+         typedef function<void(const data::Product_Ptr &)> ProductConsumer;
+         typedef function<void(const RepoIndex_Ptr &)> RepoIndexConsumer;
+
+       public:
+         /** Default ctor */
+         ContentFileReader();
+         /** Dtor */
+         virtual ~ContentFileReader();
+          /** Parse the stream.
+          * \throw ParseExcetion on errors.
+          * \throws AbortRequestException on user request.
+          * Invokes \ref consume for each tag. \ref consume might throw
+          * other exceptions as well.
+          */
+         virtual void parse( const InputStream & imput_r,
+                             const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() );
+
+       public:
+         /** Consumer to call when product data were parsed. */
+         void setProductConsumer( const ProductConsumer & fnc_r )
+         { _productConsumer = fnc_r; }
+
+         /** Consumer to call when repo index was parsed. */
+         void setRepoIndexConsumer( const RepoIndexConsumer & fnc_r )
+         { _repoIndexConsumer = fnc_r; }
+
+       protected:
+         /** Called when start parsing. */
+         virtual void beginParse();
+         /** Called when the parse is done. */
+         virtual void endParse();
+
+       protected:
+          /** Called when user(callback) request to abort.
+          * \throws AbortRequestException unless overloaded.
+          */
+         virtual void userRequestedAbort( unsigned lineNo_r );
+
+       protected:
+         /** Prefix exception message with line information. */
+         std::string errPrefix( unsigned lineNo_r,
+                                const std::string & msg_r = std::string(),
+                                const std::string & line_r = "-" ) const;
+
+       private:
+         class Impl;
+         scoped_ptr<Impl> _pimpl;
+         ProductConsumer _productConsumer;
+         RepoIndexConsumer _repoIndexConsumer;
+      };
+      ///////////////////////////////////////////////////////////////////
+
+      /////////////////////////////////////////////////////////////////
+    } // namespace susetags
+    ///////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////
+  } // namespace parser
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_SUSETAGS_CONTENTFILEREADER_H
index 0911754..4f1c8d4 100644 (file)
@@ -345,7 +345,7 @@ namespace zypp
        else if TAGFWD( Shr );
        else if TAGFWD( Ver );
        else
-       { ERR << tag_r << endl; }
+       { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
       }
 
       ///////////////////////////////////////////////////////////////////
@@ -368,7 +368,7 @@ namespace zypp
        else if TAGFWD( Kwd );
        else if TAGFWD( Aut );
        else
-       { ERR << tag_r << endl; }
+       { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
       }
 
       ///////////////////////////////////////////////////////////////////
index 8dd09ff..dc5ec24 100644 (file)
@@ -203,7 +203,7 @@ namespace zypp
        else if TAGFWD( Sum );
        else if TAGFWD( Ver );
        else
-       { ERR << tag_r << endl; }
+       { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
       }
 
       ///////////////////////////////////////////////////////////////////
@@ -218,7 +218,7 @@ namespace zypp
        else if TAGFWD( Ins );
        else if TAGFWD( Del );
        else
-       { ERR << tag_r << endl; }
+       { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
       }
 
       ///////////////////////////////////////////////////////////////////
index 80844ee..58b9f77 100644 (file)
@@ -292,7 +292,7 @@ namespace zypp
        else if TAGFWD( Ord );
        else if TAGFWD( Ver );
        else
-       { ERR << tag_r << endl; }
+       { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
       }
 
       ///////////////////////////////////////////////////////////////////
@@ -326,7 +326,7 @@ namespace zypp
        else if TAGFWD( Inc ); // UI hint: includes
        else if TAGFWD( Ext ); // UI hint: extends
        else
-       { ERR << tag_r << endl; }
+       { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
       }
 
       ///////////////////////////////////////////////////////////////////
diff --git a/zypp/parser/susetags/RepoIndex.cc b/zypp/parser/susetags/RepoIndex.cc
new file mode 100644 (file)
index 0000000..6c57aac
--- /dev/null
@@ -0,0 +1,39 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/parser/susetags/RepoIndex.cc
+ *
+*/
+#include <iostream>
+//#include "zypp/base/Logger.h"
+
+#include "zypp/parser/susetags/RepoIndex.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace parser
+  { /////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////
+    namespace susetags
+    { /////////////////////////////////////////////////////////////////
+
+      IMPL_PTR_TYPE(RepoIndex);
+
+      /////////////////////////////////////////////////////////////////
+    } // namespace susetags
+    ///////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////
+  } // namespace parser
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/parser/susetags/RepoIndex.h b/zypp/parser/susetags/RepoIndex.h
new file mode 100644 (file)
index 0000000..c717b12
--- /dev/null
@@ -0,0 +1,59 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/parser/susetags/RepoIndex.h
+ *
+*/
+#ifndef ZYPP_PARSER_SUSETAGS_REPOINDEX_H
+#define ZYPP_PARSER_SUSETAGS_REPOINDEX_H
+
+#include <iosfwd>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/PtrTypes.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace parser
+  { /////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////
+    namespace susetags
+    { /////////////////////////////////////////////////////////////////
+
+      DEFINE_PTR_TYPE(RepoIndex);
+
+      ///////////////////////////////////////////////////////////////////
+      //
+      //       CLASS NAME : RepoIndex
+      //
+      /** Repository content data.
+       * File and Checksum definitions required by Downloader and Parser.
+      */
+      class RepoIndex : public base::ReferenceCounted, private base::NonCopyable
+      {
+       public:
+
+       protected:
+         /** Overload to realize std::ostream & operator\<\<. */
+         //virtual std::ostream & dumpOn( std::ostream & str ) const;
+      };
+      ///////////////////////////////////////////////////////////////////
+
+      /////////////////////////////////////////////////////////////////
+    } // namespace susetags
+    ///////////////////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////////////////
+  } // namespace parser
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_SUSETAGS_REPOINDEX_H