From: Michael Andres Date: Mon, 2 Jan 2006 17:15:29 +0000 (+0000) Subject: - added helper struct NVRA X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~3526 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1f315a951358c4d165debd5bad28729b8b2de6a;p=platform%2Fupstream%2Flibzypp.git - added helper struct NVRA - removed unneeded solver::context - removed Capability::matches(). To be replaced by an Iterator visiting all matches in the pool. --- diff --git a/devel/devel.ma/Makefile.am b/devel/devel.ma/Makefile.am index b6cd68f..4cd9389 100644 --- a/devel/devel.ma/Makefile.am +++ b/devel/devel.ma/Makefile.am @@ -16,7 +16,7 @@ LDADD = $(top_srcdir)/zypp/lib@PACKAGE@.la -lboost_regex ## ################################################## -Main_SOURCES = Main.cc +Main_SOURCES = Main.cc Packages.cc Main_debug_SOURCES = $(Main_SOURCES) Main_debug_LDFLAGS = -static diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index 56e373c..82159b4 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -8,6 +8,8 @@ #include #include +#include + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -34,6 +36,10 @@ namespace zypp { echoOn( DBG, first, last, s ); } + void xecho( const char * first, const char *const last, const char* s = "" ) + { + DBG << ">>" << std::string(first,last) << "<< " << std::endl; + } void mecho( iterator_t first, const iterator_t last, const char* s = "" ) { echoOn( MIL, first, last, s ); @@ -79,6 +85,88 @@ struct Measure } }; //////////////////////////////////////////////////////////////////////////// + +NVRA parseNVRA( const std::string & value ) +{ + std::string n; + std::string v; + std::string r; + std::string a; + parse_info<> info = parse( value.c_str(), + + lexeme_d[(+~space_p)] [assign_a(n)] + >> lexeme_d[(+(~space_p & ~ch_p('-')))] [assign_a(v)] + >> lexeme_d[(+(~space_p & ~ch_p('-')))] [assign_a(r)] + >> lexeme_d[(+~space_p)] [assign_a(a)] + , + space_p ); + + NVRA data; + if ( info.full ) + { + data = NVRA( n, Edition(v,r), Arch(a) ); + } + else + { + ERR << "parseNVRA failed on " << value << std::endl; + } + INT << data << endl; + return data; +} + + +struct PConsume +{ + static bool isTag( const Tag & tag_r, const std::string & ident_r ) + { + return tag_r.ident == ident_r && tag_r.ext.empty(); + } + static bool isLangTag( const Tag & tag_r, const std::string & ident_r ) + { + return tag_r.ident == ident_r && ! tag_r.ext.empty(); + } + + bool newPkg( const std::string & value ) + { + NVRA data( parseNVRA( value ) ); + return true; + } + + + PConsume & operator=( const STag & stag_r ) + { + if ( isTag( stag_r.stag, "Pkg" ) ) + { + newPkg( stag_r.value ); + MIL << stag_r << endl; + } + return *this; + } + PConsume & operator=( const MTag & mtag_r ) + { + return *this; + } + + scoped_ptr _nvra; +}; + +struct X +{ + template + struct result + { + typedef rule_t type; + }; + + template + rule_t operator<<( const Item & stag_r ) const + { + return eps_p;//error_report_p( "neither empty nor comment" ); + } +}; +//const phoenix::function XX = X_impl(); + +//////////////////////////////////////////////////////////////////////////// // // Main // @@ -110,16 +198,22 @@ int main( int argc, char* argv[] ) STag stagData; MTag mtagData; + PConsume consume; + rule_t c = eps_p; + rule_t a = nothing_p; + rule_t x = error_report_p( "abort" ); + rule_t file = end_p - | ( stag - | mtag + | ( stag //[var(consume)=arg1] + >> lazy_p(var(x)) + | mtag [var(consume)=arg1] | ( *blank_p >> !( ch_p('#') >> *(anychar_p - eol_p) ) >> (eol_p|end_p) - | error_report_p( "neither empty nor comment" ) ) + | error_report_p( "neither empty nor comment" ) ) >> file; diff --git a/devel/genclass.in b/devel/genclass.in index e46288e..2cf8229 100644 --- a/devel/genclass.in +++ b/devel/genclass.in @@ -113,6 +113,7 @@ ${INDENT}/** */ ${INDENT}class ${CLASS} ${INDENT}{ ${INDENT} friend std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj ); + ${INDENT}public: ${INDENT} /** Implementation */ ${INDENT} class Impl; diff --git a/zypp/Capability.cc b/zypp/Capability.cc index ba7f7a7..cb45bea 100644 --- a/zypp/Capability.cc +++ b/zypp/Capability.cc @@ -53,15 +53,7 @@ namespace zypp std::string Capability::asString() const { return _pimpl->asString(); } - bool Capability::matches( Resolvable::constPtr resolvable_r, - solver::Context_constPtr solverContext_r ) const - { return _pimpl->matches( resolvable_r, solverContext_r ); } - bool Capability::matches( Resolvable::constPtr resolvable_r ) const - { - // NULL: actually a default context needed - return _pimpl->matches( resolvable_r, NULL ); - } /****************************************************************** ** diff --git a/zypp/Capability.h b/zypp/Capability.h index b40a2d1..91f81cf 100644 --- a/zypp/Capability.h +++ b/zypp/Capability.h @@ -18,7 +18,6 @@ #include "zypp/base/PtrTypes.h" #include "zypp/Resolvable.h" -#include "zypp/solver/SolverFwd.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -105,11 +104,7 @@ namespace zypp std::string asString() const; /** */ - bool matches( Resolvable::constPtr resolvable_r, - solver::Context_constPtr solverContext_r ) const; - /** \todo this does not make sense until ther's a default context available*/ - bool matches( Resolvable::constPtr resolvable_r ) const; private: /** Pointer to implementation */ diff --git a/zypp/Makefile.am b/zypp/Makefile.am index 5fc1e08..7c7f2a6 100644 --- a/zypp/Makefile.am +++ b/zypp/Makefile.am @@ -17,6 +17,7 @@ include_HEADERS = NeedAType.h \ Edition.h \ LanguageCode.h \ Locale.h \ + NVRA.h \ Rel.h \ ResObject.h \ Resolvable.h \ @@ -56,6 +57,7 @@ lib@PACKAGE@_la_SOURCES = \ Edition.cc \ LanguageCode.cc \ Locale.cc \ + NVRA.cc \ Rel.cc \ ResObject.cc \ Resolvable.cc \ diff --git a/zypp/solver/SolverFwd.h b/zypp/NVRA.cc similarity index 70% rename from zypp/solver/SolverFwd.h rename to zypp/NVRA.cc index 976f4b5..96d7e84 100644 --- a/zypp/solver/SolverFwd.h +++ b/zypp/NVRA.cc @@ -6,27 +6,36 @@ | /_____||_| |_| |_| | | | \---------------------------------------------------------------------*/ -/** \file zypp/solver/SolverFwd.h - * - * Forward declaration of Solver related public types. +/** \file zypp/NVRA.cc * */ -#ifndef ZYPP_SOLVER_SOLVERFWD_H -#define ZYPP_SOLVER_SOLVERFWD_H +#include +//#include "zypp/base/Logger.h" + +#include "zypp/NVRA.h" + +using std::endl; /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : NVRA + // /////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(Context); + /****************************************************************** + ** + ** FUNCTION NAME : operator<< + ** FUNCTION TYPE : std::ostream & + */ + std::ostream & operator<<( std::ostream & str, const NVRA & obj ) + { + return str << obj.name << '-' << obj.edition << '.' << obj.arch; + } - ///////////////////////////////////////////////////////////////// - } // namespace solver - /////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_SOLVERFWD_H diff --git a/zypp/solver/Context.cc b/zypp/NVRA.h similarity index 52% rename from zypp/solver/Context.cc rename to zypp/NVRA.h index 846ea3b..f84b9a3 100644 --- a/zypp/solver/Context.cc +++ b/zypp/NVRA.h @@ -6,55 +6,57 @@ | /_____||_| |_| |_| | | | \---------------------------------------------------------------------*/ -/** \file zypp/solver/Context.cc +/** \file zypp/NVRA.h * */ -#include +#ifndef ZYPP_NVRA_H +#define ZYPP_NVRA_H -#include "zypp/base/Logger.h" +#include +#include -#include "zypp/solver/Context.h" - -using namespace std; +#include "zypp/base/PtrTypes.h" +#include "zypp/Edition.h" +#include "zypp/Arch.h" /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////// - IMPL_PTR_TYPE(Context); - - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : Context::Context - // METHOD TYPE : Ctor - // - Context::Context() + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : NVRA + // + /** */ + struct NVRA + { + /** Default ctor */ + NVRA() {} - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : Context::~Context - // METHOD TYPE : Dtor - // - Context::~Context() + /** Ctor */ + explicit + NVRA( const std::string & name_r, + const Edition & edition_r = Edition(), + const Arch & arch_r = Arch() ) + : name( name_r ) + , edition( edition_r ) + , arch( arch_r ) {} - /****************************************************************** - ** - ** FUNCTION NAME : operator<< - ** FUNCTION TYPE : std::ostream & - */ - std::ostream & operator<<( std::ostream & str, const Context & obj ) - { - return str; - } - - ///////////////////////////////////////////////////////////////// - } // namespace solver + /** */ + std::string name; + /** */ + Edition edition; + /** */ + Arch arch; + }; /////////////////////////////////////////////////////////////////// + + /** \relates NVRA Stream output */ + std::ostream & operator<<( std::ostream & str, const NVRA & obj ); + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// +#endif // ZYPP_NVRA_H diff --git a/zypp/capability/CapabilityImpl.h b/zypp/capability/CapabilityImpl.h index a7c0e0e..b376785 100644 --- a/zypp/capability/CapabilityImpl.h +++ b/zypp/capability/CapabilityImpl.h @@ -17,7 +17,6 @@ #include "zypp/base/KindOf.h" #include "zypp/Resolvable.h" // maybe ResTraits are sufficient? -#include "zypp/solver/SolverFwd.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -27,6 +26,12 @@ namespace zypp { ///////////////////////////////////////////////////////////////// DEFINE_PTR_TYPE(CapabilityImpl) + namespace solver + { + typedef void * Context_constPtr; + } + + /////////////////////////////////////////////////////////////////// // // CLASS NAME : CapabilityImpl diff --git a/zypp/solver/Context.h b/zypp/solver/Context.h deleted file mode 100644 index 3912c7e..0000000 --- a/zypp/solver/Context.h +++ /dev/null @@ -1,61 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/solver/Context.h - * -*/ -#ifndef ZYPP_SOLVER_CONTEXT_H -#define ZYPP_SOLVER_CONTEXT_H - -#include - -#include "zypp/base/ReferenceCounted.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/SolverFwd.h" - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : Context - // - /** Solver context. - */ - class Context : public base::ReferenceCounted, private base::NonCopyable - { - public: - typedef Context Self; - typedef Context_Ptr Ptr; - typedef Context_constPtr constPtr; - friend std::ostream & operator<<( std::ostream & str, const Context & obj ); - - public: - /** Default ctor */ - Context(); - /** Dtor */ - ~Context(); - }; - /////////////////////////////////////////////////////////////////// - - /** \relates Context Stream output */ - extern std::ostream & operator<<( std::ostream & str, const Context & obj ); - - ///////////////////////////////////////////////////////////////// - } // namespace solver - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_CONTEXT_H diff --git a/zypp/solver/Makefile.am b/zypp/solver/Makefile.am index 19a2100..263f7ed 100644 --- a/zypp/solver/Makefile.am +++ b/zypp/solver/Makefile.am @@ -6,15 +6,12 @@ SUBDIRS = ## ################################################## -include_HEADERS = \ - SolverFwd.h \ - Context.h +include_HEADERS = noinst_LTLIBRARIES = lib@PACKAGE@_solver.la ## ################################################## -lib@PACKAGE@_solver_la_SOURCES = \ - Context.cc +lib@PACKAGE@_solver_la_SOURCES = ## ##################################################