00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: PkgSplit.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: 00019 00020 /-*/ 00021 #ifndef PkgSplit_h 00022 #define PkgSplit_h 00023 00024 #include <iosfwd> 00025 #include <string> 00026 #include <set> 00027 00028 #include <y2util/Pathname.h> 00029 00030 #include <y2pm/PkgName.h> 00031 00033 class PkgSplit; 00034 00035 typedef std::set<PkgSplit> PkgSplitSet; 00036 00038 00040 // 00041 // CLASS NAME : PkgSplit 00057 class PkgSplit { 00058 00059 private: 00060 00061 PkgName _ipkg; 00062 Pathname _file; 00063 00064 public: 00065 00069 PkgSplit() {} 00070 00077 PkgSplit( const std::string & splitprovides_r, const bool quiet_r = false ); 00078 00082 PkgSplit( const PkgName & ipkg_r, const Pathname & file_r ); 00083 00084 ~PkgSplit(); 00085 00091 bool valid() const { return ! ( _ipkg->empty() || _file.empty() ); } 00092 00096 const PkgName & ipkg() const { return _ipkg; } 00097 00101 const Pathname & file() const { return _file; } 00102 00103 public: 00104 00108 friend std::ostream & operator<<( std::ostream & str, const PkgSplit & obj ); 00109 00117 friend bool std::less<PkgSplit>::operator()(const PkgSplit & lhs, const PkgSplit & rhs ) const; 00118 }; 00119 00121 00129 inline bool std::less<PkgSplit>::operator()(const PkgSplit & lhs, const PkgSplit & rhs ) const { 00130 int d = lhs.ipkg().asString().compare( rhs.ipkg().asString() ); 00131 if ( d ) 00132 return( d < 0 ); 00133 return( lhs.file().asString() < rhs.file().asString() ); 00134 } 00135 00137 00138 #endif // PkgSplit_h 00139