## ##################################################
-Main_SOURCES = Main.cc
+Main_SOURCES = Main.cc Packages.cc
Main_debug_SOURCES = $(Main_SOURCES)
Main_debug_LDFLAGS = -static
#include <zypp/base/PtrTypes.h>
#include <zypp/parser/tagfile/Tags.h>
+#include <zypp/NVRA.h>
+
///////////////////////////////////////////////////////////////////
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 );
}
};
////////////////////////////////////////////////////////////////////////////
+
+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> _nvra;
+};
+
+struct X
+{
+ template <typename Item>
+ struct result
+ {
+ typedef rule_t type;
+ };
+
+ template <typename Item>
+ rule_t operator<<( const Item & stag_r ) const
+ {
+ return eps_p;//error_report_p( "neither empty nor comment" );
+ }
+};
+//const phoenix::function<X_impl> XX = X_impl();
+
+////////////////////////////////////////////////////////////////////////////
//
// Main
//
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;
${INDENT}class ${CLASS}
${INDENT}{
${INDENT} friend std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj );
+
${INDENT}public:
${INDENT} /** Implementation */
${INDENT} class Impl;
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 );
- }
/******************************************************************
**
#include "zypp/base/PtrTypes.h"
#include "zypp/Resolvable.h"
-#include "zypp/solver/SolverFwd.h"
///////////////////////////////////////////////////////////////////
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 */
Edition.h \
LanguageCode.h \
Locale.h \
+ NVRA.h \
Rel.h \
ResObject.h \
Resolvable.h \
Edition.cc \
LanguageCode.cc \
Locale.cc \
+ NVRA.cc \
Rel.cc \
ResObject.cc \
Resolvable.cc \
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \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 <iostream>
+//#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
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/solver/Context.cc
+/** \file zypp/NVRA.h
*
*/
-#include <iostream>
+#ifndef ZYPP_NVRA_H
+#define ZYPP_NVRA_H
-#include "zypp/base/Logger.h"
+#include <iosfwd>
+#include <string>
-#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
#include "zypp/base/KindOf.h"
#include "zypp/Resolvable.h" // maybe ResTraits are sufficient?
-#include "zypp/solver/SolverFwd.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
DEFINE_PTR_TYPE(CapabilityImpl)
+ namespace solver
+ {
+ typedef void * Context_constPtr;
+ }
+
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : CapabilityImpl
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/Context.h
- *
-*/
-#ifndef ZYPP_SOLVER_CONTEXT_H
-#define ZYPP_SOLVER_CONTEXT_H
-
-#include <iosfwd>
-
-#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
## ##################################################
-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 =
## ##################################################