- add operator < to use Url in std::set
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 31 May 2007 16:17:48 +0000 (16:17 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 31 May 2007 16:17:48 +0000 (16:17 +0000)
- First repomanager that can list repos from /etc/repos.d ;-)

devel/devel.dmacvicar/CachedSource_tp.cc
devel/devel.dmacvicar/RepositoryManager_tp.cc
zypp/Url.cc
zypp/Url.h
zypp2/RepoInfo.cc
zypp2/RepoManager.cc

index 8f16e2f..59fc637 100644 (file)
 #include "zypp/detail/PackageImplIf.h"
 #include "zypp/Package.h"
 #include "zypp2/RepositoryFactory.h"
-#include "zypp2/repository/cached/CachedRepositoryImpl.h"
+#include "zypp2/repo/cached/RepoImpl.h"
 #include "zypp/data/ResolvableData.h"
 
 using namespace std;
 using namespace zypp;
-using namespace zypp::repository;
-using namespace zypp::repository::cached;
+using namespace zypp::repo;
+using namespace zypp::repo::cached;
 
 
 int main(int argc, char **argv)
index 7b5912d..21dc8a7 100644 (file)
 #include "zypp/detail/PackageImplIf.h"
 #include "zypp/Package.h"
 #include "zypp2/RepositoryFactory.h"
-#include "zypp2/RepositoryInfo.h"
+#include "zypp2/RepoInfo.h"
 
-#include "zypp2/repository/cached/CachedRepositoryImpl.h"
+#include "zypp2/repo/cached/RepoImpl.h"
 #include "zypp/data/ResolvableData.h"
 
-#include "zypp2/RepositoryManager.h"
-#include "zypp2/RepositoryInfo.h"
+#include "zypp2/RepoManager.h"
+#include "zypp2/RepoInfo.h"
 
 
 using namespace std;
@@ -34,10 +34,10 @@ int main(int argc, char **argv)
     
       Pathname dbpath = Pathname(getenv("PWD"));
       
-      RepositoryManager manager;
-      RepositoryInfoList repos = manager.knownRepositories();
+      RepoManager manager;
+      RepoInfoList repos = manager.knownRepositories();
 
-      for ( RepositoryInfoList::const_iterator it = repos.begin(); it != repos.end(); ++it )
+      for ( RepoInfoList::const_iterator it = repos.begin(); it != repos.end(); ++it )
       {
         cout << *it << endl;
       }
index 7545273..03dc2be 100644 (file)
@@ -783,6 +783,10 @@ namespace zypp
     return str << url.asString();
   }
 
+  bool operator<( const Url &lhs, const Url &rhs )
+  {
+    return (lhs.asString() < rhs.asString());
+  }
 
   ////////////////////////////////////////////////////////////////////
 } // namespace zypp
index 3002681..7c05e6c 100644 (file)
@@ -772,6 +772,11 @@ namespace zypp
 
   std::ostream & operator<<( std::ostream & str, const Url & url );
 
+  /**
+   * needed for std::set
+   */
+  bool operator<( const Url &lhs, const Url &rhs );
+  
   ////////////////////////////////////////////////////////////////////
 } // namespace zypp
 //////////////////////////////////////////////////////////////////////
index bc9f1c9..f6c0ede 100644 (file)
@@ -162,7 +162,14 @@ namespace zypp
   {
     str << "--------------------------------------" << std::endl;
     str << "- alias       : " << alias() << std::endl;
-    //str << "- url         : " << baseUrl() << std::endl;
+    std::set<Url> url_set(urls());
+    for ( std::set<Url>::const_iterator it = url_set.begin();
+          it != url_set.end();
+          ++it )
+    {
+      str << "- url         : " << *it << std::endl;
+    }
+    
     str << "- type        : " << type() << std::endl;
     str << "- enabled     : " << enabled() << std::endl;
     str << "- autorefresh : " << autorefresh() << std::endl;
@@ -170,6 +177,11 @@ namespace zypp
     return str;
   }
 
+  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
+  {
+    return obj.dumpOn(str);
+  }
+  
   /////////////////////////////////////////////////////////////////
 } // namespace zypp2
 ///////////////////////////////////////////////////////////////////
index ea8e657..1456d96 100644 (file)
@@ -44,7 +44,7 @@ static std::list<RepoInfo> repositories_in_file( const Pathname &file )
           ++it )
     {
       
-      MIL << (*it).first << endl;
+      //MIL << (*it).first << endl;
       if (it->first == "name" )
         info.setName(it-> second);
       else if ( it->first == "enabled" )
@@ -54,22 +54,10 @@ static std::list<RepoInfo> repositories_in_file( const Pathname &file )
     }
     
     // add it to the list.
+    repos.push_back(info);
   }
   
-//   dictionary *d = iniparser_new(file.c_str());
-//   
-//   if ( d == NULL )
-//     ZYPP_THROW(Exception("Failed creating dictionary"));
-//   
-//   int n = iniparser_getnsec(d);
-//   MIL << n << endl;
-//   
-//   for ( int i = 0; i < n; i++ )
-//   {
-//     MIL << iniparser_getsecname(d, i) << endl;
-//     
-//   }
-  return std::list<RepoInfo>();
+  return repos;
 }
 
 static std::list<RepoInfo> repositories_in_path( const Pathname &dir )
@@ -90,9 +78,7 @@ static std::list<RepoInfo> repositories_in_path( const Pathname &dir )
 
 std::list<RepoInfo> RepoManager::knownRepositories()
 {
-  
-
-  return std::list<RepoInfo>();
+  return repositories_in_path("/etc/zypp/repos.d");
 }
 
 } // ns zypp