Mailinglist Archive: zypp-devel (68 mails)
| < Previous | Next > |
[zypp-devel] Re: [zypp-commit] r5561 - in /trunk/libzypp: devel/devel.ma/ zypp/ zypp/parser/ zypp/parser/susetags/
- From: Stanislav Visnovsky <visnov@xxxxxxx>
- Date: Thu, 17 May 2007 11:56:25 +0200
- Message-id: <200705171156.26273.visnov@xxxxxxx>
Dňa St 16. Máj 2007 21:47 mlandres@xxxxxxxxxxxxxxxx napísal:
> Author: mlandres
> Date: Wed May 16 21:47:19 2007
> New Revision: 5561
>
> URL: http://svn.opensuse.org/viewcvs/zypp?rev=5561&view=rev
> Log:
> - Parser update
> - added class ZConfig
Did anyone review the added classes?
Stano
>
> Added:
> trunk/libzypp/zypp/ZConfig.cc
> trunk/libzypp/zypp/ZConfig.h
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.h
> trunk/libzypp/zypp/parser/susetags/RepoIndex.cc
> trunk/libzypp/zypp/parser/susetags/RepoIndex.h
> Modified:
> trunk/libzypp/devel/devel.ma/Parse.cc
> trunk/libzypp/zypp/CMakeLists.txt
> trunk/libzypp/zypp/parser/TagParser.cc
> trunk/libzypp/zypp/parser/TagParser.h
> trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc
> trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc
>
> Modified: trunk/libzypp/devel/devel.ma/Parse.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Parse.cc?
>rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/devel/devel.ma/Parse.cc (original)
> +++ trunk/libzypp/devel/devel.ma/Parse.cc Wed May 16 21:47:19 2007
> @@ -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 @@
> }
>
> #include "zypp/ProgressData.h"
> -
> +#include "zypp2/cache/CacheStore.h"
> ///////////////////////////////////////////////////////////////////
> namespace zypp
> { /////////////////////////////////////////////////////////////////
> @@ -133,14 +135,72 @@
> ///////////////////////////////////////////////////////////////////
> 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 @@
> ///////////////////////////////////////////////////////////////////
>
> 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 @@
> //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 << "===[END]============================================" << endl <<
> endl; zypp::base::LogControl::instance().logNothing();
> return 0;
> -#endif
>
> Pathname proot( "lmd/suse/setup/descr" );
>
>
> Modified: trunk/libzypp/zypp/CMakeLists.txt
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=
>5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/CMakeLists.txt (original)
> +++ trunk/libzypp/zypp/CMakeLists.txt Wed May 16 21:47:19 2007
> @@ -11,6 +11,7 @@
> ADD_DEFINITIONS(-DLOCALEDIR=\\\"/usr/share/libzypp\\\"
> -DTEXTDOMAIN=\\\"zypp\\\" )
>
> SET( zypp_SRCS
> + ZConfig.cc
> LanguageCode.cc
> Arch.cc
> Atom.cc
> @@ -87,7 +88,8 @@
> Fetcher.cc
> )
>
> -SET( zypp_HEADERS
> +SET( zypp_HEADERSZ
> + ZConfig.h
> Arch.h
> Atom.h
> AutoDispose.h
> @@ -448,12 +450,16 @@
> )
>
> 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
>
> Added: trunk/libzypp/zypp/ZConfig.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=5561
>&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/ZConfig.cc (added)
> +++ trunk/libzypp/zypp/ZConfig.cc Wed May 16 21:47:19 2007
> @@ -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
> +///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/ZConfig.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=5561&
>view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/ZConfig.h (added)
> +++ trunk/libzypp/zypp/ZConfig.h Wed May 16 21:47:19 2007
> @@ -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
>
> Modified: trunk/libzypp/zypp/parser/TagParser.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/TagParser.cc
>?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/TagParser.cc (original)
> +++ trunk/libzypp/zypp/parser/TagParser.cc Wed May 16 21:47:19 2007
> @@ -126,7 +126,7 @@
> 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 @@
> break;
> }
>
> -
> if ( ! ticks.set( input_r.stream().tellg() ) )
> userRequestedAbort( line.lineNo() );
> }
>
> Modified: trunk/libzypp/zypp/parser/TagParser.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/TagParser.h?
>rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/TagParser.h (original)
> +++ trunk/libzypp/zypp/parser/TagParser.h Wed May 16 21:47:19 2007
> @@ -87,7 +87,7 @@
> * 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:
>
> Added: trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Con
>tentFileReader.cc?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc (added) +++
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc Wed May 16 21:47:19
> 2007 @@ -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
> +///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/parser/susetags/ContentFileReader.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Con
>tentFileReader.h?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/ContentFileReader.h (added) +++
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.h Wed May 16 21:47:19
> 2007 @@ -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
>
> Modified: trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Pac
>kagesFileReader.cc?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc (original)
> +++ trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc Wed May 16
> 21:47:19 2007 @@ -345,7 +345,7 @@
> else if TAGFWD( Shr );
> else if TAGFWD( Ver );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
> @@ -368,7 +368,7 @@
> else if TAGFWD( Kwd );
> else if TAGFWD( Aut );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
>
> Modified: trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Pac
>kagesLangFileReader.cc?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> (original) +++ trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> Wed May 16 21:47:19 2007 @@ -203,7 +203,7 @@
> else if TAGFWD( Sum );
> else if TAGFWD( Ver );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
> @@ -218,7 +218,7 @@
> else if TAGFWD( Ins );
> else if TAGFWD( Del );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
>
> Modified: trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Pat
>ternFileReader.cc?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc (original)
> +++ trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc Wed May 16
> 21:47:19 2007 @@ -292,7 +292,7 @@
> else if TAGFWD( Ord );
> else if TAGFWD( Ver );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
> @@ -326,7 +326,7 @@
> 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; }
> }
>
> ///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/parser/susetags/RepoIndex.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Rep
>oIndex.cc?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/RepoIndex.cc (added)
> +++ trunk/libzypp/zypp/parser/susetags/RepoIndex.cc Wed May 16 21:47:19
> 2007 @@ -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
> +///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/parser/susetags/RepoIndex.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Rep
>oIndex.h?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/RepoIndex.h (added)
> +++ trunk/libzypp/zypp/parser/susetags/RepoIndex.h Wed May 16 21:47:19 2007
> @@ -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
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
> Author: mlandres
> Date: Wed May 16 21:47:19 2007
> New Revision: 5561
>
> URL: http://svn.opensuse.org/viewcvs/zypp?rev=5561&view=rev
> Log:
> - Parser update
> - added class ZConfig
Did anyone review the added classes?
Stano
>
> Added:
> trunk/libzypp/zypp/ZConfig.cc
> trunk/libzypp/zypp/ZConfig.h
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.h
> trunk/libzypp/zypp/parser/susetags/RepoIndex.cc
> trunk/libzypp/zypp/parser/susetags/RepoIndex.h
> Modified:
> trunk/libzypp/devel/devel.ma/Parse.cc
> trunk/libzypp/zypp/CMakeLists.txt
> trunk/libzypp/zypp/parser/TagParser.cc
> trunk/libzypp/zypp/parser/TagParser.h
> trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc
> trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc
>
> Modified: trunk/libzypp/devel/devel.ma/Parse.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Parse.cc?
>rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/devel/devel.ma/Parse.cc (original)
> +++ trunk/libzypp/devel/devel.ma/Parse.cc Wed May 16 21:47:19 2007
> @@ -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 @@
> }
>
> #include "zypp/ProgressData.h"
> -
> +#include "zypp2/cache/CacheStore.h"
> ///////////////////////////////////////////////////////////////////
> namespace zypp
> { /////////////////////////////////////////////////////////////////
> @@ -133,14 +135,72 @@
> ///////////////////////////////////////////////////////////////////
> 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 @@
> ///////////////////////////////////////////////////////////////////
>
> 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 @@
> //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 << "===[END]============================================" << endl <<
> endl; zypp::base::LogControl::instance().logNothing();
> return 0;
> -#endif
>
> Pathname proot( "lmd/suse/setup/descr" );
>
>
> Modified: trunk/libzypp/zypp/CMakeLists.txt
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=
>5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/CMakeLists.txt (original)
> +++ trunk/libzypp/zypp/CMakeLists.txt Wed May 16 21:47:19 2007
> @@ -11,6 +11,7 @@
> ADD_DEFINITIONS(-DLOCALEDIR=\\\"/usr/share/libzypp\\\"
> -DTEXTDOMAIN=\\\"zypp\\\" )
>
> SET( zypp_SRCS
> + ZConfig.cc
> LanguageCode.cc
> Arch.cc
> Atom.cc
> @@ -87,7 +88,8 @@
> Fetcher.cc
> )
>
> -SET( zypp_HEADERS
> +SET( zypp_HEADERSZ
> + ZConfig.h
> Arch.h
> Atom.h
> AutoDispose.h
> @@ -448,12 +450,16 @@
> )
>
> 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
>
> Added: trunk/libzypp/zypp/ZConfig.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=5561
>&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/ZConfig.cc (added)
> +++ trunk/libzypp/zypp/ZConfig.cc Wed May 16 21:47:19 2007
> @@ -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
> +///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/ZConfig.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=5561&
>view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/ZConfig.h (added)
> +++ trunk/libzypp/zypp/ZConfig.h Wed May 16 21:47:19 2007
> @@ -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
>
> Modified: trunk/libzypp/zypp/parser/TagParser.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/TagParser.cc
>?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/TagParser.cc (original)
> +++ trunk/libzypp/zypp/parser/TagParser.cc Wed May 16 21:47:19 2007
> @@ -126,7 +126,7 @@
> 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 @@
> break;
> }
>
> -
> if ( ! ticks.set( input_r.stream().tellg() ) )
> userRequestedAbort( line.lineNo() );
> }
>
> Modified: trunk/libzypp/zypp/parser/TagParser.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/TagParser.h?
>rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/TagParser.h (original)
> +++ trunk/libzypp/zypp/parser/TagParser.h Wed May 16 21:47:19 2007
> @@ -87,7 +87,7 @@
> * 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:
>
> Added: trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Con
>tentFileReader.cc?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc (added) +++
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc Wed May 16 21:47:19
> 2007 @@ -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
> +///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/parser/susetags/ContentFileReader.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Con
>tentFileReader.h?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/ContentFileReader.h (added) +++
> trunk/libzypp/zypp/parser/susetags/ContentFileReader.h Wed May 16 21:47:19
> 2007 @@ -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
>
> Modified: trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Pac
>kagesFileReader.cc?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc (original)
> +++ trunk/libzypp/zypp/parser/susetags/PackagesFileReader.cc Wed May 16
> 21:47:19 2007 @@ -345,7 +345,7 @@
> else if TAGFWD( Shr );
> else if TAGFWD( Ver );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
> @@ -368,7 +368,7 @@
> else if TAGFWD( Kwd );
> else if TAGFWD( Aut );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
>
> Modified: trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Pac
>kagesLangFileReader.cc?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> (original) +++ trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.cc
> Wed May 16 21:47:19 2007 @@ -203,7 +203,7 @@
> else if TAGFWD( Sum );
> else if TAGFWD( Ver );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
> @@ -218,7 +218,7 @@
> else if TAGFWD( Ins );
> else if TAGFWD( Del );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
>
> Modified: trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Pat
>ternFileReader.cc?rev=5561&r1=5560&r2=5561&view=diff
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc (original)
> +++ trunk/libzypp/zypp/parser/susetags/PatternFileReader.cc Wed May 16
> 21:47:19 2007 @@ -292,7 +292,7 @@
> else if TAGFWD( Ord );
> else if TAGFWD( Ver );
> else
> - { ERR << tag_r << endl; }
> + { WAR << errPrefix( tag_r, "Unknown tag" ) << endl; }
> }
>
> ///////////////////////////////////////////////////////////////////
> @@ -326,7 +326,7 @@
> 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; }
> }
>
> ///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/parser/susetags/RepoIndex.cc
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Rep
>oIndex.cc?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/RepoIndex.cc (added)
> +++ trunk/libzypp/zypp/parser/susetags/RepoIndex.cc Wed May 16 21:47:19
> 2007 @@ -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
> +///////////////////////////////////////////////////////////////////
>
> Added: trunk/libzypp/zypp/parser/susetags/RepoIndex.h
> URL:
> http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/Rep
>oIndex.h?rev=5561&view=auto
> ===========================================================================
>=== --- trunk/libzypp/zypp/parser/susetags/RepoIndex.h (added)
> +++ trunk/libzypp/zypp/parser/susetags/RepoIndex.h Wed May 16 21:47:19 2007
> @@ -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
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
| < Previous | Next > |