start using xml backend
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 9 Jan 2006 17:31:43 +0000 (17:31 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 9 Jan 2006 17:31:43 +0000 (17:31 +0000)
devel/devel.dmacvicar/Makefile
devel/devel.dmacvicar/Makefile.am
devel/devel.dmacvicar/test2.cc

index 53db2e8..e323f4e 100644 (file)
@@ -194,8 +194,8 @@ INCLUDES =
 AM_LDFLAGS = -pg
 AM_CXXFLAGS = 
 # gperf:       -pg
-LDADD = $(top_srcdir)/zypp/libzypp.la -lboost_regex -lsqlite3
-#LDADD =       -lboost_regex -lsqlite3
+LDADD = $(top_srcdir)/zypp/libzypp.la -lboost_regex -lsqlite3 -ldbxml
+#LDADD =       -lboost_regex -lsqlite3 -dbxml
 test2_SOURCES = test2.cc PersistentStorage.cc Backend.cc BDBBackend.cc SQLiteWrapper.cc SQLiteBackend.cc
 test2_debug_SOURCES = $(test2_SOURCES)
 test2_debug_LDFLAGS = -static
index 4fdb6a3..2d1ba47 100644 (file)
@@ -14,8 +14,8 @@ AM_LDFLAGS = -pg
 AM_CXXFLAGS =
 # gperf:       -pg
 
-LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la -lboost_regex -lsqlite3
-#LDADD =       -lboost_regex -lsqlite3
+LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la -lboost_regex -lsqlite3 -ldbxml
+#LDADD =       -lboost_regex -lsqlite3 -dbxml
 
 ## ##################################################
 
index 83b6570..03f9d29 100644 (file)
 #include "PersistentStorage.h"
 
+#include <iostream>
+#include <fstream>
+
+#include "dbxml/DbXml.hpp"
+
+#include <zypp/base/Logger.h>
+///////////////////////////////////////////////////////////////////
+
+#include <zypp/Message.h>
+#include <zypp/detail/MessageImpl.h>
+#include <zypp/detail/PatchImpl.h>
+#include <zypp/Patch.h>
+#include <zypp/Package.h>
+#include <zypp/detail/PackageImpl.h>
+#include <zypp/Script.h>
+#include <zypp/detail/ScriptImpl.h>
+#include <zypp/Resolvable.h>
+#include <zypp/detail/ResolvableImpl.h>
+#include <zypp/Capability.h>
+#include <zypp/capability/CapabilityImpl.h>
+
+#include <zypp/parser/yum/YUMParser.h>
+#include <zypp/base/Logger.h>
+#include <zypp/source/yum/YUMScriptImpl.h>
+#include <zypp/source/yum/YUMMessageImpl.h>
+#include <zypp/source/yum/YUMPackageImpl.h>
+#include <zypp/source/yum/YUMSource.h>
+
+#include <map>
+#include <set>
+
+#include <zypp/CapFactory.h>
+
+using namespace zypp::detail;
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::parser::yum;
+using namespace zypp::source::yum;
 using namespace zypp::storage;
+using namespace DbXml;
+
+/*
+class YUMSerializer : public base::ReferenceCounted, private base::NonCopyable
+{
+       public:
+       friend std::ostream & operator<<( std::ostream & str, const YUMSerializer & obj );
+       typedef intrusive_ptr<PatchYUMSerializer> Ptr;
+       typedef intrusive_ptr<const PatchYUMSerializer> constPtr;
+       YUMSerializer( Resolvable::constPtr resolvable )
+       {
+               m_resolvable = resolvable;
+       }
+       private:
+       Resolvable::constPtr m_resolvable;
+};
+*/
+
+class XMLBackend : public base::ReferenceCounted, private base::NonCopyable
+{
+       public:
+       //friend std::ostream & operator<<( std::ostream & str, const PatchYUMSerializer & obj );
+       typedef intrusive_ptr<XMLBackend> Ptr;
+       typedef intrusive_ptr<const XMLBackend> constPtr;
+
+  void initDatabase()
+  {
+    // Get a manager object.
+    XmlManager myManager;
+    // Open a container
+    XmlContainer myContainer =  myManager.openContainer("zypp_db.dbxml");
+  }
+
+       XMLBackend()
+       {
+               
+       }
+  protected:
+  const std::string serializePatch( Patch::constPtr patch ) const
+  {
+    std::string str;
+    //ostream str(buffer);
+    str += "<patch>\n";
+    /*
+    str << "  xmlns=\"http://novell.com/package/metadata/suse/patch\"" << endl;
+    str << "  xmlns:patch=\"http://novell.com/package/metadata/suse/patch\"" << endl;
+    str << "  xmlns:yum=\"http://linux.duke.edu/metadata/common\"" << endl;
+    str << "  xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\"" << endl;
+    str << "  xmlns:suse=\"http://novell.com/package/metadata/suse/common\"" << endl;
+    str << "  patchid=\"" << obj.m_patch->id() << "\"" <<  endl;
+    str << "  timestamp=\"" << obj.m_patch->timestamp() << "\"" << endl;
+    str << "  engine=\"1.0\">" << endl;
+    str << "  <yum:name>" << obj.m_patch->name() << "</yum:name>" << endl;
+    str << "  <summary lang=\"en\">"  << obj.m_patch->summary() << "</summary>" << endl;
+    */
+    str += "</patch>\n";
+    return str;
+  }
+
+
+       private:
+       //std::ostream & operator<<( std::ostream & str, const PatchYUMSerializer & obj )
+};
+
+
 
 int main()
 {
-       PersistentStorage ps;
-       ps.doTest();
-       return 1;
+       //zypp::storage::PersistentStorage ps;
+       //ps.doTest();
+
+       //INT << "===[START]==========================================" << endl;
+       //RpmDb db;
+       //DBG << "===[DB OBJECT CREATED]==============================" << endl;
+       //db.initDatabase();
+       //DBG << "===[DATABASE INITIALIZED]===========================" << endl;
+       //std::list<Package::Ptr> packages = db.getPackages();
+       //for (std::list<Package::Ptr>::const_iterator it = packages.begin(); it != packages.end(); it++)
+       //{
+       //      DBG << **it << endl;
+       //}
+       //INT << "===[END]============================================" << endl;
+
+       INT << "===[START]==========================================" << endl;
+       YUMSource src;
+       Patch::Ptr patch1;
+       
+       //YUMPatchParser iter(cin,"");
+       ifstream patch_file("patch.xml");
+       YUMPatchParser iter(patch_file,"");
+       for (; !iter.atEnd(); ++iter)
+       {
+               patch1 = src.createPatch(**iter);
+       }
+       if (iter.errorStatus())
+               throw *iter.errorStatus();
+
+       // process the patch
+       
+       DBG << patch1 << endl;
+       DBG << *patch1 << endl;
+       DBG << patch1->deps() << endl;
+       Patch::AtomList at = patch1->atoms();
+       for (Patch::AtomList::iterator it = at.begin(); it != at.end(); it++)
+       {
+               DBG << **it << endl;
+               DBG << (**it).deps() << endl;
+       }
+       INT << "===[END]============================================" << endl;
+       //PatchYUMSerializer serializer(patch1);
+       //DBG << endl << serializer << endl;
+       return 1;       
 }
 
+/*
+#include "DbXml.hpp"
+...
+
+using namespace DbXml;
+int main(void)
+{
+    XmlManager myManager;   // The manager is closed when
+                            // it goes out of scope.
+
+    // Assumes the container currently exists.
+    myManager.renameContainer("/export/xml/myContainer.bdbxml",
+                              "/export2/xml/myContainer.bdbxml");
+
+
+    myManager.removeContainer("/export2/xml/myContainer.bdbxml");
+
+    return(0);
+} 
+*/
+