From 0d61dcc35e0ce7b640b9dc91132e34ef9463dd0d Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 15 Oct 2009 17:36:27 +0200 Subject: [PATCH] remove obsolete testdrafts --- devel/devel.ma/testdrafts/Arch.cc | 157 -------------- devel/devel.ma/testdrafts/BitField.cc | 204 ------------------ devel/devel.ma/testdrafts/CapMatch.cc | 108 ---------- devel/devel.ma/testdrafts/CompareBy.cc | 146 ------------- devel/devel.ma/testdrafts/EditionRangeOvelap.cc | 107 ---------- devel/devel.ma/testdrafts/GzStream.cc | 67 ------ devel/devel.ma/testdrafts/Locale.cc | 102 --------- devel/devel.ma/testdrafts/XmlExample.cc | 270 ------------------------ 8 files changed, 1161 deletions(-) delete mode 100644 devel/devel.ma/testdrafts/Arch.cc delete mode 100644 devel/devel.ma/testdrafts/BitField.cc delete mode 100644 devel/devel.ma/testdrafts/CapMatch.cc delete mode 100644 devel/devel.ma/testdrafts/CompareBy.cc delete mode 100644 devel/devel.ma/testdrafts/EditionRangeOvelap.cc delete mode 100644 devel/devel.ma/testdrafts/GzStream.cc delete mode 100644 devel/devel.ma/testdrafts/Locale.cc delete mode 100644 devel/devel.ma/testdrafts/XmlExample.cc diff --git a/devel/devel.ma/testdrafts/Arch.cc b/devel/devel.ma/testdrafts/Arch.cc deleted file mode 100644 index 28d7ad9..0000000 --- a/devel/devel.ma/testdrafts/Arch.cc +++ /dev/null @@ -1,157 +0,0 @@ -#include -#include -#include - -#include "Printing.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -using namespace std; -using namespace zypp; -using namespace zypp::functor; - -inline const char * compResult( int res ) -{ - return( res ? ( res < 0 ? "<" : ">" ) : "=" ); -} - -template - 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 - 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 - inline _BinaryFunction - nest_for_earch( _Iter begin, _Iter end, - _BinaryFunction fnc ) - { return nest_for_earch( begin, end, begin, end, fnc ); } - - -template - inline void sym_compare( _Iter begin, _Iter end ) - { - sym_compare( begin, end, _Function() ); - } - -inline list archList() -{ - list 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 archlist( archList() ); -static set 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 -{ - bool operator()( const Arch & lhs, const Arch & rhs ) const - { 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 -** FUNCTION TYPE : int -*/ -int main( int argc, char * argv[] ) -{ - INT << "===[START]==========================================" << endl; - - // All archs in test - print( archlist ); - - // set ordering - print( archset ); - - // compatibleWith - sym_compare( archset.begin(), archset.end(), CompatTest() ); - - // compare order - typedef set OrderedArch; - - OrderedArch a( archset.begin(), archset.end() ); - print( a ); - 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 > 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; -} - diff --git a/devel/devel.ma/testdrafts/BitField.cc b/devel/devel.ma/testdrafts/BitField.cc deleted file mode 100644 index 2fefddf..0000000 --- a/devel/devel.ma/testdrafts/BitField.cc +++ /dev/null @@ -1,204 +0,0 @@ -#include - -#include -#include -#include -#include - -#include "Measure.h" -#include "Printing.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "zypp/NVRAD.h" -#include "zypp/ResPool.h" -#include "zypp/ResFilters.h" - -#include -#include - -#include "zypp/ResPoolManager.h" -#include "zypp/ResPoolProxy.h" - -using namespace std; -using namespace zypp; -using namespace zypp::ui; -using namespace zypp::functor; - -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// - -template - struct Counter - { - Counter() - : _value( _IntT(0) ) - {} - - Counter( _IntT value_r ) - : _value( _IntT( value_r ) ) - {} - - - operator _IntT &() - { return _value; } - - operator const _IntT &() const - { return _value; } - - _IntT _value; - }; - -struct Rstats : public std::unary_function -{ - void operator()( ResObject::constPtr ptr ) - { - ++_total; - ++_perKind[ptr->kind()]; - } - - typedef std::map > KindMap; - Counter _total; - KindMap _perKind; -}; - -std::ostream & operator<<( std::ostream & str, const Rstats & obj ) -{ - str << "Total: " << obj._total; - for( Rstats::KindMap::const_iterator it = obj._perKind.begin(); it != obj._perKind.end(); ++it ) - { - str << endl << " " << it->first << ":\t" << it->second; - } - return str; -} - -template - void rstats( _Iterator begin, _Iterator end ) - { - DBG << __PRETTY_FUNCTION__ << endl; - Rstats stats; - for_each( begin, end, functorRef(stats) ); - MIL << stats << endl; - } - -/////////////////////////////////////////////////////////////////// - -struct XByInstalled : public std::unary_function -{ - bool operator()( const ui::Selectable::constPtr & obj ) const - { - return obj->hasInstalledObj(); - } -}; - -template - void fieldInfo() - { - MIL << bit::asString(FT::Mask::value) << '|' << FT::begin << '-' << FT::end << '|' << FT::size << endl; - MIL << bit::asString(FT::Mask::inverted) << endl; - } - - -void testr() -{ - fieldInfo(); - DBG << bit::asString((ResStatus::FieldType)ResStatus::UNINSTALLED) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::INSTALLED) << endl; - fieldInfo(); - DBG << bit::asString((ResStatus::FieldType)ResStatus::UNDETERMINED) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::UNNEEDED) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::SATISFIED) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::INCOMPLETE) << endl; - fieldInfo(); - DBG << bit::asString((ResStatus::FieldType)ResStatus::KEEP_STATE) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::TRANSACT) << endl; - fieldInfo(); - DBG << bit::asString((ResStatus::FieldType)ResStatus::SOLVER) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::APPL_LOW) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::APPL_HIGH) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::USER) << endl; - fieldInfo(); - DBG << bit::asString((ResStatus::FieldType)ResStatus::EXPLICIT_INSTALL) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::SOFT_INSTALL) << endl; - DBG << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::EXPLICIT_REMOVE) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::SOFT_REMOVE) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::DUE_TO_OBSOLETE) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::DUE_TO_UNLINK) << endl; - fieldInfo(); - DBG << bit::asString((ResStatus::FieldType)ResStatus::NORMAL) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::SEEN) << endl; - DBG << bit::asString((ResStatus::FieldType)ResStatus::IMPOSSIBLE) << endl; -} - - - -/////////////////////////////////////////////////////////////////// - -/****************************************************************** -** -** FUNCTION NAME : main -** FUNCTION TYPE : int -*/ -int main( int argc, char * argv[] ) -{ - INT << "===[START]==========================================" << endl; - - string infile( "p" ); - if (argc >= 2 ) - infile = argv[1]; - - MIL << ResStatus::toBeUninstalledDueToUnlink << endl; - MIL << ResStatus::toBeUninstalledDueToObsolete << endl; - testr(); - return 0; - - NVRAD a( "foo", Edition("1.1") ); - NVRAD b( "foo", Edition("1.0") ); - SEC << (a==b) << endl; - SEC << (a!=b) << endl; - SEC << (a s; - s.insert(a); - s.insert(b); - SEC << s.size() << endl; - return 0; - - Url url("dir:/Local/ma/zypp/libzypp/devel/devel.ma/CD1"); - Measure x( "SourceFactory.create" ); - Source_Ref src( SourceFactory().createFrom( url ) ); - x.stop(); - Source_Ref trg( SourceFactory().createFrom( url ) ); - - //Source_Ref src( SourceFactory().createFrom( new source::susetags::SuseTagsImpl(infile) ) ); - //MIL << src.resolvables().size() << endl; - - ResPoolManager pool; - x.start( "pool.insert" ); - pool.insert( src.resolvables().begin(), src.resolvables().end() ); - x.stop(); - MIL << pool << endl; - - ResPool query( pool.accessor() ); - rstats( query.begin(), query.end() ); - - ResPoolProxy y2pm( query ); - - pool.insert( trg.resolvables().begin(), trg.resolvables().end(), true ); - y2pm = ResPoolProxy( query ); - - - - - INT << "===[END]============================================" << endl << endl; - return 0; -} - diff --git a/devel/devel.ma/testdrafts/CapMatch.cc b/devel/devel.ma/testdrafts/CapMatch.cc deleted file mode 100644 index c9ffe6f..0000000 --- a/devel/devel.ma/testdrafts/CapMatch.cc +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace zypp; - -// work around flaw in y2logview -template - void printOnHack( const _Tp & obj ) - { - MIL << obj << endl; - }; - -/////////////////////////////////////////////////////////////////// -// Just for the stats -struct Measure -{ - time_t _begin; - Measure() - : _begin( time(NULL) ) - { - USR << "START MEASURE..." << endl; - } - ~Measure() - { - USR << "DURATION: " << (time(NULL)-_begin) << " sec." << endl; - } -}; - -/////////////////////////////////////////////////////////////////// -// Print stream status -ostream & operator<<( ostream & str, const istream & obj ) { - return str - << (obj.good() ? 'g' : '_') - << (obj.eof() ? 'e' : '_') - << (obj.fail() ? 'F' : '_') - << (obj.bad() ? 'B' : '_'); -} - -namespace zypp -{ - - - -} - -using namespace zypp; - -/****************************************************************** -** -** FUNCTION NAME : main -** FUNCTION TYPE : int -*/ -int main( int argc, char * argv[] ) -{ - INT << "===[START]==========================================" << endl; - - CapMatch u( CapMatch::irrelevant ); - CapMatch y(true); - CapMatch n(false); - -#define OUT(X) DBG << #X << " " << (X) << endl - - OUT( u ); - OUT( u == y ); - OUT( u != y ); - - OUT( u == true ); - OUT( u == false ); - OUT( true == u ); - OUT( false == u ); - - OUT( u && y ); - OUT( u && n ); - OUT( u && u ); - - OUT( y && y ); - OUT( y && n ); - OUT( y && u ); - - OUT( n && y ); - OUT( n && n ); - OUT( n && u ); - - OUT( u || y ); - OUT( u || n ); - OUT( u || u ); - - OUT( y || y ); - OUT( y || n ); - OUT( y || u ); - - OUT( n || y ); - OUT( n || n ); - OUT( n || u ); - - OUT( !u ); - OUT( !y ); - OUT( !n ); - - INT << "===[END]============================================" << endl; - return 0; -} diff --git a/devel/devel.ma/testdrafts/CompareBy.cc b/devel/devel.ma/testdrafts/CompareBy.cc deleted file mode 100644 index 62b4c17..0000000 --- a/devel/devel.ma/testdrafts/CompareBy.cc +++ /dev/null @@ -1,146 +0,0 @@ -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "zypp/ResPool.h" -#include "zypp/ResFilters.h" - -#include -#include - -#include "zypp/ResPoolManager.h" - -using namespace std; -using namespace zypp; -using namespace zypp::functor; -using namespace zypp::resfilter; - -namespace zypp -{ -} - -/////////////////////////////////////////////////////////////////// - -struct Print : public std::unary_function -{ - bool operator()( ResObject::constPtr ptr ) - { - USR << *ptr << endl; - return true; - } -}; - -/////////////////////////////////////////////////////////////////// - -template - struct Counter - { - Counter() - : _value( _IntT(0) ) - {} - - Counter( _IntT value_r ) - : _value( _IntT( value_r ) ) - {} - - operator _IntT &() - { return _value; } - - operator const _IntT &() const - { return _value; } - - _IntT _value; - }; - -struct Rstats : public std::unary_function -{ - void operator()( ResObject::constPtr ptr ) - { - ++_total; - ++_perKind[ptr->kind()]; - } - - typedef std::map > KindMap; - Counter _total; - KindMap _perKind; -}; - -std::ostream & operator<<( std::ostream & str, const Rstats & obj ) -{ - str << "Total: " << obj._total; - for( Rstats::KindMap::const_iterator it = obj._perKind.begin(); it != obj._perKind.end(); ++it ) - { - str << endl << " " << it->first << ":\t" << it->second; - } - return str; -} - -template - void rstats( _Iterator begin, _Iterator end ) - { - DBG << __PRETTY_FUNCTION__ << endl; - Rstats stats; - for_each( begin, end, functorRef(stats) ); - MIL << stats << endl; - } - -/////////////////////////////////////////////////////////////////// - -void test( ResPool::const_iterator begin, ResPool::const_iterator end, const Edition & ed, Rel op = Rel::EQ ) -{ - SEC << "Serach for editions " << op << ' ' << ed << ':' << endl; - SEC << invokeOnEach( begin, end, - - resfilter::byEdition( Edition("2.0-1"), CompareBy(op) ), - - Print() ) << endl; -} - -/****************************************************************** -** -** FUNCTION NAME : main -** FUNCTION TYPE : int -*/ -int main( int argc, char * argv[] ) -{ - string infile( "p" ); - if (argc >= 2 ) - infile = argv[1]; - - Source_Ref src( SourceFactory().createFrom( new source::susetags::SuseTagsImpl(infile) ) ); - MIL << src.resolvables().size() << endl; - - ResPoolManager pool; - pool.insert( src.resolvables().begin(), src.resolvables().end() ); - MIL << pool << endl; - - ResPool query( pool.accessor() ); - rstats( query.begin(), query.end() ); - - SEC << invokeOnEach( query.begin(), query.end(), - Print() ) << endl; - - test( query.begin(), query.end(), Edition("2.0-1"), Rel::LT ); - test( query.begin(), query.end(), Edition("2.0-1"), Rel::LE ); - test( query.begin(), query.end(), Edition("2.0-1"), Rel::EQ ); - test( query.begin(), query.end(), Edition("2.0-1"), Rel::GE ); - test( query.begin(), query.end(), Edition("2.0-1"), Rel::GT ); - test( query.begin(), query.end(), Edition("2.0-1"), Rel::ANY ); - test( query.begin(), query.end(), Edition("2.0-1"), Rel::NONE ); - - - - return 0; -} - diff --git a/devel/devel.ma/testdrafts/EditionRangeOvelap.cc b/devel/devel.ma/testdrafts/EditionRangeOvelap.cc deleted file mode 100644 index 33b23fd..0000000 --- a/devel/devel.ma/testdrafts/EditionRangeOvelap.cc +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace zypp; - -// work around flaw in y2logview -template - void printOnHack( const _Tp & obj ) - { - MIL << obj << endl; - }; - -/////////////////////////////////////////////////////////////////// -// Just for the stats -struct Measure -{ - time_t _begin; - Measure() - : _begin( time(NULL) ) - { - USR << "START MEASURE..." << endl; - } - ~Measure() - { - USR << "DURATION: " << (time(NULL)-_begin) << " sec." << endl; - } -}; - -/////////////////////////////////////////////////////////////////// -// Print stream status -ostream & operator<<( ostream & str, const istream & obj ) { - return str - << (obj.good() ? 'g' : '_') - << (obj.eof() ? 'e' : '_') - << (obj.fail() ? 'F' : '_') - << (obj.bad() ? 'B' : '_'); -} - -namespace zypp -{ - - - -} - -using namespace zypp; - -/****************************************************************** -** -** FUNCTION NAME : main -** FUNCTION TYPE : int -*/ -int main( int argc, char * argv[] ) -{ - INT << "===[START]==========================================" << endl; - - Edition::Range any; - DBG << any << endl; - - Edition l( "1.0" ); - Edition r( "2.0" ); - -#define R(O,E) Edition::Range( Rel::O, E ) - -#define NONE(E) R(NONE,E) -#define ANY(E) R(ANY,E) -#define LT(E) R(LT,E) -#define LE(E) R(LE,E) -#define EQ(E) R(EQ,E) -#define GE(E) R(GE,E) -#define GT(E) R(GT,E) -#define NE(E) R(NE,E) - -#define OV(L,R) DBG << #L << " <> " << #R << " ==> " << Edition::Range::overlaps( L, R ) << endl - - ERR << "Omitting Rel::NE" << endl; - -#define OVALL( L ) \ - DBG << "----------------------------" << endl; \ - OV( L, NONE(r) ); \ - OV( L, ANY(r) ); \ - OV( L, LT(r) ); \ - OV( L, LE(r) ); \ - OV( L, EQ(r) ); \ - OV( L, GE(r) ); \ - OV( L, GT(r) ); \ - DBG << "----------------------------" << endl; - - OVALL( NONE(l) ); - OVALL( ANY(l) ); - OVALL( LT(l) ); - OVALL( LE(l) ); - OVALL( EQ(l) ); - OVALL( GE(l) ); - OVALL( GT(l) ); - - // same for l > r and l == r - - INT << "===[END]============================================" << endl; - return 0; -} diff --git a/devel/devel.ma/testdrafts/GzStream.cc b/devel/devel.ma/testdrafts/GzStream.cc deleted file mode 100644 index 835d44a..0000000 --- a/devel/devel.ma/testdrafts/GzStream.cc +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include -#include - -#include "Tools.h" - -#include -#include -#include - -using namespace std; -using namespace zypp; - -std::ostream & operator<<( std::ostream & str, std::istream & obj ) -{ - return str << "IN(" - << ( obj.good() ? 'g' : '_' ) - << ( obj.eof() ? 'e' : '_' ) - << ( obj.fail() ? 'F' : '_' ) - << ( obj.bad() ? 'B' : '_' ) - << ' ' << obj.tellg() << ")"; -} -std::ostream & operator<<( std::ostream & str, std::ostream & obj ) -{ - return str << "OUT(" - << ( obj.good() ? 'g' : '_' ) - << ( obj.eof() ? 'e' : '_' ) - << ( obj.fail() ? 'F' : '_' ) - << ( obj.bad() ? 'B' : '_' ) - << ' ' << obj.tellp() << ")"; -} - - -/****************************************************************** -** -** FUNCTION NAME : main -** FUNCTION TYPE : int -*/ -int main( int argc, char * argv[] ) -{ - INT << "===[START]==========================================" << endl; - - ifgzstream inf( "file" ); - ofgzstream zout( "file.gz" ); - MIL << inf << endl; - MIL << zout << endl; - - inf >> noskipws; - copy( istream_iterator(inf), istream_iterator(), - ostream_iterator(zout) ); - MIL << inf << endl; - MIL << zout << endl; - zout.close(); - MIL << zout << endl; - - ifgzstream zinf( "file.gz" ); - DBG << zinf << endl; - zinf >> noskipws; - copy( istream_iterator(zinf), istream_iterator(), - ostream_iterator(DBG) ); - DBG << endl; - MIL << zinf << endl; - - INT << "===[END]============================================" << endl << endl; - return 0; -} - diff --git a/devel/devel.ma/testdrafts/Locale.cc b/devel/devel.ma/testdrafts/Locale.cc deleted file mode 100644 index 1644e70..0000000 --- a/devel/devel.ma/testdrafts/Locale.cc +++ /dev/null @@ -1,102 +0,0 @@ -#include - -#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; -} diff --git a/devel/devel.ma/testdrafts/XmlExample.cc b/devel/devel.ma/testdrafts/XmlExample.cc deleted file mode 100644 index 717e2cb..0000000 --- a/devel/devel.ma/testdrafts/XmlExample.cc +++ /dev/null @@ -1,270 +0,0 @@ -#include "Tools.h" - -extern "C" -{ -#include -#include -} -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include "zypp/base/Exception.h" -#include "zypp/base/InputStream.h" -#include "zypp/base/DefaultIntegral.h" -#include -#include -#include -#include -#include -#include -#include - -#include "zypp/parser/xml/Reader.h" - -using namespace std; -using namespace zypp; - -/////////////////////////////////////////////////////////////////// - -static const Pathname sysRoot( "/Local/ROOT" ); - -/////////////////////////////////////////////////////////////////// - -template - void ti( const _Cl & c ) -{ - SEC << __PRETTY_FUNCTION__ << endl; -} - -/////////////////////////////////////////////////////////////////// - -bool dump( xml::Reader & reader_r ) -{ - MIL << *reader_r << endl; -} - -/////////////////////////////////////////////////////////////////// - -bool dumpNode( xml::Reader & reader_r ) -{ - switch ( reader_r->nodeType() ) - { - case XML_READER_TYPE_ELEMENT: - MIL << *reader_r << endl; - for ( int i = 0; i < reader_r->attributeCount(); ++i ) - { - MIL << " attr no " << i << " '" << reader_r->getAttributeNo( i ) << "'" << endl; - } - break; - - case XML_READER_TYPE_ATTRIBUTE: - WAR << *reader_r << endl; - break; - - case XML_READER_TYPE_TEXT: - case XML_READER_TYPE_CDATA: - DBG << *reader_r << endl; - break; - - default: - //ERR << *reader_r << endl; - break; - } - return true; -} - -/////////////////////////////////////////////////////////////////// - -bool dumpEd( xml::Reader & reader_r ) -{ - static int num = 5; - if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT - && reader_r->name() == "version" ) - { - MIL << *reader_r << endl; -#define _show(x) DBG << #x << " = " << reader_r->getAttribute( #x ) << endl - _show( rel ); - _show( ver ); - _show( epoch ); - WAR << Edition( reader_r->getAttribute( "ver" ).asString(), - reader_r->getAttribute( "rel" ).asString(), - reader_r->getAttribute( "epoch" ).asString() ) << endl; - --num; - } - return num; -} - -/////////////////////////////////////////////////////////////////// - -template - struct DumpDeps - { - DumpDeps( _OutputIterator result_r ) - : _result( result_r ) - {} - - bool operator()( xml::Reader & reader_r ) - { - if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT - && reader_r->prefix() == "rpm" - && reader_r->localName() == "entry" ) - { - string n( reader_r->getAttribute( "name" ).asString() ); - Rel op( reader_r->getAttribute( "flags" ).asString() ); - if ( op != Rel::ANY ) - { - n += " "; - n += op.asString(); - n += " "; - n += reader_r->getAttribute( "ver" ).asString(); - n += "-"; - n += reader_r->getAttribute( "rel" ).asString(); - } - *_result = n; - ++_result; - } - return true; - } - - _OutputIterator _result; - }; - -template - DumpDeps<_OutputIterator> dumpDeps( _OutputIterator result_r ) - { return DumpDeps<_OutputIterator>( result_r ); } - -/////////////////////////////////////////////////////////////////// - -/****************************************************************** -** -** FUNCTION NAME : main -** FUNCTION TYPE : int -*/ -int main( int argc, char * argv[] ) -{ - INT << "===[START]==========================================" << endl; - - --argc; - ++argv; - - Pathname repodata; - if ( argc ) - { - repodata = *argv; - } - else - { - repodata = "/Local/FACTORY/repodata"; - repodata /= "primary.xml"; - } - - if ( 1 ) - { - Measure m( "Parse" ); - xml::Reader reader( repodata ); - - switch ( 3 ) - { - case 1: - reader.foreachNode( dumpNode ); - break; - case 2: - reader.foreachNodeOrAttribute( dumpNode ); - break; - case 3: - reader.foreachNode( dumpEd ); - break; - - default: - WAR << "NOP" << endl; - break; - } - } - - INT << "===[END]============================================" << endl << endl; - return 0; -} - -/* - - - -fam-devel -ppc - -59d6a65cdadd911fe8ceee87740a54305b2ab053 -Include Files and Libraries Mandatory for Development -Fam is a file alteration monitoring service. This means that you can - -foreachNode( dumpNode ) -======================= -START MEASURE(Parse) -0:ELEMENT [attr 3] - attr no 0 'http://linux.duke.edu/metadata/common' - attr no 1 'http://linux.duke.edu/metadata/rpm' - attr no 2 '23230' -1: ELEMENT [attr 1] - attr no 0 'rpm' -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {fam-devel} -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {ppc} -2: ELEMENT [attr 3|empty] - attr no 0 '0' - attr no 1 '2.6.10' - attr no 2 '141' -2: ELEMENT [attr 2] - attr no 0 'sha' - attr no 1 'YES' -3: TEXT <#text> [noattr] {59d6a65cdadd911fe8ceee87740a54305b2ab053} -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {Include Files and Libraries Mandatory for Development} -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {Fam is a file alteration monitoring service. This means that you can - -foreachNodeOrAttribute( dumpNode ) -================================== -START MEASURE(Parse) -0:ELEMENT [attr 3] - attr no 0 'http://linux.duke.edu/metadata/common' - attr no 1 'http://linux.duke.edu/metadata/rpm' - attr no 2 '23230' -1: ATTRIBUTE [noattr] {http://linux.duke.edu/metadata/common} -1: ATTRIBUTE [noattr] {http://linux.duke.edu/metadata/rpm} -1: ATTRIBUTE [noattr] {23230} -1: ELEMENT [attr 1] - attr no 0 'rpm' -2: ATTRIBUTE [noattr] {rpm} -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {fam-devel} -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {ppc} -2: ELEMENT [attr 3|empty] - attr no 0 '0' - attr no 1 '2.6.10' - attr no 2 '141' -3: ATTRIBUTE [noattr] {0} -3: ATTRIBUTE [noattr] {2.6.10} -3: ATTRIBUTE [noattr] {141} -2: ELEMENT [attr 2] - attr no 0 'sha' - attr no 1 'YES' -3: ATTRIBUTE [noattr] {sha} -3: ATTRIBUTE [noattr] {YES} -3: TEXT <#text> [noattr] {59d6a65cdadd911fe8ceee87740a54305b2ab053} -3: ATTRIBUTE [noattr] {sha} -3: ATTRIBUTE [noattr] {YES} -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {Include Files and Libraries Mandatory for Development} -2: ELEMENT [noattr] -3: TEXT <#text> [noattr] {Fam is a file alteration monitoring service. This means that you can - -*/ -- 2.7.4