#include <list>
#include <set>
-#include "Printing.h"
+#include "Tools.h"
#include <zypp/base/LogControl.h>
-#include <zypp/base/String.h>
-#include <zypp/base/Exception.h>
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/Iterator.h>
-#include <zypp/base/Algorithm.h>
-
-#include <zypp/Arch.h>
+#include <zypp/ResStatus.h>
using namespace std;
using namespace zypp;
-using namespace zypp::functor;
-
-inline const char * compResult( int res )
-{
- return( res ? ( res < 0 ? "<" : ">" ) : "=" );
-}
-
-template<class _Iter, class _Function>
- inline void sym_compare( _Iter begin, _Iter end, _Function fnc )
- {
- for ( _Iter l = begin; l != end; ++l )
- for ( _Iter r = begin; r != end; ++r )
- fnc( *l, *r );
- }
-
-template<class _LIter, class _RIter, class _BinaryFunction>
- inline _BinaryFunction
- nest_for_earch( _LIter lbegin, _LIter lend,
- _RIter rbegin, _RIter rend,
- _BinaryFunction fnc )
- {
- for ( ; lbegin != lend; ++lbegin )
- for ( _RIter r = rbegin; r != rend; ++r )
- fnc( *lbegin, *r );
- return fnc;
- }
-
-template<class _Iter, class _BinaryFunction>
- inline _BinaryFunction
- nest_for_earch( _Iter begin, _Iter end,
- _BinaryFunction fnc )
- { return nest_for_earch( begin, end, begin, end, fnc ); }
-
-
-template<class _Iter, class _Function>
- inline void sym_compare( _Iter begin, _Iter end )
- {
- sym_compare( begin, end, _Function() );
- }
-
-inline list<Arch> archList()
-{
- list<Arch> ret;
- ret.push_back( Arch_noarch );
- ret.push_back( Arch_src );
- ret.push_back( Arch_x86_64 );
- ret.push_back( Arch_athlon );
- ret.push_back( Arch_i686 );
- ret.push_back( Arch_i586 );
- ret.push_back( Arch_i486 );
- ret.push_back( Arch_i386 );
- ret.push_back( Arch_s390x );
- ret.push_back( Arch_s390 );
- ret.push_back( Arch_ppc64 );
- ret.push_back( Arch_ppc );
- ret.push_back( Arch_ia64 );
- ret.push_back( Arch( "unknown" ) );
- ret.push_back( Arch( "unknown2" ) );
- ret.push_back( Arch() );
- ret.push_back( Arch("") );
- return ret;
-}
-
-static list<Arch> archlist( archList() );
-static set<Arch> archset( archlist.begin(), archlist.end() );
-
-struct CompatTest
-{
- void operator()( const Arch & lhs, const Arch & rhs ) const
- {
- DBG << str::form( "%-10s --> %-10s : %6s : %s",
- lhs.asString().c_str(),
- rhs.asString().c_str(),
- ( lhs.compatibleWith( rhs ) ? "COMPAT" : "no" ),
- compResult( lhs.compare( rhs ) ) )
-
- << std::endl;
- }
-};
-
-struct OrderByCompare : public std::binary_function<Arch, Arch, bool>
-{
- bool operator()( const Arch & lhs, const Arch & rhs ) const
- { return lhs.compare( rhs ) < 0; }
-};
/******************************************************************
**
{
INT << "===[START]==========================================" << endl;
- // All archs in test
- print( archlist );
+ ResStatus stat;
+ MIL << stat << endl;
+
+ DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW )
+ << ' ' << stat << endl;
+
+ DBG << stat.setTransact( false, ResStatus::APPL_LOW )
+ << ' ' << stat << endl;
- // set ordering
- print( archset );
+ DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW )
+ << ' ' << stat << endl;
- // compatibleWith
- sym_compare( archset.begin(), archset.end(), CompatTest() );
+ DBG << stat.setTransact( false, ResStatus::APPL_HIGH )
+ << ' ' << stat << endl;
- // compare order
- typedef set<Arch,OrderByCompare> OrderedArch;
+ DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW )
+ << ' ' << stat << endl;
- OrderedArch a( archset.begin(), archset.end() );
- print( a );
- OrderedArch b( archset.rbegin(), archset.rend() );
- print( b );
INT << "===[END]============================================" << endl << endl;
return 0;
#include "zypp/ResPool.h"
#include "zypp/ResFilters.h"
#include "zypp/CapFilters.h"
+#include "zypp/Package.h"
+#include <zypp/SourceManager.h>
#include <zypp/SourceFactory.h>
#include <zypp/source/susetags/SuseTagsImpl.h>
} // namespace zypp
///////////////////////////////////////////////////////////////////
-struct X : public base::ProvideNumericId<X>
+struct X : public base::ProvideNumericId<X,unsigned>
{
};
bool operator()( const ui::Selectable::Ptr & obj )
{
if ( obj ) {
+ obj->set_status( ui::S_Install );
USR << *obj << std::endl;
std::for_each( obj->availableBegin(), obj->availableEnd(),
PrintPtr<ResObject::constPtr>() );
+ if ( obj->availableBegin() != obj->availableEnd() )
+ SEC << PrintPtr<ResObject::constPtr>()(*obj->availableBegin() )
+ << " " << asKind<Package>(*obj->availableBegin())->vendor() << endl;
}
else
USR << "(NULL)" << std::endl;
return true;
}
};
+
/******************************************************************
**
** FUNCTION NAME : main
if (argc >= 2 )
infile = argv[1];
- Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/SOURCE") );
+ DBG << Source_Ref() << endl;
+ DBG << Source_Ref::noSource << endl;
+ Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma") );
+ DBG << *SourceManager::sourceManager() << endl;
+ SourceManager::sourceManager()->addSource( src );
+ SourceManager::sourceManager()->removeSource( 0 );
+ SourceManager::sourceManager()->removeSource( src.numericId() );
+ return 0;
+
+ //Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma") );
+ //Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/SOURCE") );
Source_Ref trg( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/TARGET") );
ResPoolManager pool;
std::for_each( query.begin(), query.end(), Print<PoolItem>() );
ResPoolProxy y2pm( query );
+ y2pm.saveState<Package>();
std::for_each( y2pm.byKindBegin<Package>(), y2pm.byKindEnd<Package>(),
PrintPtr<ui::Selectable::Ptr>() );
+
+ y2pm.saveState<Package>();
+ SEC << y2pm.diffState<Package>() << endl;
+
+
INT << "===[END]============================================" << endl << endl;
return 0;
}
--- /dev/null
+#include <iostream>
+
+#include "zypp/base/LogControl.h"
+
+#include "zypp/Locale.h"
+
+
+using std::endl;
+using namespace zypp;
+
+inline std::string vstr( const char * str )
+{
+ std::string ret;
+ if ( str )
+ {
+ ret+="\"";
+ ret+=str;
+ ret+="\"";
+ }
+ return ret;
+}
+
+void test( const Locale & val_r )
+{
+ DBG << " <<: " << (val_r) << endl;
+ DBG << " code: " << (val_r.code()) << endl;
+ DBG << " name: " << (val_r.name()) << endl;
+ DBG << " ==noCode: " << (val_r == Locale::noCode) << endl;
+ DBG << " !=noCode: " << (val_r != Locale::noCode) << endl;
+ DBG << " Language: " << (val_r.language()) << endl;
+ DBG << " Country: " << (val_r.country()) << endl;
+}
+
+void test( const LanguageCode & val_r )
+{
+ DBG << " <<: " << (val_r) << endl;
+ DBG << " code: " << (val_r.code()) << endl;
+ DBG << " name: " << (val_r.name()) << endl;
+ DBG << " ==noCode: " << (val_r == LanguageCode::noCode) << endl;
+ DBG << " !=noCode: " << (val_r != LanguageCode::noCode) << endl;
+ DBG << " ==default: " << (val_r == LanguageCode::useDefault) << endl;
+ DBG << " !=default: " << (val_r != LanguageCode::useDefault) << endl;
+}
+
+void test( const CountryCode & val_r )
+{
+ DBG << " <<: " << (val_r) << endl;
+ DBG << " code: " << (val_r.code()) << endl;
+ DBG << " name: " << (val_r.name()) << endl;
+ DBG << " ==noCode: " << (val_r == CountryCode::noCode) << endl;
+ DBG << " !=noCode: " << (val_r != CountryCode::noCode) << endl;
+}
+
+void testLocale( const char * str = 0 )
+{
+ MIL << "Locale(" << vstr(str) << ")" << endl;
+ test( str ? Locale( str ) : Locale() );
+}
+
+void testLanguage( const char * str = 0 )
+{
+ MIL << "Language(" << vstr(str) << ")" << endl;
+ test( str ? LanguageCode( str ) : LanguageCode() );
+}
+
+void testCountry( const char * str = 0 )
+{
+ MIL << "Country(" << vstr(str) << ")" << endl;
+ test( str ? CountryCode( str ) : CountryCode() );
+}
+
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+ //zypp::base::LogControl::instance().logfile( "xxx" );
+ INT << "===[START]==========================================" << endl;
+
+ testLocale();
+ testLocale( "" );
+ testLocale( "en" );
+ testLocale( "de_DE" );
+ testLocale( "C" );
+ testLocale( "POSIX" );
+ testLocale( "default" );
+
+ testLanguage();
+ testLanguage( "" );
+ testLanguage( "en" );
+ testLanguage( "default" );
+
+ testCountry();
+ testCountry( "" );
+ testCountry( "US" );
+ testCountry( "DE" );
+
+ INT << "===[END]============================================" << endl;
+ return 0;
+}
///////////////////////////////////////////////////////////////////
inline Source_Ref createSource( const std::string & url_r )
{
+ Source_Ref ret;
Measure x( "createSource: " + url_r );
- Source_Ref ret( SourceFactory().createFrom( Url(url_r) ) );
+ try
+ {
+ ret = SourceFactory().createFrom( Url(url_r) );
+ }
+ catch ( const Exception & )
+ {
+ return Source_Ref::noSource;
+ }
x.start( "parseSource: " + url_r );
ret.resolvables();
x.stop();
+ MIL << "Content " << ret << "{" << endl;
rstats( ret.resolvables() );
+ MIL << "}" << endl;
return ret;
}
#$MAKE -C ../../zypp || exit 1
$MAKE $PRG || exit 1
+export ZYPP_LOGFILE=-
./$PRG "$@" 2> $LPIPE
using std::string;
using std::map;
-struct Resolvable::Impl
-{
- string _kind;
-};
-
-Resolvable::Resolvable( const string kind_r /*NVRA*/ )
-: _impl( new Impl )
-{
- _impl->_kind = kind_r;
-}
-Resolvable::~Resolvable()
-{}
-std::ostream & Resolvable::dumpOn( std::ostream & str ) const
-{
- return str << '[' << kind() << ']' << name();
-}
-
-string Resolvable::kind() const { return _impl->_kind; }
-string Resolvable::name() const { return "n"; }
-
-
-Object::Object( const string kind_r /*NVRA*/ )
-: Resolvable( kind_r )
-{}
-Object::~Object()
-{}
-
-string Object::summary() const { return impl().summary(); }
-list<string> Object::description() const { return impl().description(); }
-
-
-Package::Package( /*NVRA*/ )
-: Object( "Package" /*NVRA*/ )
-{}
-Package::~Package()
{}
string Package::packagedata() const { return impl().packagedata(); }
#include "Printing.h"
-#include <zypp/base/Logger.h>
+#include <zypp/base/LogControl.h>
#include <zypp/base/String.h>
#include <zypp/base/Exception.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/Algorithm.h>
#include <zypp/Arch.h>
+#include <zypp/Bit.h>
+#include <zypp/RelCompare.h>
using namespace std;
using namespace zypp;
for ( _Iter r = begin; r != end; ++r )
fnc( *l, *r );
}
+
+template<class _LIter, class _RIter, class _BinaryFunction>
+ inline _BinaryFunction
+ nest_for_earch( _LIter lbegin, _LIter lend,
+ _RIter rbegin, _RIter rend,
+ _BinaryFunction fnc )
+ {
+ for ( ; lbegin != lend; ++lbegin )
+ for ( _RIter r = rbegin; r != rend; ++r )
+ fnc( *lbegin, *r );
+ return fnc;
+ }
+
+template<class _Iter, class _BinaryFunction>
+ inline _BinaryFunction
+ nest_for_earch( _Iter begin, _Iter end,
+ _BinaryFunction fnc )
+ { return nest_for_earch( begin, end, begin, end, fnc ); }
+
+
template<class _Iter, class _Function>
inline void sym_compare( _Iter begin, _Iter end )
{
ret.push_back( Arch( "unknown" ) );
ret.push_back( Arch( "unknown2" ) );
ret.push_back( Arch() );
+ ret.push_back( Arch("") );
return ret;
}
{ return lhs.compare( rhs ) < 0; }
};
+
+void dumpOn( const Arch::CompatSet & s )
+{
+ SEC << str::join( make_transform_iterator( s.begin(), std::mem_fun_ref(&Arch::asString) ),
+ make_transform_iterator( s.end(), std::mem_fun_ref(&Arch::asString) ) )
+ << endl;
+}
+
/******************************************************************
**
** FUNCTION NAME : main
OrderedArch b( archset.rbegin(), archset.rend() );
print( b );
+ dumpOn( Arch::compatSet( Arch_noarch ) );
+ dumpOn( Arch::compatSet( Arch_i486 ) );
+ dumpOn( Arch::compatSet( Arch_x86_64 ) );
+ dumpOn( Arch::compatSet( Arch("Foo") ) );
+
+ typedef set<Arch,CompareByGT<Arch> > AS;
+ Arch::CompatSet x( Arch::compatSet(Arch_x86_64) );
+ AS rx( x.begin(), x.end() );
+ INT << str::join( make_transform_iterator( rx.begin(), std::mem_fun_ref(&Arch::asString) ),
+ make_transform_iterator( rx.end(), std::mem_fun_ref(&Arch::asString) ) )
+ << endl;
+
+
INT << "===[END]============================================" << endl << endl;
return 0;
}
--- /dev/null
+#include <iostream>
+
+#include "zypp/base/LogControl.h"
+
+#include "zypp/Locale.h"
+
+
+using std::endl;
+using namespace zypp;
+
+inline std::string vstr( const char * str )
+{
+ std::string ret;
+ if ( str )
+ {
+ ret+="\"";
+ ret+=str;
+ ret+="\"";
+ }
+ return ret;
+}
+
+void test( const Locale & val_r )
+{
+ DBG << " <<: " << (val_r) << endl;
+ DBG << " code: " << (val_r.code()) << endl;
+ DBG << " name: " << (val_r.name()) << endl;
+ DBG << " ==noCode: " << (val_r == Locale::noCode) << endl;
+ DBG << " !=noCode: " << (val_r != Locale::noCode) << endl;
+ DBG << " Language: " << (val_r.language()) << endl;
+ DBG << " Country: " << (val_r.country()) << endl;
+}
+
+void test( const LanguageCode & val_r )
+{
+ DBG << " <<: " << (val_r) << endl;
+ DBG << " code: " << (val_r.code()) << endl;
+ DBG << " name: " << (val_r.name()) << endl;
+ DBG << " ==noCode: " << (val_r == LanguageCode::noCode) << endl;
+ DBG << " !=noCode: " << (val_r != LanguageCode::noCode) << endl;
+ DBG << " ==default: " << (val_r == LanguageCode::useDefault) << endl;
+ DBG << " !=default: " << (val_r != LanguageCode::useDefault) << endl;
+}
+
+void test( const CountryCode & val_r )
+{
+ DBG << " <<: " << (val_r) << endl;
+ DBG << " code: " << (val_r.code()) << endl;
+ DBG << " name: " << (val_r.name()) << endl;
+ DBG << " ==noCode: " << (val_r == CountryCode::noCode) << endl;
+ DBG << " !=noCode: " << (val_r != CountryCode::noCode) << endl;
+}
+
+void testLocale( const char * str = 0 )
+{
+ MIL << "Locale(" << vstr(str) << ")" << endl;
+ test( str ? Locale( str ) : Locale() );
+}
+
+void testLanguage( const char * str = 0 )
+{
+ MIL << "Language(" << vstr(str) << ")" << endl;
+ test( str ? LanguageCode( str ) : LanguageCode() );
+}
+
+void testCountry( const char * str = 0 )
+{
+ MIL << "Country(" << vstr(str) << ")" << endl;
+ test( str ? CountryCode( str ) : CountryCode() );
+}
+
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+ //zypp::base::LogControl::instance().logfile( "xxx" );
+ INT << "===[START]==========================================" << endl;
+
+ testLocale();
+ testLocale( "" );
+ testLocale( "en" );
+ testLocale( "de_DE" );
+ testLocale( "C" );
+ testLocale( "POSIX" );
+ testLocale( "default" );
+
+ testLanguage();
+ testLanguage( "" );
+ testLanguage( "en" );
+ testLanguage( "default" );
+
+ testCountry();
+ testCountry( "" );
+ testCountry( "US" );
+ testCountry( "DE" );
+
+ INT << "===[END]============================================" << endl;
+ return 0;
+}