- Use SolvAttr to keep the ids of attributes in a nice way
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 5 Feb 2008 18:27:55 +0000 (18:27 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 5 Feb 2008 18:27:55 +0000 (18:27 +0000)
- start playing with a way to get the data using resolvable interface
- the most important goal for today (tonight) is the url/media so we can
  commit packages, and hopefully, description and summary

zypp/CMakeLists.txt
zypp/ResObject.cc
zypp/Resolvable.cc
zypp/sat/SolvAttr.cc [new file with mode: 0644]
zypp/sat/SolvAttr.h [new file with mode: 0644]

index ee99662..063784f 100644 (file)
@@ -514,6 +514,7 @@ SET( zypp_sat_SRCS
   sat/Repo.cc
   sat/Solvable.cc
   sat/SATResolver.cc
+  sat/SolvAttr.cc
 )
 
 SET( zypp_sat_HEADERS
@@ -521,6 +522,7 @@ SET( zypp_sat_HEADERS
   sat/Repo.h
   sat/Solvable.h
   sat/SATResolver.h
+  sat/SolvAttr.h
 )
 
 INSTALL(  FILES
index 777f5bc..775fac1 100644 (file)
 */
 #include "zypp/ResObject.h"
 #include "zypp/Repository.h"
+#include "zypp/sat/SolvAttr.h"
+extern "C"
+{
+#include "satsolver/repo.h"
+}
+
+class SearchQuery
+{
+  void search(Repo *repo, Id p, Id key, const char *match, int flags)
+  {
+    repo_search( repo, p, key, match, flags, SearchQuery::repo_search_cb, (void*) this);
+  }
+  
+  static int repo_search_cb(void *cbdata, ::Solvable *s, ::Repodata *data, ::Repokey *key, ::KeyValue *kv)
+  {
+    SearchQuery *q = (SearchQuery *) cbdata;
+  }
+};
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -101,7 +119,7 @@ namespace zypp
 ///////////////////////////////////////////////////////////////////
 
 #include "zypp/ResObjects.h"
-
+             
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
index 0097113..628801e 100644 (file)
@@ -11,7 +11,7 @@
 */
 #include "zypp/Resolvable.h"
 #include "zypp/ResObject.h"
-
+             
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
diff --git a/zypp/sat/SolvAttr.cc b/zypp/sat/SolvAttr.cc
new file mode 100644 (file)
index 0000000..a184847
--- /dev/null
@@ -0,0 +1,33 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/SolvAttr.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/base/String.h"
+
+#include "zypp/sat/SolvAttr.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace sat
+{ /////////////////////////////////////////////////////////////////
+
+  const SolvAttr SolvAttr::summary      ( "summary" );
+  const SolvAttr SolvAttr::description  ( "description" );
+
+
+} // namespace sat
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/sat/SolvAttr.h b/zypp/sat/SolvAttr.h
new file mode 100644 (file)
index 0000000..b5ed978
--- /dev/null
@@ -0,0 +1,76 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/SolvAttr.h
+ *
+*/
+#ifndef ZYPP_SolvAttr_H
+#define ZYPP_SolvAttr_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/String.h"
+#include "zypp/IdStringType.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace sat
+{ /////////////////////////////////////////////////////////////////
+
+  
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : SolvAttr
+  //
+  /** Resolvable kinds.
+   * A \b lowercased string and used as identification.
+   * Comparison against string values is always case
+   * insensitive.
+   */
+  class SolvAttr : public IdStringType<SolvAttr>
+  {
+    public:
+      /** \name Some builtin SolvAttr constants. */
+      //@{
+      /** Value representing \c nokind (<tt>""</tt>)*/
+      static const SolvAttr noAttr;
+      static const SolvAttr summary;
+      static const SolvAttr description;
+      //@}
+
+    public:
+      /** Default ctor: \ref nokind */
+      SolvAttr() {}
+
+      /** Ctor taking kind as string. */
+      explicit SolvAttr( sat::detail::IdType id_r )  : _str( str::toLower(IdString(id_r).c_str()) ) {}
+      explicit SolvAttr( const IdString & idstr_r )  : _str( str::toLower(idstr_r.c_str()) ) {}
+      explicit SolvAttr( const std::string & str_r ) : _str( str::toLower(str_r) ) {}
+      explicit SolvAttr( const char * cstr_r )       : _str( str::toLower(cstr_r) ) {}
+
+    public:
+      private:
+      static int _doCompare( const char * lhs,  const char * rhs )
+      {
+        if ( lhs == rhs ) return 0;
+        if ( lhs && rhs ) return ::strcasecmp( lhs, rhs );
+        return( lhs ? 1 : -1 );
+      }
+
+    private:
+      friend class IdStringType<SolvAttr>;
+      IdString _str;
+  };
+
+  /////////////////////////////////////////////////////////////////
+} // namespace sat
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SolvAttr_H