move store to target
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Wed, 18 Jan 2006 16:18:21 +0000 (16:18 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Wed, 18 Jan 2006 16:18:21 +0000 (16:18 +0000)
24 files changed:
devel/devel.dmacvicar/Backend.cc [deleted file]
devel/devel.dmacvicar/Backend.h [deleted file]
devel/devel.dmacvicar/Makefile.am [deleted file]
devel/devel.dmacvicar/PersistentStorage.cc [deleted file]
devel/devel.dmacvicar/PersistentStorage.h [deleted file]
devel/devel.dmacvicar/XMLFilesBackend.cc [deleted file]
devel/devel.dmacvicar/XMLFilesBackend.h [deleted file]
devel/devel.dmacvicar/parser_utils.hpp [deleted file]
devel/devel.dmacvicar/serialize.cc [deleted file]
devel/devel.dmacvicar/serialize.h [deleted file]
devel/devel.dmacvicar/xml_escape_parser.cpp [deleted file]
devel/devel.dmacvicar/xml_escape_parser.hpp [deleted file]
zypp/target/store/Backend.cc [new file with mode: 0644]
zypp/target/store/Backend.h [new file with mode: 0644]
zypp/target/store/Makefile.am [new file with mode: 0644]
zypp/target/store/PersistentStorage.cc [new file with mode: 0644]
zypp/target/store/PersistentStorage.h [new file with mode: 0644]
zypp/target/store/XMLFilesBackend.cc [new file with mode: 0644]
zypp/target/store/XMLFilesBackend.h [new file with mode: 0644]
zypp/target/store/parser_utils.hpp [new file with mode: 0644]
zypp/target/store/serialize.cc [new file with mode: 0644]
zypp/target/store/serialize.h [new file with mode: 0644]
zypp/target/store/xml_escape_parser.cpp [new file with mode: 0644]
zypp/target/store/xml_escape_parser.hpp [new file with mode: 0644]

diff --git a/devel/devel.dmacvicar/Backend.cc b/devel/devel.dmacvicar/Backend.cc
deleted file mode 100644 (file)
index 3ac7cac..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/Backend.cc
-*
-*/
-#include <iostream>
-//#include "zypp/base/Logger.h"
-
-#include "devel/devel.dmacvicar/Backend.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-       ///////////////////////////////////////////////////////////////////
-       namespace storage
-       { 
-               ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : Backend
-    //
-    ///////////////////////////////////////////////////////////////////
-               class Backend::Private
-               {
-               };
-
-               ///////////////////////////////////////////////////////////////////
-               //
-               //      CLASS NAME : Backend
-               //
-               ///////////////////////////////////////////////////////////////////
-
-
-               ///////////////////////////////////////////////////////////////////
-               //
-               //      METHOD NAME : Backend::Backend
-               //      METHOD TYPE : Ctor
-               //
-               Backend::Backend()
-               {}
-
-               ///////////////////////////////////////////////////////////////////
-               //
-               //      METHOD NAME : Backend::~Backend
-               //      METHOD TYPE : Dtor
-               //
-               Backend::~Backend()
-               {}
-
-               /******************************************************************
-               **
-               **      FUNCTION NAME : operator<<
-               **      FUNCTION TYPE : std::ostream &
-               */
-               std::ostream & operator<<( std::ostream & str, const Backend & obj )
-               {
-                       return str;
-               }
-
-               /////////////////////////////////////////////////////////////////
-       } // namespace devel.dmacvicar
-       ///////////////////////////////////////////////////////////////////
-       /////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
diff --git a/devel/devel.dmacvicar/Backend.h b/devel/devel.dmacvicar/Backend.h
deleted file mode 100644 (file)
index 093d843..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/Backend.h
-*
-*/
-#ifndef DEVEL_DEVEL_DMACVICAR_BACKEND_H
-#define DEVEL_DEVEL_DMACVICAR_BACKEND_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include <zypp/Patch.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-       ///////////////////////////////////////////////////////////////////
-       namespace storage
-       { /////////////////////////////////////////////////////////////////
-
-               ///////////////////////////////////////////////////////////////////
-               //
-               //      CLASS NAME : Backend
-               //
-               /** */
-               class Backend
-               {
-                       friend std::ostream & operator<<( std::ostream & str, const Backend & obj );
-               public:
-                       /** Default ctor */
-                       Backend();
-                       /** Dtor */
-                       virtual ~Backend();
-                       virtual void doTest() = 0;
-
-      /**
-       * is the storage backend initialized
-       */
-                       virtual bool isBackendInitialized() = 0;
-      /**
-       * initialize the storage backend
-       */
-                       virtual void initBackend() = 0;
-
-      /**
-       * Stores a Resolvable in the active backend.
-       */
-      virtual void storeObject( Resolvable::Ptr resolvable )  = 0;
-      /**
-       * Deletes a Resolvable from the active backend.
-       */
-      virtual void deleteObject( Resolvable::Ptr resolvable ) = 0;
-     
-      /**
-       * Query for installed Resolvables.
-       */
-      virtual std::list<Resolvable::Ptr> storedObjects() = 0;
-       /**
-       * Query for installed Resolvables of a certain kind
-       */
-      virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind) = 0;
-       /**
-       * Query for installed Resolvables of a certain kind by name
-       * \a partial_match allows for text search.
-       */
-      virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match = false) = 0;
-
-               private:
-                       /** Pointer to implementation */
-                       class Private;
-                       Private *d;
-               };
-               ///////////////////////////////////////////////////////////////////
-
-               /** \relates Backend Stream output */
-               std::ostream & operator<<( std::ostream & str, const Backend & obj );
-
-               /////////////////////////////////////////////////////////////////
-       } // namespace devel.dmacvicar
-       ///////////////////////////////////////////////////////////////////
-       /////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
-#endif // DEVEL_DEVEL_DMACVICAR_BACKEND_H
diff --git a/devel/devel.dmacvicar/Makefile.am b/devel/devel.dmacvicar/Makefile.am
deleted file mode 100644 (file)
index 84f5bf5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-## Process this file with automake to produce Makefile.in
-## ##################################################
-
-noinst_PROGRAMS =      test2 test2_debug
-
-#Main Main.debug Parse
-
-## ##################################################
-
-INCLUDES =
-
-AM_LDFLAGS = -pg
-
-AM_CXXFLAGS =
-# gperf:       -pg
-
-
-# -ldbxml -lpathan -lxerces-c -lxquery
-LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la -lboost_regex -lboost_filesystem -ldb -ldb_cxx 
-#LDADD =       -lboost_regex -lsqlite3 -dbxml
-
-## ##################################################
-
-test2_SOURCES = test2.cc PersistentStorage.cc Backend.cc XMLFilesBackend.cc serialize.cc xml_escape_parser.cpp
-
-test2_debug_SOURCES =  $(test2_SOURCES)
-test2_debug_LDFLAGS =  -static
-
-## ##################################################
-
-test1_SOURCES = test-sqlite.cc
-
-test1_debug_SOURCES =  $(test1_SOURCES)
-test1_debug_LDFLAGS =  -static
-
-## ##################################################
-
-#Main_SOURCES =                Main.cc
-
-#Main_debug_SOURCES =  $(Main_SOURCES)
-#Main_debug_LDFLAGS =  -static
-
-## ##################################################
-
-#Parse_SOURCES =       Parse.cc
-#Parse_LDFLAGS =               -static
-
-## ##################################################
-
-.PHONY:        always
-
-$(noinst_PROGRAMS):    $(top_srcdir)/zypp/lib@PACKAGE@.la
-
-$(top_srcdir)/zypp/lib@PACKAGE@.la:     always
-       $(MAKE) -C $(top_srcdir)/zypp
-
-## ##################################################
diff --git a/devel/devel.dmacvicar/PersistentStorage.cc b/devel/devel.dmacvicar/PersistentStorage.cc
deleted file mode 100644 (file)
index 6a53e02..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/PersistentStorage.cc
-*
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-
-#include "devel/devel.dmacvicar/PersistentStorage.h"
-#include "devel/devel.dmacvicar/Backend.h"
-#include "devel/devel.dmacvicar/XMLFilesBackend.h"
-//#include "devel/devel.dmacvicar/BDBBackend.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace storage
-{
-///////////////////////////////////////////////////////////////////
-//
-//     CLASS NAME : PersistentStoragePrivate
-//
-///////////////////////////////////////////////////////////////////
-class PersistentStorage::Private
-{
-  public:
-  Backend *backend;
-};
-
-///////////////////////////////////////////////////////////////////
-//
-//     CLASS NAME : PersistentStorage
-//
-///////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-//     METHOD NAME : PersistentStorage::PersistentStorage
-//     METHOD TYPE : Ctor
-//
-PersistentStorage::PersistentStorage()
-{
-  d = new Private;
-  DBG << "  Creating XML Files backend" << endl;
-  d->backend = new XMLFilesBackend();
-}
-
-///////////////////////////////////////////////////////////////////
-//
-//     METHOD NAME : PersistentStorage::~PersistentStorage
-//     METHOD TYPE : Dtor
-//
-PersistentStorage::~PersistentStorage()
-{}
-
-    ///////////////////////////////////////////////////////////////////
-//
-//     METHOD NAME : PersistentStorage::~PersistentStorage
-//     METHOD TYPE : Dtor
-//
-void PersistentStorage::doTest()
-{
-  d->backend->doTest();
-}
-
-void
-PersistentStorage::storeObject( Resolvable::Ptr resolvable )
-{
-  d->backend->storeObject(resolvable);
-}
-
-void
-PersistentStorage::deleteObject( Resolvable::Ptr resolvable )
-{
-
-}
-
-
-std::list<Resolvable::Ptr>
-PersistentStorage::storedObjects()
-{
-  return d->backend->storedObjects();
-}
-
-std::list<Resolvable::Ptr>
-PersistentStorage::storedObjects(const Resolvable::Kind kind)
-{
-  //list<Resolvable::Ptr>::iterator it;
-  //it = find(nums.begin(), nums.end(), 3); // Search the list.
-  return d->backend->storedObjects(kind);
-}
-
-std::list<Resolvable::Ptr>
-PersistentStorage::storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match)
-{
-  return d->backend->storedObjects(kind, name, partial_match);
-}
-
-/******************************************************************
-**
-**     FUNCTION NAME : operator<<
-**     FUNCTION TYPE : std::ostream &
-*/
-std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj )
-{
-  //return str << *obj._pimpl;
-  return str;
-}
-  /////////////////////////////////////////////////////////////////
-} // namespace devel.dmacvicar
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
diff --git a/devel/devel.dmacvicar/PersistentStorage.h b/devel/devel.dmacvicar/PersistentStorage.h
deleted file mode 100644 (file)
index 7865b80..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/PersistentStorage.h
-*
-*/
-#ifndef DEVEL_DEVEL_DMACVICAR_PERSISTENTSTORAGE_H
-#define DEVEL_DEVEL_DMACVICAR_PERSISTENTSTORAGE_H
-
-#include <iosfwd>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-#include <zypp/Patch.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
-  namespace storage
-  { /////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : PersistentStorage
-    //
-    /** */
-    class PersistentStorage : public base::ReferenceCounted, private base::NonCopyable
-    {
-      friend std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
-      typedef intrusive_ptr<PersistentStorage> Ptr;
-      typedef intrusive_ptr<const PersistentStorage> constPtr;
-    public:
-      /** Default ctor */
-      PersistentStorage();
-      /** Dtor */
-      ~PersistentStorage();
-      void doTest();
-
-    public:
-      /**
-       * Stores a Resolvable in the active backend.
-       */
-      void storeObject( Resolvable::Ptr resolvable );
-      /**
-       * Deletes a Resolvable from the active backend.
-       */
-      void deleteObject( Resolvable::Ptr resolvable );
-      /**
-       * Query for installed Resolvables.
-       */
-      std::list<Resolvable::Ptr> storedObjects();
-       /**
-       * Query for installed Resolvables of a certain kind.
-       */
-      std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind kind);
-       /**
-       * Query for installed Resolvables of a certain kind by name
-       * \a partial_match allows for text search.
-       */
-      std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match = false);
-
-    private:
-      class Private;
-      Private *d;
-    };
-    ///////////////////////////////////////////////////////////////////
-    /** \relates PersistentStorage Stream output */
-    std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
-
-    /////////////////////////////////////////////////////////////////
-  } // namespace devel.dmacvicar
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
-#endif // DEVEL_DEVEL_DMACVICAR_PERSISTENTSTORAGE_H
diff --git a/devel/devel.dmacvicar/XMLFilesBackend.cc b/devel/devel.dmacvicar/XMLFilesBackend.cc
deleted file mode 100644 (file)
index 01778f3..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/XMLFilesBackend.cc
-*
-*/
-#include <iostream>
-#include <ctime>
-#include "zypp/base/Logger.h"
-
-#include "zypp/source/yum/YUMSourceImpl.h"
-#include "zypp/parser/yum/YUMParser.h"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <streambuf>
-
-#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
-#include "boost/filesystem/fstream.hpp"    // ditto
-
-#include "XMLFilesBackend.h"
-#include "serialize.h"
-#include <list>
-
-#define ZYPP_DB_DIR "zypp_db"
-
-using std::endl;
-using namespace boost::filesystem;
-//using namespace boost::iostreams;
-using namespace zypp::parser::yum;
-using namespace zypp::source::yum;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-//     CLASS NAME : XMLFilesBackend::Private
-//
-///////////////////////////////////////////////////////////////////
-class XMLFilesBackend::Private
-{
-  public:
-       YUMSourceImpl source;
-};
-
-///////////////////////////////////////////////////////////////////
-//
-//     CLASS NAME : XMLFilesBackend
-//
-///////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-//     METHOD NAME : XMLFilesBackend::XMLFilesBackend
-//     METHOD TYPE : Ctor
-//
-XMLFilesBackend::XMLFilesBackend()
-{
-  d = new Private;
-       // check if the db exists
-       if (!isBackendInitialized())
-       {
-               DBG << "Database not initialized" << std::endl;
-               initBackend();
-    // should be initialized now...
-               if (!isBackendInitialized())
-                       DBG << "Error, cant init database" << std::endl;
-               else
-                       DBG << "Database initialized" << std::endl;
-       }
-       else
-       {
-               DBG << "Database already initialized" << std::endl;
-       }
-}
-
-
-bool
-XMLFilesBackend::isBackendInitialized()
-{
-  return exists( ZYPP_DB_DIR );
-}
-
-void
-XMLFilesBackend::initBackend()
-{
-  // FIXME duncan * handle exceptions
-  DBG << "Creating directory structure..." << std::endl;
-  create_directory( path(ZYPP_DB_DIR) );
-  create_directory( path(ZYPP_DB_DIR) / path("patches") );
-  create_directory( path(ZYPP_DB_DIR) / path("selections") );
-  create_directory( path(ZYPP_DB_DIR) / path("products") );
-}
-
-std::string
-XMLFilesBackend::dirForResolvableKind( Resolvable::Kind kind ) const
-{
-  std::string dir;
-  // FIXME replace with path class of boost
-  dir += std::string(ZYPP_DB_DIR);
-  dir += "/";
-  dir += resolvableKindToString(kind, true);
-  return dir;
-}
-
-std::string
-XMLFilesBackend::dirForResolvable( Resolvable::Ptr resolvable ) const
-{
-  return dirForResolvableKind(resolvable->kind());
-}
-
-std::string
-XMLFilesBackend::fullPathForResolvable( Resolvable::Ptr resolvable ) const
-{
-  std::string filename;
-  filename = dirForResolvable(resolvable) + "/";
-  filename += resolvable->name();
-  return filename;
-}
-
-void
-XMLFilesBackend::storeObject( Resolvable::Ptr resolvable )
-{
-  std::string xml = castedToXML(resolvable);
-  std::string filename = fullPathForResolvable(resolvable);
-  DBG << std::endl << xml << std::endl;
-  std::ofstream file;
-  DBG << filename << std::endl;
-  file.open(filename.c_str());
-  file << xml;
-  file.close();
-}
-
-void
-XMLFilesBackend::deleteObject( Resolvable::Ptr resolvable )
-{}
-
-Resolvable::Ptr XMLFilesBackend::resolvableFromFile( std::string file_path, Resolvable::Kind kind ) const
-{
-  DBG << "[" << resolvableKindToString( kind, false ) << "] - " << file_path << std::endl;
-  Resolvable::Ptr resolvable;
-  std::ifstream res_file(file_path.c_str());
-  if ( kind == ResTraits<zypp::Patch>::kind )
-  {
-    // a patch file can contain more than one patch, but we store only
-    // one patch, so we break at the first
-    // FIXME how can we avoid creating this for every object?
-    YUMPatchParser iter(res_file,"");
-    for (; !iter.atEnd(); ++iter)
-    {
-      resolvable = d->source.createPatch(**iter);
-      break;
-    }
-  }
-  else
-  {
-    resolvable = 0;
-  }
-  return resolvable;
-}
-
-std::list<Resolvable::Ptr>
-XMLFilesBackend::storedObjects()
-{
-  std::list<Resolvable::Ptr> objects;
-  std::list<Resolvable::Kind> kinds;
-  // only patches for now
-  kinds.push_back(ResTraits<zypp::Patch>::kind);
-
-  std::list<Resolvable::Kind>::const_iterator it_kinds;
-  for ( it_kinds = kinds.begin() ; it_kinds != kinds.end(); ++it_kinds )
-  {
-    Resolvable::Kind kind = (*it_kinds);
-    // patches
-    if ( kind == ResTraits<zypp::Patch>::kind )
-    {
-      std::string dir_path = dirForResolvableKind(kind);
-      DBG << "objects in ... " << dir_path << std::endl;
-      directory_iterator end_iter;
-      if ( !exists( dir_path ) ) continue;
-      for ( directory_iterator dir_itr( dir_path ); dir_itr != end_iter; ++dir_itr )
-      {
-        DBG << "[" << resolvableKindToString( kind, false ) << "] - " << dir_itr->leaf() << std::endl;
-        objects.push_back( resolvableFromFile( dir_path + "/" + dir_itr->leaf(), kind) );
-      }
-    }
-  }
-  return objects;
-}
-
-std::list<Resolvable::Ptr>
-XMLFilesBackend::storedObjects(const Resolvable::Kind)
-{
-  return storedObjects();
-}
-
-std::list<Resolvable::Ptr>
-XMLFilesBackend::storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match)
-{
-  return storedObjects();
-}
-
-std::string
-XMLFilesBackend::randomFileName() const
-{
-  FILE *fp;
-  char puffer[49];
-  if ( (fp = popen("openssl rand -base64 48", "r")) == 0)
-  {
-    DBG << "mierda!" << std::endl;
-    //ZYPP_THROW("put some message here");
-  }
-  fscanf(fp, "%s", &puffer);
-  pclose(fp);
-  return "blah";
-}
-
-///////////////////////////////////////////////////////////////////
-//
-//     METHOD NAME : XMLFilesBackend::~XMLFilesBackend
-//     METHOD TYPE : Dtor
-//
-XMLFilesBackend::~XMLFilesBackend()
-{
-  delete d;
-}
-
-///////////////////////////////////////////////////////////////////
-//
-//     METHOD NAME : XMLFilesBackend::doTest()
-//     METHOD TYPE : Dtor
-//
-void XMLFilesBackend::doTest()
-{}
-
-/******************************************************************
-**
-**     FUNCTION NAME : operator<<
-**     FUNCTION TYPE : std::ostream &
-*/
-std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj )
-{
-       return str;
-}
-
-               /////////////////////////////////////////////////////////////////
-       } // namespace devel.dmacvicar
-       ///////////////////////////////////////////////////////////////////
-       /////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
diff --git a/devel/devel.dmacvicar/XMLFilesBackend.h b/devel/devel.dmacvicar/XMLFilesBackend.h
deleted file mode 100644 (file)
index 68831d6..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/XMLFilesBackend.h
-*
-*/
-#ifndef DEVEL_DEVEL_DMACVICAR_XMLFILESBACKEND_H
-#define DEVEL_DEVEL_DMACVICAR_XMLFILESBACKEND_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include "Backend.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-//     CLASS NAME : XMLFilesBackend
-//
-/** */
-class XMLFilesBackend : public Backend
-{
-  friend std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj );
-public:
-  typedef intrusive_ptr<XMLFilesBackend> Ptr;
-  typedef intrusive_ptr<const XMLFilesBackend> constPtr;
-
-  public:
-  /** Default ctor */
-  XMLFilesBackend();
-  /** Dtor */
-  ~XMLFilesBackend();
-  virtual void doTest();
-
-  /**
-    * is the storage backend initialized
-    */
-  virtual bool isBackendInitialized();
-  /**
-    * initialize the storage backend
-    */
-  virtual void initBackend();
-  /**
-    * Stores a Resolvable in the active backend.
-    */
-  virtual void storeObject( Resolvable::Ptr resolvable ) ;
-  /**
-    * Deletes a Resolvable from the active backend.
-    */
-  virtual void deleteObject( Resolvable::Ptr resolvable );
-  /**
-    * Deletes a Resolvable from the active backend.
-    */
-  virtual std::list<Resolvable::Ptr> storedObjects();
-   /**
-    * Query for installed Resolvables of a certain kind
-    */
-  virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind);
-  /**
-    * Query for installed Resolvables of a certain kind by name
-    * \a partial_match allows for text search.
-    */
-  virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match = false);
-
-  protected:
-  std::string randomFileName() const;
-  /**
-    * Directory where the xml file is stored (for the given resolvable)
-    */
-  std::string dirForResolvable( Resolvable::Ptr resolvable ) const;
-  /**
-    * Directory where the xml file is stored (for the given resolvable kind)
-    */
-  std::string dirForResolvableKind( Resolvable::Kind kind ) const;
-  /**
-    * Full path to the xml file for a given resolvable
-    * Does not care if the resolvable is yet stored or not
-    */
-  std::string fullPathForResolvable( Resolvable::Ptr resolvable ) const;
-   /**
-    * Full path to the xml file for a given resolvable
-    * Does not care if the resolvable is yet stored or not
-    */
-  Resolvable::Ptr resolvableFromFile( std::string file_path, Resolvable::Kind kind ) const;
-
-  private:
-  class Private;
-  Private *d;
-};
-
-///////////////////////////////////////////////////////////////////
-/** \relates XMLFilesBackend Stream output */
-std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj );
-/////////////////////////////////////////////////////////////////
-} // namespace devel.dmacvicar
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
-#endif // DEVEL_DEVEL_DMACVICAR_SQLITEBACKEND_H
diff --git a/devel/devel.dmacvicar/parser_utils.hpp b/devel/devel.dmacvicar/parser_utils.hpp
deleted file mode 100644 (file)
index 492b4de..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*\r
-IoBind Library License:\r
---------------------------\r
-\r
-The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
-\r
-This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
-\r
-Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
-\r
-1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
-\r
-2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
-\r
-3. This notice may not be removed or altered from any source distribution\r
-*/\r
-\r
-\r
-#ifndef IOBIND_PARSER_UTILS_HPP\r
-#define IOBIND_PARSER_UTILS_HPP\r
-\r
-#include <boost/spirit.hpp>\r
-#include <boost/call_traits.hpp>\r
-#include <string>\r
-\r
-namespace iobind{\r
-namespace parser{\r
-namespace detail{\r
-\r
-template<\r
-       typename Container,\r
-       typename Policy\r
-> \r
-class append_with_policy\r
-{\r
-public:\r
-    append_with_policy( Container& container_, Policy const& policy_)\r
-        : m_container(container_), m_policy(policy_)\r
-    {};\r
-\r
-    // the method called by the parser    \r
-    template <typename IteratorT>\r
-    void operator()(IteratorT const& first, IteratorT const& last) const\r
-    {\r
-               m_container.insert(m_container.end(), m_policy.encode( std::string(first, last) ) );\r
-    }\r
-\r
-private:\r
-    Container& m_container;\r
-       Policy const& m_policy;\r
-};\r
-\r
-template<\r
-       typename Container,\r
-       typename Policy\r
-> \r
-class insert_with_policy\r
-{\r
-public:\r
-    insert_with_policy( size_t& index_, Container& container_, Policy const& policy_)\r
-        : m_index(index_), m_container(container_), m_policy(policy_)\r
-    {};\r
-\r
-    // the method called by the parser    \r
-    template <typename IteratorT>\r
-    void operator()(IteratorT const& first, IteratorT const& last) const\r
-    {\r
-               if (m_index < m_container.size())\r
-                       m_container[m_index++]=m_policy.encode( std::string(first, last) );\r
-#ifdef _DEBUG\r
-               else\r
-                       std::cerr<<"insert_with_policy: could not add data"<<std::endl;\r
-#endif\r
-       }\r
-\r
-private:\r
-       size_t& m_index;\r
-    Container& m_container;\r
-       Policy const& m_policy;\r
-};\r
-\r
-template<\r
-       typename Pair,\r
-       typename FirstPolicy,\r
-       typename SecondPolicy\r
-> \r
-class assign_pair_with_policy\r
-{\r
-public:\r
\r
-       explicit assign_pair_with_policy( \r
-               Pair& pair_, \r
-               FirstPolicy const& first_policy_,\r
-               SecondPolicy const& second_policy_,\r
-               std::string const& first_,\r
-               std::string const& second_\r
-               )\r
-        : \r
-               m_pair(pair_), \r
-               m_first_policy(first_policy_),\r
-               m_second_policy(second_policy_),\r
-               m_first(first_),\r
-               m_second(second_)\r
-    {};\r
-\r
-    // the method called by the parser    \r
-    template <typename IteratorT>\r
-    void operator()(IteratorT first, IteratorT last) const\r
-    {\r
-               m_pair=Pair(\r
-                       m_first_policy.encode(m_first.c_str()),\r
-                       m_second_policy.encode(m_second.c_str())\r
-                       );\r
-    }\r
-\r
-private:\r
-    Pair& m_pair;\r
-       FirstPolicy const& m_first_policy;\r
-       SecondPolicy const& m_second_policy;\r
-       std::string const& m_first;\r
-       std::string const& m_second;\r
-};\r
-\r
-class concat_string\r
-{\r
-public:\r
-    // key_ and val_ should point to the string modified in keyvalue_grammar\r
-    // kvc_ is the map of key - values\r
-    concat_string( std::ostream& out_)\r
-        : out(out_)\r
-    {  };\r
-\r
-    // the method called by the parser    \r
-    template <typename IteratorT>\r
-    void operator()(IteratorT first, IteratorT last) const\r
-    {\r
-               out<<std::string(first,last);\r
-    }\r
-\r
-       template <typename IteratorT>\r
-       void operator()(IteratorT single) const\r
-       {\r
-               out<<single;\r
-       }\r
-private:\r
-    std::ostream& out;\r
-};\r
-\r
-class concat_symbol\r
-{\r
-public:\r
-    // key_ and val_ should point to the string modified in keyvalue_grammar\r
-    // kvc_ is the map of key - values\r
-    concat_symbol( std::ostream& out_)\r
-        : out(out_)\r
-    {  };\r
-\r
-    // the method called by the parser    \r
-       void operator()(std::string const& str) const\r
-       {\r
-               out<<str;\r
-       }\r
-private:\r
-    std::ostream& out;\r
-};\r
-\r
-class concat_pre_post_symbol\r
-{\r
-public:\r
-    // key_ and val_ should point to the string modified in keyvalue_grammar\r
-    // kvc_ is the map of key - values\r
-    concat_pre_post_symbol( std::ostream& out_, std::string const& pre_, std::string const& post_)\r
-        : m_out(out_),m_pre(pre_), m_post(post_)\r
-    {  };\r
-\r
-    // the method called by the parser    \r
-       void operator()(std::string const& str_) const\r
-       {\r
-               m_out<<m_pre<<str_<<m_post;\r
-       }\r
-private:\r
-    std::ostream& m_out;\r
-       std::string m_pre;\r
-       std::string m_post;\r
-};\r
-\r
-};//details\r
-};//parser\r
-};//iobind\r
-\r
-#endif\r
-\r
-\r
diff --git a/devel/devel.dmacvicar/serialize.cc b/devel/devel.dmacvicar/serialize.cc
deleted file mode 100644 (file)
index adfd974..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/SQLiteBackend.cc
-*
-*/
-#include <iostream>
-#include <ctime>
-#include <fstream>
-#include <sstream>
-#include <streambuf>
-
-#include "zypp/base/Logger.h"
-#include "zypp/CapFactory.h"
-
-#include "serialize.h"
-#include "xml_escape_parser.hpp"
-
-using namespace std;
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-
-std::string xml_escape( const std::string &text )
-{
-  iobind::parser::xml_escape_parser parser;
-  return parser.escape(text);
-}
-
-std::string xml_tag_enclose( const std::string &text, const std::string &tag, bool escape = false )
-{
-  std::string result;
-  result += "<" + tag + ">";
-  
-  if ( escape)
-   result += xml_escape(text);
-  else
-   result += text;
-
-  result += "</" + tag + ">";
-  return result;
-}
-
-template<class T>
-std::string toXML( T obj ); //undefined
-
-template<> // or constPtr?
-std::string toXML( const Edition edition )
-{
-  stringstream out;
-  // sad the yum guys did not acll it edition
-  out << "<version ver=\"" << edition.version() << "\" rel=\"" << edition.release() << "\"/>";
-  return out.str();
-}
-
-template<> // or constPtr?
-std::string toXML( const Arch arch )
-{
-  stringstream out;
-  out << xml_tag_enclose(arch.asString(), "arch");
-  return out.str();
-}
-
-template<> // or constPtr?
-std::string toXML( Capability cap )
-{
-  stringstream out;
-  CapFactory factory;
-  
-  out << "<entry kind=\"" << cap.refers() << "\" >" <<  xml_escape(factory.encode(cap)) << "</entry>";
-  return out.str();
-}
-
-template<> // or constPtr?
-std::string toXML( const CapSet caps )
-{
-  stringstream out;
-  CapSet::iterator it = caps.begin();
-  for ( ; it != caps.end(); ++it)
-  {
-    out << toXML((*it));
-  }
-  return out.str(); 
-}
-
-template<> // or constPtr?
-std::string toXML( const Dependencies dep )
-{
-  stringstream out;
-  if ( dep.provides.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.provides), "provides") << std::endl;
-  if ( dep.prerequires.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.prerequires), "prerequires") << std::endl;
-  if ( dep.requires.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.requires), "requires") << std::endl;
-  if ( dep.conflicts.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.conflicts), "conflicts") << std::endl;
-   if ( dep.obsoletes.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.obsoletes), "obsoletes") << std::endl;
-  // why the YUM tag is freshen without s????
-   if ( dep.freshens.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.freshens), "freshen") << std::endl;
-   if ( dep.suggests.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.suggests), "suggests") << std::endl;
-   if ( dep.recommends.size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep.recommends), "recommends") << std::endl;
-  return out.str();
-  
-}
-
-template<> // or constPtr?
-std::string toXML( Resolvable::Ptr obj )
-{
-  stringstream out;
-  
-  out << "  <name>" << obj->name() << "</name>" << std::endl;
-  // is this shared? uh
-  out << "  " << toXML(obj->edition()) << std::endl;
-  out << "  " << toXML(obj->arch()) << std::endl;
-  out << "  " << toXML(obj->deps()) << std::endl;
-  return out.str();
-}
-
-template<> // or constPtr?
-std::string toXML( Package::Ptr obj )
-{
-  stringstream out;
-  out << "<package>" << std::endl;
-  // reuse Resolvable information serialize function
-  toXML(static_cast<Resolvable::Ptr>(obj));
-  //out << "  <do>" << std::endl;
-  //out << "      " << obj->do_script() << std::endl;
-  //out << "  </do>" << std::endl;
-  out << "</package>" << std::endl;
-  return out.str();
-}
-
-template<> // or constPtr?
-std::string toXML( Script::Ptr obj )
-{
-  stringstream out;
-  out << "<script>" << std::endl;
-  // reuse Resolvable information serialize function
-  out << toXML(static_cast<Resolvable::Ptr>(obj));
-  out << "  <do>" << std::endl;
-  out << "      " << obj->do_script() << std::endl;
-  out << "  </do>" << std::endl;
-  if ( obj->undo_available() )
-  {
-    out << "  <undo>" << std::endl;
-    out << "      " << obj->undo_script() << std::endl;
-    out << "  </undo>" << std::endl;
-  }
-  out << "</script>" << std::endl;
-  return out.str();
-}
-
-
-
-template<> // or constPtr?
-std::string toXML( Message::Ptr obj )
-{
-  stringstream out;
-  out << "<message type=\"" << obj->type() << "\">" << std::endl;
-  // reuse Resolvable information serialize function
-  out << toXML(static_cast<Resolvable::Ptr>(obj));
-  out << "  <text>" << obj->text() << "</text>" << std::endl;
-  out << "</message>" << std::endl;
-  return out.str();
-}
-
-// or constPtr?
-std::string castedToXML( Resolvable::Ptr resolvable )
-{
-  stringstream out;
-  if ( isKind<Package>(resolvable) )
-     out << toXML(asKind<Package>(resolvable)) << std::endl;
-  if ( isKind<Patch>(resolvable) )
-     out << toXML(asKind<Patch>(resolvable)) << std::endl;
-  if ( isKind<Message>(resolvable) )
-     out << toXML(asKind<Message>(resolvable)) << std::endl;
-  if ( isKind<Script>(resolvable) )
-     out << toXML(asKind<Script>(resolvable)) << std::endl;
-  return out.str();
-}
-
-// or constPtr?
-std::string resolvableTypeToString( Resolvable::Ptr resolvable, bool plural )
-{
-  return resolvableKindToString(resolvable->kind(), plural);
-}
-
-std::string resolvableKindToString( Resolvable::Kind kind, bool plural)
-{
-  if ( kind == ResTraits<zypp::Package>::kind )
-     return plural ? "packages" : "package";
-  if ( kind == ResTraits<zypp::Patch>::kind )
-     return plural ? "patches" : "patch";
-  if ( kind == ResTraits<zypp::Message>::kind )
-     return plural ? "messages" : "message";
-  if ( kind == ResTraits<zypp::Script>::kind )
-     return plural ? "scripts" : "script";
-  return "";
-}
-
-template<> // or constPtr?
-std::string toXML( Patch::Ptr obj )
-{
-  stringstream out;
-  out << "<patch>" << std::endl;
-  // reuse Resolvable information serialize function
-  out << toXML(static_cast<Resolvable::Ptr>(obj));
-  Patch::AtomList at = obj->atoms();
-  for (Patch::AtomList::iterator it = at.begin(); it != at.end(); it++)
-  {
-    // atoms tag here looks weird but lets follow YUM
-    out << "  <atoms>" << std::endl;
-    // I have a better idea to avoid the cast here (Michaels code in his tmp/)
-    Resolvable::Ptr one_atom = *it;
-    out << castedToXML(one_atom) << std::endl;
-    out << "  </atoms>" << std::endl;
-  }
-  out << "</patch>" << std::endl;
-  return out.str();
-}
-
-
-
-/////////////////////////////////////////////////////////////////
-} // namespace devel.dmacvicar
-       ///////////////////////////////////////////////////////////////////
-       /////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
diff --git a/devel/devel.dmacvicar/serialize.h b/devel/devel.dmacvicar/serialize.h
deleted file mode 100644 (file)
index 609f47c..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      devel/devel.dmacvicar/SQLiteBackend.h
-*
-*/
-#ifndef DEVEL_DEVEL_DMACVICAR_SERIALIZE_H
-#define DEVEL_DEVEL_DMACVICAR_SERIALIZE_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include "devel/devel.dmacvicar/Backend.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/Script.h>
-#include <zypp/Message.h>
-#include <zypp/Edition.h>
-#include <zypp/CapSet.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>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace storage
-{ /////////////////////////////////////////////////////////////////
-
-template<class T>
-std::string toXML( T obj ); //undefined
-
-template<> // or constPtr?
-std::string toXML( const Edition edition );
-
-template<> // or constPtr?
-std::string toXML( const Arch arch );
-
-template<> // or constPtr?
-std::string toXML( Capability cap );
-
-template<> // or constPtr?
-std::string toXML( const CapSet caps );
-
-template<> // or constPtr?
-std::string toXML( const Dependencies dep );
-
-/**
- * Serialize Resolvable properties
- * NOTE: This wont serialize child classes properties
- * Use castedToXML for that.
- */
-template<> // or constPtr?
-std::string toXML( Resolvable::Ptr obj );
-
-/**
- * Serialize properties based in the specific kind of the Resolvable
- */
-std::string castedToXML( Resolvable::Ptr ret );
-
-/**
- * lack of instrospection sucks
- */
-std::string resolvableTypeToString( Resolvable::Ptr resolvable, bool plural = false );
-
-/**
- * lack of instrospection sucks
- */
-std::string resolvableKindToString( Resolvable::Kind kind, bool plural = false );
-
-template<> // or constPtr?
-std::string toXML( Package::Ptr obj );
-
-template<> // or constPtr?
-std::string toXML( Script::Ptr obj );
-
-template<> // or constPtr?
-std::string toXML( Message::Ptr obj );
-
-template<> // or constPtr?
-std::string toXML( Patch::Ptr obj );
-
-/////////////////////////////////////////////////////////////////
-} // namespace devel.dmacvicar
-       ///////////////////////////////////////////////////////////////////
-       /////////////////////////////////////////////////////////////////
-} // namespace devel
-///////////////////////////////////////////////////////////////////
-#endif // DEVEL_DEVEL_DMACVICAR_SQLITEBACKEND_H
diff --git a/devel/devel.dmacvicar/xml_escape_parser.cpp b/devel/devel.dmacvicar/xml_escape_parser.cpp
deleted file mode 100644 (file)
index 6d0cd67..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*\r
-IoBind Library License:\r
---------------------------\r
-\r
-The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
-\r
-This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
-\r
-Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
-\r
-1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
-\r
-2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
-\r
-3. This notice may not be removed or altered from any source distribution\r
-*/\r
-\r
-\r
-#include <string>\r
-#include <sstream>\r
-#include <boost/format.hpp>\r
-#include <boost/spirit.hpp> \r
-#include "parser_utils.hpp"\r
-#include "xml_escape_parser.hpp"\r
-\r
-\r
-namespace iobind{\r
-namespace parser{\r
-namespace detail{\r
-\r
-struct escapes : boost::spirit::symbols<std::string>\r
-{\r
-    escapes()\r
-    {\r
-        add\r
-            ("<"    , "lt")\r
-            (">"    , "gt")\r
-            ("&"    , "amp")\r
-            ("'"    , "apos")\r
-            ("\""    , "quot")\r
-        ;\r
-    }\r
-\r
-} escapes_p;\r
-\r
-struct unescapes : boost::spirit::symbols<std::string>\r
-{\r
-    unescapes()\r
-    {\r
-        add\r
-            ("lt", "<")\r
-            ("gt",">")\r
-            ("amp","&")\r
-            ("apos","\'")\r
-            ("quot","\"")\r
-        ;\r
-    }\r
-} unescapes_p;\r
-\r
-struct unescape_from_xml_grammar : boost::spirit::grammar<unescape_from_xml_grammar>\r
-{\r
-       std::ostream& out;\r
-\r
-       explicit unescape_from_xml_grammar( std::ostream& out_)\r
-               :out(out_){};\r
-\r
-   template <typename ScannerT>\r
-   struct definition\r
-   {    \r
-        definition(unescape_from_xml_grammar const& self)  \r
-               {\r
-                       using namespace boost::spirit;\r
-\r
-                       begin = ch_p('&');\r
-                       end = ch_p(';');\r
-                       // the rest is ok\r
-                       encoded_string=\r
-                               *( \r
-                                        begin >> unescapes_p[concat_symbol(self.out)] >> end\r
-                                  | anychar_p[concat_string(self.out)]\r
-                                );\r
-               };\r
-\r
-               boost::spirit::rule<ScannerT> encoded_string, begin, end;\r
-               boost::spirit::rule<ScannerT> const& start() const { return encoded_string; };\r
-   };\r
-};\r
-\r
-struct escape_to_xml_grammar : boost::spirit::grammar<escape_to_xml_grammar>\r
-{\r
-       std::ostream& out;\r
-\r
-       explicit escape_to_xml_grammar( std::ostream& out_)\r
-               :out(out_){};\r
-  \r
-   template <typename ScannerT>\r
-   struct definition\r
-   {    \r
-        definition(escape_to_xml_grammar const& self)  \r
-               {\r
-                       using namespace boost::spirit;\r
-                       concat_pre_post_symbol concatener(self.out, "&", ";");\r
-\r
-                       // the rest is ok\r
-                       encoded_string=\r
-                               *( \r
-                                        escapes_p[concatener]\r
-                                  | anychar_p[concat_string(self.out)]\r
-                                );\r
-               };\r
-\r
-               boost::spirit::rule<ScannerT> encoded_string;\r
-               boost::spirit::rule<ScannerT> const& start() const { return encoded_string; };\r
-   };\r
-};\r
-\r
-}; //details\r
-\r
-\r
-std::string xml_escape_parser::escape( std::string const& str) const\r
-{\r
-       using namespace boost::spirit;\r
-\r
-       std::ostringstream out;\r
-\r
-       parse_info<> info = boost::spirit::parse(\r
-               str.c_str(), \r
-                          detail::escape_to_xml_grammar(out)\r
-                          );\r
-\r
-       return out.str();\r
-};\r
-\r
-std::string xml_escape_parser::unescape( std::string const& str) const\r
-{\r
-       using namespace boost::spirit;\r
-\r
-       std::ostringstream out;\r
-\r
-       parse_info<> info = boost::spirit::parse(\r
-               str.c_str(), \r
-               detail::unescape_from_xml_grammar(out)\r
-                          );\r
-\r
-       return out.str();\r
-};\r
-}; // parser\r
-}; // iobind\r
-\r
diff --git a/devel/devel.dmacvicar/xml_escape_parser.hpp b/devel/devel.dmacvicar/xml_escape_parser.hpp
deleted file mode 100644 (file)
index 205d2a7..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*\r
-IoBind Library License:\r
---------------------------\r
-\r
-The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
-\r
-This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
-\r
-Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
-\r
-1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
-\r
-2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
-\r
-3. This notice may not be removed or altered from any source distribution\r
-*/\r
-\r
-\r
-#ifndef IOBIND_XML_ESCAPE_PARSER_HPP\r
-#define IOBIND_XML_ESCAPE_PARSER_HPP\r
-\r
-#include<string>\r
-\r
-namespace iobind{\r
-namespace parser{\r
-\r
-       struct xml_escape_parser\r
-       {\r
-               std::string escape( std::string const&) const;\r
-               std::string unescape( std::string const&) const;\r
-       };\r
-};\r
-};//iobind\r
-\r
-#endif\r
-\r
-\r
diff --git a/zypp/target/store/Backend.cc b/zypp/target/store/Backend.cc
new file mode 100644 (file)
index 0000000..3ac7cac
--- /dev/null
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/Backend.cc
+*
+*/
+#include <iostream>
+//#include "zypp/base/Logger.h"
+
+#include "devel/devel.dmacvicar/Backend.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+       ///////////////////////////////////////////////////////////////////
+       namespace storage
+       { 
+               ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : Backend
+    //
+    ///////////////////////////////////////////////////////////////////
+               class Backend::Private
+               {
+               };
+
+               ///////////////////////////////////////////////////////////////////
+               //
+               //      CLASS NAME : Backend
+               //
+               ///////////////////////////////////////////////////////////////////
+
+
+               ///////////////////////////////////////////////////////////////////
+               //
+               //      METHOD NAME : Backend::Backend
+               //      METHOD TYPE : Ctor
+               //
+               Backend::Backend()
+               {}
+
+               ///////////////////////////////////////////////////////////////////
+               //
+               //      METHOD NAME : Backend::~Backend
+               //      METHOD TYPE : Dtor
+               //
+               Backend::~Backend()
+               {}
+
+               /******************************************************************
+               **
+               **      FUNCTION NAME : operator<<
+               **      FUNCTION TYPE : std::ostream &
+               */
+               std::ostream & operator<<( std::ostream & str, const Backend & obj )
+               {
+                       return str;
+               }
+
+               /////////////////////////////////////////////////////////////////
+       } // namespace devel.dmacvicar
+       ///////////////////////////////////////////////////////////////////
+       /////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/target/store/Backend.h b/zypp/target/store/Backend.h
new file mode 100644 (file)
index 0000000..093d843
--- /dev/null
@@ -0,0 +1,90 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/Backend.h
+*
+*/
+#ifndef DEVEL_DEVEL_DMACVICAR_BACKEND_H
+#define DEVEL_DEVEL_DMACVICAR_BACKEND_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+#include <zypp/Patch.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+       ///////////////////////////////////////////////////////////////////
+       namespace storage
+       { /////////////////////////////////////////////////////////////////
+
+               ///////////////////////////////////////////////////////////////////
+               //
+               //      CLASS NAME : Backend
+               //
+               /** */
+               class Backend
+               {
+                       friend std::ostream & operator<<( std::ostream & str, const Backend & obj );
+               public:
+                       /** Default ctor */
+                       Backend();
+                       /** Dtor */
+                       virtual ~Backend();
+                       virtual void doTest() = 0;
+
+      /**
+       * is the storage backend initialized
+       */
+                       virtual bool isBackendInitialized() = 0;
+      /**
+       * initialize the storage backend
+       */
+                       virtual void initBackend() = 0;
+
+      /**
+       * Stores a Resolvable in the active backend.
+       */
+      virtual void storeObject( Resolvable::Ptr resolvable )  = 0;
+      /**
+       * Deletes a Resolvable from the active backend.
+       */
+      virtual void deleteObject( Resolvable::Ptr resolvable ) = 0;
+     
+      /**
+       * Query for installed Resolvables.
+       */
+      virtual std::list<Resolvable::Ptr> storedObjects() = 0;
+       /**
+       * Query for installed Resolvables of a certain kind
+       */
+      virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind) = 0;
+       /**
+       * Query for installed Resolvables of a certain kind by name
+       * \a partial_match allows for text search.
+       */
+      virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match = false) = 0;
+
+               private:
+                       /** Pointer to implementation */
+                       class Private;
+                       Private *d;
+               };
+               ///////////////////////////////////////////////////////////////////
+
+               /** \relates Backend Stream output */
+               std::ostream & operator<<( std::ostream & str, const Backend & obj );
+
+               /////////////////////////////////////////////////////////////////
+       } // namespace devel.dmacvicar
+       ///////////////////////////////////////////////////////////////////
+       /////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
+#endif // DEVEL_DEVEL_DMACVICAR_BACKEND_H
diff --git a/zypp/target/store/Makefile.am b/zypp/target/store/Makefile.am
new file mode 100644 (file)
index 0000000..84f5bf5
--- /dev/null
@@ -0,0 +1,57 @@
+## Process this file with automake to produce Makefile.in
+## ##################################################
+
+noinst_PROGRAMS =      test2 test2_debug
+
+#Main Main.debug Parse
+
+## ##################################################
+
+INCLUDES =
+
+AM_LDFLAGS = -pg
+
+AM_CXXFLAGS =
+# gperf:       -pg
+
+
+# -ldbxml -lpathan -lxerces-c -lxquery
+LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la -lboost_regex -lboost_filesystem -ldb -ldb_cxx 
+#LDADD =       -lboost_regex -lsqlite3 -dbxml
+
+## ##################################################
+
+test2_SOURCES = test2.cc PersistentStorage.cc Backend.cc XMLFilesBackend.cc serialize.cc xml_escape_parser.cpp
+
+test2_debug_SOURCES =  $(test2_SOURCES)
+test2_debug_LDFLAGS =  -static
+
+## ##################################################
+
+test1_SOURCES = test-sqlite.cc
+
+test1_debug_SOURCES =  $(test1_SOURCES)
+test1_debug_LDFLAGS =  -static
+
+## ##################################################
+
+#Main_SOURCES =                Main.cc
+
+#Main_debug_SOURCES =  $(Main_SOURCES)
+#Main_debug_LDFLAGS =  -static
+
+## ##################################################
+
+#Parse_SOURCES =       Parse.cc
+#Parse_LDFLAGS =               -static
+
+## ##################################################
+
+.PHONY:        always
+
+$(noinst_PROGRAMS):    $(top_srcdir)/zypp/lib@PACKAGE@.la
+
+$(top_srcdir)/zypp/lib@PACKAGE@.la:     always
+       $(MAKE) -C $(top_srcdir)/zypp
+
+## ##################################################
diff --git a/zypp/target/store/PersistentStorage.cc b/zypp/target/store/PersistentStorage.cc
new file mode 100644 (file)
index 0000000..6a53e02
--- /dev/null
@@ -0,0 +1,123 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/PersistentStorage.cc
+*
+*/
+#include <iostream>
+#include "zypp/base/Logger.h"
+
+#include "devel/devel.dmacvicar/PersistentStorage.h"
+#include "devel/devel.dmacvicar/Backend.h"
+#include "devel/devel.dmacvicar/XMLFilesBackend.h"
+//#include "devel/devel.dmacvicar/BDBBackend.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace storage
+{
+///////////////////////////////////////////////////////////////////
+//
+//     CLASS NAME : PersistentStoragePrivate
+//
+///////////////////////////////////////////////////////////////////
+class PersistentStorage::Private
+{
+  public:
+  Backend *backend;
+};
+
+///////////////////////////////////////////////////////////////////
+//
+//     CLASS NAME : PersistentStorage
+//
+///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+//     METHOD NAME : PersistentStorage::PersistentStorage
+//     METHOD TYPE : Ctor
+//
+PersistentStorage::PersistentStorage()
+{
+  d = new Private;
+  DBG << "  Creating XML Files backend" << endl;
+  d->backend = new XMLFilesBackend();
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//     METHOD NAME : PersistentStorage::~PersistentStorage
+//     METHOD TYPE : Dtor
+//
+PersistentStorage::~PersistentStorage()
+{}
+
+    ///////////////////////////////////////////////////////////////////
+//
+//     METHOD NAME : PersistentStorage::~PersistentStorage
+//     METHOD TYPE : Dtor
+//
+void PersistentStorage::doTest()
+{
+  d->backend->doTest();
+}
+
+void
+PersistentStorage::storeObject( Resolvable::Ptr resolvable )
+{
+  d->backend->storeObject(resolvable);
+}
+
+void
+PersistentStorage::deleteObject( Resolvable::Ptr resolvable )
+{
+
+}
+
+
+std::list<Resolvable::Ptr>
+PersistentStorage::storedObjects()
+{
+  return d->backend->storedObjects();
+}
+
+std::list<Resolvable::Ptr>
+PersistentStorage::storedObjects(const Resolvable::Kind kind)
+{
+  //list<Resolvable::Ptr>::iterator it;
+  //it = find(nums.begin(), nums.end(), 3); // Search the list.
+  return d->backend->storedObjects(kind);
+}
+
+std::list<Resolvable::Ptr>
+PersistentStorage::storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match)
+{
+  return d->backend->storedObjects(kind, name, partial_match);
+}
+
+/******************************************************************
+**
+**     FUNCTION NAME : operator<<
+**     FUNCTION TYPE : std::ostream &
+*/
+std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj )
+{
+  //return str << *obj._pimpl;
+  return str;
+}
+  /////////////////////////////////////////////////////////////////
+} // namespace devel.dmacvicar
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/target/store/PersistentStorage.h b/zypp/target/store/PersistentStorage.h
new file mode 100644 (file)
index 0000000..7865b80
--- /dev/null
@@ -0,0 +1,82 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/PersistentStorage.h
+*
+*/
+#ifndef DEVEL_DEVEL_DMACVICAR_PERSISTENTSTORAGE_H
+#define DEVEL_DEVEL_DMACVICAR_PERSISTENTSTORAGE_H
+
+#include <iosfwd>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/PtrTypes.h"
+#include <zypp/Patch.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace storage
+  { /////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : PersistentStorage
+    //
+    /** */
+    class PersistentStorage : public base::ReferenceCounted, private base::NonCopyable
+    {
+      friend std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
+      typedef intrusive_ptr<PersistentStorage> Ptr;
+      typedef intrusive_ptr<const PersistentStorage> constPtr;
+    public:
+      /** Default ctor */
+      PersistentStorage();
+      /** Dtor */
+      ~PersistentStorage();
+      void doTest();
+
+    public:
+      /**
+       * Stores a Resolvable in the active backend.
+       */
+      void storeObject( Resolvable::Ptr resolvable );
+      /**
+       * Deletes a Resolvable from the active backend.
+       */
+      void deleteObject( Resolvable::Ptr resolvable );
+      /**
+       * Query for installed Resolvables.
+       */
+      std::list<Resolvable::Ptr> storedObjects();
+       /**
+       * Query for installed Resolvables of a certain kind.
+       */
+      std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind kind);
+       /**
+       * Query for installed Resolvables of a certain kind by name
+       * \a partial_match allows for text search.
+       */
+      std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match = false);
+
+    private:
+      class Private;
+      Private *d;
+    };
+    ///////////////////////////////////////////////////////////////////
+    /** \relates PersistentStorage Stream output */
+    std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace devel.dmacvicar
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
+#endif // DEVEL_DEVEL_DMACVICAR_PERSISTENTSTORAGE_H
diff --git a/zypp/target/store/XMLFilesBackend.cc b/zypp/target/store/XMLFilesBackend.cc
new file mode 100644 (file)
index 0000000..01778f3
--- /dev/null
@@ -0,0 +1,261 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/XMLFilesBackend.cc
+*
+*/
+#include <iostream>
+#include <ctime>
+#include "zypp/base/Logger.h"
+
+#include "zypp/source/yum/YUMSourceImpl.h"
+#include "zypp/parser/yum/YUMParser.h"
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <streambuf>
+
+#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
+#include "boost/filesystem/fstream.hpp"    // ditto
+
+#include "XMLFilesBackend.h"
+#include "serialize.h"
+#include <list>
+
+#define ZYPP_DB_DIR "zypp_db"
+
+using std::endl;
+using namespace boost::filesystem;
+//using namespace boost::iostreams;
+using namespace zypp::parser::yum;
+using namespace zypp::source::yum;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace storage
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+//     CLASS NAME : XMLFilesBackend::Private
+//
+///////////////////////////////////////////////////////////////////
+class XMLFilesBackend::Private
+{
+  public:
+       YUMSourceImpl source;
+};
+
+///////////////////////////////////////////////////////////////////
+//
+//     CLASS NAME : XMLFilesBackend
+//
+///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+//     METHOD NAME : XMLFilesBackend::XMLFilesBackend
+//     METHOD TYPE : Ctor
+//
+XMLFilesBackend::XMLFilesBackend()
+{
+  d = new Private;
+       // check if the db exists
+       if (!isBackendInitialized())
+       {
+               DBG << "Database not initialized" << std::endl;
+               initBackend();
+    // should be initialized now...
+               if (!isBackendInitialized())
+                       DBG << "Error, cant init database" << std::endl;
+               else
+                       DBG << "Database initialized" << std::endl;
+       }
+       else
+       {
+               DBG << "Database already initialized" << std::endl;
+       }
+}
+
+
+bool
+XMLFilesBackend::isBackendInitialized()
+{
+  return exists( ZYPP_DB_DIR );
+}
+
+void
+XMLFilesBackend::initBackend()
+{
+  // FIXME duncan * handle exceptions
+  DBG << "Creating directory structure..." << std::endl;
+  create_directory( path(ZYPP_DB_DIR) );
+  create_directory( path(ZYPP_DB_DIR) / path("patches") );
+  create_directory( path(ZYPP_DB_DIR) / path("selections") );
+  create_directory( path(ZYPP_DB_DIR) / path("products") );
+}
+
+std::string
+XMLFilesBackend::dirForResolvableKind( Resolvable::Kind kind ) const
+{
+  std::string dir;
+  // FIXME replace with path class of boost
+  dir += std::string(ZYPP_DB_DIR);
+  dir += "/";
+  dir += resolvableKindToString(kind, true);
+  return dir;
+}
+
+std::string
+XMLFilesBackend::dirForResolvable( Resolvable::Ptr resolvable ) const
+{
+  return dirForResolvableKind(resolvable->kind());
+}
+
+std::string
+XMLFilesBackend::fullPathForResolvable( Resolvable::Ptr resolvable ) const
+{
+  std::string filename;
+  filename = dirForResolvable(resolvable) + "/";
+  filename += resolvable->name();
+  return filename;
+}
+
+void
+XMLFilesBackend::storeObject( Resolvable::Ptr resolvable )
+{
+  std::string xml = castedToXML(resolvable);
+  std::string filename = fullPathForResolvable(resolvable);
+  DBG << std::endl << xml << std::endl;
+  std::ofstream file;
+  DBG << filename << std::endl;
+  file.open(filename.c_str());
+  file << xml;
+  file.close();
+}
+
+void
+XMLFilesBackend::deleteObject( Resolvable::Ptr resolvable )
+{}
+
+Resolvable::Ptr XMLFilesBackend::resolvableFromFile( std::string file_path, Resolvable::Kind kind ) const
+{
+  DBG << "[" << resolvableKindToString( kind, false ) << "] - " << file_path << std::endl;
+  Resolvable::Ptr resolvable;
+  std::ifstream res_file(file_path.c_str());
+  if ( kind == ResTraits<zypp::Patch>::kind )
+  {
+    // a patch file can contain more than one patch, but we store only
+    // one patch, so we break at the first
+    // FIXME how can we avoid creating this for every object?
+    YUMPatchParser iter(res_file,"");
+    for (; !iter.atEnd(); ++iter)
+    {
+      resolvable = d->source.createPatch(**iter);
+      break;
+    }
+  }
+  else
+  {
+    resolvable = 0;
+  }
+  return resolvable;
+}
+
+std::list<Resolvable::Ptr>
+XMLFilesBackend::storedObjects()
+{
+  std::list<Resolvable::Ptr> objects;
+  std::list<Resolvable::Kind> kinds;
+  // only patches for now
+  kinds.push_back(ResTraits<zypp::Patch>::kind);
+
+  std::list<Resolvable::Kind>::const_iterator it_kinds;
+  for ( it_kinds = kinds.begin() ; it_kinds != kinds.end(); ++it_kinds )
+  {
+    Resolvable::Kind kind = (*it_kinds);
+    // patches
+    if ( kind == ResTraits<zypp::Patch>::kind )
+    {
+      std::string dir_path = dirForResolvableKind(kind);
+      DBG << "objects in ... " << dir_path << std::endl;
+      directory_iterator end_iter;
+      if ( !exists( dir_path ) ) continue;
+      for ( directory_iterator dir_itr( dir_path ); dir_itr != end_iter; ++dir_itr )
+      {
+        DBG << "[" << resolvableKindToString( kind, false ) << "] - " << dir_itr->leaf() << std::endl;
+        objects.push_back( resolvableFromFile( dir_path + "/" + dir_itr->leaf(), kind) );
+      }
+    }
+  }
+  return objects;
+}
+
+std::list<Resolvable::Ptr>
+XMLFilesBackend::storedObjects(const Resolvable::Kind)
+{
+  return storedObjects();
+}
+
+std::list<Resolvable::Ptr>
+XMLFilesBackend::storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match)
+{
+  return storedObjects();
+}
+
+std::string
+XMLFilesBackend::randomFileName() const
+{
+  FILE *fp;
+  char puffer[49];
+  if ( (fp = popen("openssl rand -base64 48", "r")) == 0)
+  {
+    DBG << "mierda!" << std::endl;
+    //ZYPP_THROW("put some message here");
+  }
+  fscanf(fp, "%s", &puffer);
+  pclose(fp);
+  return "blah";
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//     METHOD NAME : XMLFilesBackend::~XMLFilesBackend
+//     METHOD TYPE : Dtor
+//
+XMLFilesBackend::~XMLFilesBackend()
+{
+  delete d;
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//     METHOD NAME : XMLFilesBackend::doTest()
+//     METHOD TYPE : Dtor
+//
+void XMLFilesBackend::doTest()
+{}
+
+/******************************************************************
+**
+**     FUNCTION NAME : operator<<
+**     FUNCTION TYPE : std::ostream &
+*/
+std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj )
+{
+       return str;
+}
+
+               /////////////////////////////////////////////////////////////////
+       } // namespace devel.dmacvicar
+       ///////////////////////////////////////////////////////////////////
+       /////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/target/store/XMLFilesBackend.h b/zypp/target/store/XMLFilesBackend.h
new file mode 100644 (file)
index 0000000..68831d6
--- /dev/null
@@ -0,0 +1,110 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/XMLFilesBackend.h
+*
+*/
+#ifndef DEVEL_DEVEL_DMACVICAR_XMLFILESBACKEND_H
+#define DEVEL_DEVEL_DMACVICAR_XMLFILESBACKEND_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+#include "Backend.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace storage
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+//
+//     CLASS NAME : XMLFilesBackend
+//
+/** */
+class XMLFilesBackend : public Backend
+{
+  friend std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj );
+public:
+  typedef intrusive_ptr<XMLFilesBackend> Ptr;
+  typedef intrusive_ptr<const XMLFilesBackend> constPtr;
+
+  public:
+  /** Default ctor */
+  XMLFilesBackend();
+  /** Dtor */
+  ~XMLFilesBackend();
+  virtual void doTest();
+
+  /**
+    * is the storage backend initialized
+    */
+  virtual bool isBackendInitialized();
+  /**
+    * initialize the storage backend
+    */
+  virtual void initBackend();
+  /**
+    * Stores a Resolvable in the active backend.
+    */
+  virtual void storeObject( Resolvable::Ptr resolvable ) ;
+  /**
+    * Deletes a Resolvable from the active backend.
+    */
+  virtual void deleteObject( Resolvable::Ptr resolvable );
+  /**
+    * Deletes a Resolvable from the active backend.
+    */
+  virtual std::list<Resolvable::Ptr> storedObjects();
+   /**
+    * Query for installed Resolvables of a certain kind
+    */
+  virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind);
+  /**
+    * Query for installed Resolvables of a certain kind by name
+    * \a partial_match allows for text search.
+    */
+  virtual std::list<Resolvable::Ptr> storedObjects(const Resolvable::Kind, const std::string & name, bool partial_match = false);
+
+  protected:
+  std::string randomFileName() const;
+  /**
+    * Directory where the xml file is stored (for the given resolvable)
+    */
+  std::string dirForResolvable( Resolvable::Ptr resolvable ) const;
+  /**
+    * Directory where the xml file is stored (for the given resolvable kind)
+    */
+  std::string dirForResolvableKind( Resolvable::Kind kind ) const;
+  /**
+    * Full path to the xml file for a given resolvable
+    * Does not care if the resolvable is yet stored or not
+    */
+  std::string fullPathForResolvable( Resolvable::Ptr resolvable ) const;
+   /**
+    * Full path to the xml file for a given resolvable
+    * Does not care if the resolvable is yet stored or not
+    */
+  Resolvable::Ptr resolvableFromFile( std::string file_path, Resolvable::Kind kind ) const;
+
+  private:
+  class Private;
+  Private *d;
+};
+
+///////////////////////////////////////////////////////////////////
+/** \relates XMLFilesBackend Stream output */
+std::ostream & operator<<( std::ostream & str, const XMLFilesBackend & obj );
+/////////////////////////////////////////////////////////////////
+} // namespace devel.dmacvicar
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
+#endif // DEVEL_DEVEL_DMACVICAR_SQLITEBACKEND_H
diff --git a/zypp/target/store/parser_utils.hpp b/zypp/target/store/parser_utils.hpp
new file mode 100644 (file)
index 0000000..492b4de
--- /dev/null
@@ -0,0 +1,193 @@
+/*\r
+IoBind Library License:\r
+--------------------------\r
+\r
+The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
+\r
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
+\r
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
+\r
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
+\r
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
+\r
+3. This notice may not be removed or altered from any source distribution\r
+*/\r
+\r
+\r
+#ifndef IOBIND_PARSER_UTILS_HPP\r
+#define IOBIND_PARSER_UTILS_HPP\r
+\r
+#include <boost/spirit.hpp>\r
+#include <boost/call_traits.hpp>\r
+#include <string>\r
+\r
+namespace iobind{\r
+namespace parser{\r
+namespace detail{\r
+\r
+template<\r
+       typename Container,\r
+       typename Policy\r
+> \r
+class append_with_policy\r
+{\r
+public:\r
+    append_with_policy( Container& container_, Policy const& policy_)\r
+        : m_container(container_), m_policy(policy_)\r
+    {};\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT const& first, IteratorT const& last) const\r
+    {\r
+               m_container.insert(m_container.end(), m_policy.encode( std::string(first, last) ) );\r
+    }\r
+\r
+private:\r
+    Container& m_container;\r
+       Policy const& m_policy;\r
+};\r
+\r
+template<\r
+       typename Container,\r
+       typename Policy\r
+> \r
+class insert_with_policy\r
+{\r
+public:\r
+    insert_with_policy( size_t& index_, Container& container_, Policy const& policy_)\r
+        : m_index(index_), m_container(container_), m_policy(policy_)\r
+    {};\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT const& first, IteratorT const& last) const\r
+    {\r
+               if (m_index < m_container.size())\r
+                       m_container[m_index++]=m_policy.encode( std::string(first, last) );\r
+#ifdef _DEBUG\r
+               else\r
+                       std::cerr<<"insert_with_policy: could not add data"<<std::endl;\r
+#endif\r
+       }\r
+\r
+private:\r
+       size_t& m_index;\r
+    Container& m_container;\r
+       Policy const& m_policy;\r
+};\r
+\r
+template<\r
+       typename Pair,\r
+       typename FirstPolicy,\r
+       typename SecondPolicy\r
+> \r
+class assign_pair_with_policy\r
+{\r
+public:\r
\r
+       explicit assign_pair_with_policy( \r
+               Pair& pair_, \r
+               FirstPolicy const& first_policy_,\r
+               SecondPolicy const& second_policy_,\r
+               std::string const& first_,\r
+               std::string const& second_\r
+               )\r
+        : \r
+               m_pair(pair_), \r
+               m_first_policy(first_policy_),\r
+               m_second_policy(second_policy_),\r
+               m_first(first_),\r
+               m_second(second_)\r
+    {};\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT first, IteratorT last) const\r
+    {\r
+               m_pair=Pair(\r
+                       m_first_policy.encode(m_first.c_str()),\r
+                       m_second_policy.encode(m_second.c_str())\r
+                       );\r
+    }\r
+\r
+private:\r
+    Pair& m_pair;\r
+       FirstPolicy const& m_first_policy;\r
+       SecondPolicy const& m_second_policy;\r
+       std::string const& m_first;\r
+       std::string const& m_second;\r
+};\r
+\r
+class concat_string\r
+{\r
+public:\r
+    // key_ and val_ should point to the string modified in keyvalue_grammar\r
+    // kvc_ is the map of key - values\r
+    concat_string( std::ostream& out_)\r
+        : out(out_)\r
+    {  };\r
+\r
+    // the method called by the parser    \r
+    template <typename IteratorT>\r
+    void operator()(IteratorT first, IteratorT last) const\r
+    {\r
+               out<<std::string(first,last);\r
+    }\r
+\r
+       template <typename IteratorT>\r
+       void operator()(IteratorT single) const\r
+       {\r
+               out<<single;\r
+       }\r
+private:\r
+    std::ostream& out;\r
+};\r
+\r
+class concat_symbol\r
+{\r
+public:\r
+    // key_ and val_ should point to the string modified in keyvalue_grammar\r
+    // kvc_ is the map of key - values\r
+    concat_symbol( std::ostream& out_)\r
+        : out(out_)\r
+    {  };\r
+\r
+    // the method called by the parser    \r
+       void operator()(std::string const& str) const\r
+       {\r
+               out<<str;\r
+       }\r
+private:\r
+    std::ostream& out;\r
+};\r
+\r
+class concat_pre_post_symbol\r
+{\r
+public:\r
+    // key_ and val_ should point to the string modified in keyvalue_grammar\r
+    // kvc_ is the map of key - values\r
+    concat_pre_post_symbol( std::ostream& out_, std::string const& pre_, std::string const& post_)\r
+        : m_out(out_),m_pre(pre_), m_post(post_)\r
+    {  };\r
+\r
+    // the method called by the parser    \r
+       void operator()(std::string const& str_) const\r
+       {\r
+               m_out<<m_pre<<str_<<m_post;\r
+       }\r
+private:\r
+    std::ostream& m_out;\r
+       std::string m_pre;\r
+       std::string m_post;\r
+};\r
+\r
+};//details\r
+};//parser\r
+};//iobind\r
+\r
+#endif\r
+\r
+\r
diff --git a/zypp/target/store/serialize.cc b/zypp/target/store/serialize.cc
new file mode 100644 (file)
index 0000000..adfd974
--- /dev/null
@@ -0,0 +1,241 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/SQLiteBackend.cc
+*
+*/
+#include <iostream>
+#include <ctime>
+#include <fstream>
+#include <sstream>
+#include <streambuf>
+
+#include "zypp/base/Logger.h"
+#include "zypp/CapFactory.h"
+
+#include "serialize.h"
+#include "xml_escape_parser.hpp"
+
+using namespace std;
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace storage
+{ /////////////////////////////////////////////////////////////////
+
+std::string xml_escape( const std::string &text )
+{
+  iobind::parser::xml_escape_parser parser;
+  return parser.escape(text);
+}
+
+std::string xml_tag_enclose( const std::string &text, const std::string &tag, bool escape = false )
+{
+  std::string result;
+  result += "<" + tag + ">";
+  
+  if ( escape)
+   result += xml_escape(text);
+  else
+   result += text;
+
+  result += "</" + tag + ">";
+  return result;
+}
+
+template<class T>
+std::string toXML( T obj ); //undefined
+
+template<> // or constPtr?
+std::string toXML( const Edition edition )
+{
+  stringstream out;
+  // sad the yum guys did not acll it edition
+  out << "<version ver=\"" << edition.version() << "\" rel=\"" << edition.release() << "\"/>";
+  return out.str();
+}
+
+template<> // or constPtr?
+std::string toXML( const Arch arch )
+{
+  stringstream out;
+  out << xml_tag_enclose(arch.asString(), "arch");
+  return out.str();
+}
+
+template<> // or constPtr?
+std::string toXML( Capability cap )
+{
+  stringstream out;
+  CapFactory factory;
+  
+  out << "<entry kind=\"" << cap.refers() << "\" >" <<  xml_escape(factory.encode(cap)) << "</entry>";
+  return out.str();
+}
+
+template<> // or constPtr?
+std::string toXML( const CapSet caps )
+{
+  stringstream out;
+  CapSet::iterator it = caps.begin();
+  for ( ; it != caps.end(); ++it)
+  {
+    out << toXML((*it));
+  }
+  return out.str(); 
+}
+
+template<> // or constPtr?
+std::string toXML( const Dependencies dep )
+{
+  stringstream out;
+  if ( dep.provides.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.provides), "provides") << std::endl;
+  if ( dep.prerequires.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.prerequires), "prerequires") << std::endl;
+  if ( dep.requires.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.requires), "requires") << std::endl;
+  if ( dep.conflicts.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.conflicts), "conflicts") << std::endl;
+   if ( dep.obsoletes.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.obsoletes), "obsoletes") << std::endl;
+  // why the YUM tag is freshen without s????
+   if ( dep.freshens.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.freshens), "freshen") << std::endl;
+   if ( dep.suggests.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.suggests), "suggests") << std::endl;
+   if ( dep.recommends.size() > 0 )
+    out << "    " << xml_tag_enclose(toXML(dep.recommends), "recommends") << std::endl;
+  return out.str();
+  
+}
+
+template<> // or constPtr?
+std::string toXML( Resolvable::Ptr obj )
+{
+  stringstream out;
+  
+  out << "  <name>" << obj->name() << "</name>" << std::endl;
+  // is this shared? uh
+  out << "  " << toXML(obj->edition()) << std::endl;
+  out << "  " << toXML(obj->arch()) << std::endl;
+  out << "  " << toXML(obj->deps()) << std::endl;
+  return out.str();
+}
+
+template<> // or constPtr?
+std::string toXML( Package::Ptr obj )
+{
+  stringstream out;
+  out << "<package>" << std::endl;
+  // reuse Resolvable information serialize function
+  toXML(static_cast<Resolvable::Ptr>(obj));
+  //out << "  <do>" << std::endl;
+  //out << "      " << obj->do_script() << std::endl;
+  //out << "  </do>" << std::endl;
+  out << "</package>" << std::endl;
+  return out.str();
+}
+
+template<> // or constPtr?
+std::string toXML( Script::Ptr obj )
+{
+  stringstream out;
+  out << "<script>" << std::endl;
+  // reuse Resolvable information serialize function
+  out << toXML(static_cast<Resolvable::Ptr>(obj));
+  out << "  <do>" << std::endl;
+  out << "      " << obj->do_script() << std::endl;
+  out << "  </do>" << std::endl;
+  if ( obj->undo_available() )
+  {
+    out << "  <undo>" << std::endl;
+    out << "      " << obj->undo_script() << std::endl;
+    out << "  </undo>" << std::endl;
+  }
+  out << "</script>" << std::endl;
+  return out.str();
+}
+
+
+
+template<> // or constPtr?
+std::string toXML( Message::Ptr obj )
+{
+  stringstream out;
+  out << "<message type=\"" << obj->type() << "\">" << std::endl;
+  // reuse Resolvable information serialize function
+  out << toXML(static_cast<Resolvable::Ptr>(obj));
+  out << "  <text>" << obj->text() << "</text>" << std::endl;
+  out << "</message>" << std::endl;
+  return out.str();
+}
+
+// or constPtr?
+std::string castedToXML( Resolvable::Ptr resolvable )
+{
+  stringstream out;
+  if ( isKind<Package>(resolvable) )
+     out << toXML(asKind<Package>(resolvable)) << std::endl;
+  if ( isKind<Patch>(resolvable) )
+     out << toXML(asKind<Patch>(resolvable)) << std::endl;
+  if ( isKind<Message>(resolvable) )
+     out << toXML(asKind<Message>(resolvable)) << std::endl;
+  if ( isKind<Script>(resolvable) )
+     out << toXML(asKind<Script>(resolvable)) << std::endl;
+  return out.str();
+}
+
+// or constPtr?
+std::string resolvableTypeToString( Resolvable::Ptr resolvable, bool plural )
+{
+  return resolvableKindToString(resolvable->kind(), plural);
+}
+
+std::string resolvableKindToString( Resolvable::Kind kind, bool plural)
+{
+  if ( kind == ResTraits<zypp::Package>::kind )
+     return plural ? "packages" : "package";
+  if ( kind == ResTraits<zypp::Patch>::kind )
+     return plural ? "patches" : "patch";
+  if ( kind == ResTraits<zypp::Message>::kind )
+     return plural ? "messages" : "message";
+  if ( kind == ResTraits<zypp::Script>::kind )
+     return plural ? "scripts" : "script";
+  return "";
+}
+
+template<> // or constPtr?
+std::string toXML( Patch::Ptr obj )
+{
+  stringstream out;
+  out << "<patch>" << std::endl;
+  // reuse Resolvable information serialize function
+  out << toXML(static_cast<Resolvable::Ptr>(obj));
+  Patch::AtomList at = obj->atoms();
+  for (Patch::AtomList::iterator it = at.begin(); it != at.end(); it++)
+  {
+    // atoms tag here looks weird but lets follow YUM
+    out << "  <atoms>" << std::endl;
+    // I have a better idea to avoid the cast here (Michaels code in his tmp/)
+    Resolvable::Ptr one_atom = *it;
+    out << castedToXML(one_atom) << std::endl;
+    out << "  </atoms>" << std::endl;
+  }
+  out << "</patch>" << std::endl;
+  return out.str();
+}
+
+
+
+/////////////////////////////////////////////////////////////////
+} // namespace devel.dmacvicar
+       ///////////////////////////////////////////////////////////////////
+       /////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/target/store/serialize.h b/zypp/target/store/serialize.h
new file mode 100644 (file)
index 0000000..609f47c
--- /dev/null
@@ -0,0 +1,103 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      devel/devel.dmacvicar/SQLiteBackend.h
+*
+*/
+#ifndef DEVEL_DEVEL_DMACVICAR_SERIALIZE_H
+#define DEVEL_DEVEL_DMACVICAR_SERIALIZE_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+#include "devel/devel.dmacvicar/Backend.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/Script.h>
+#include <zypp/Message.h>
+#include <zypp/Edition.h>
+#include <zypp/CapSet.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>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace storage
+{ /////////////////////////////////////////////////////////////////
+
+template<class T>
+std::string toXML( T obj ); //undefined
+
+template<> // or constPtr?
+std::string toXML( const Edition edition );
+
+template<> // or constPtr?
+std::string toXML( const Arch arch );
+
+template<> // or constPtr?
+std::string toXML( Capability cap );
+
+template<> // or constPtr?
+std::string toXML( const CapSet caps );
+
+template<> // or constPtr?
+std::string toXML( const Dependencies dep );
+
+/**
+ * Serialize Resolvable properties
+ * NOTE: This wont serialize child classes properties
+ * Use castedToXML for that.
+ */
+template<> // or constPtr?
+std::string toXML( Resolvable::Ptr obj );
+
+/**
+ * Serialize properties based in the specific kind of the Resolvable
+ */
+std::string castedToXML( Resolvable::Ptr ret );
+
+/**
+ * lack of instrospection sucks
+ */
+std::string resolvableTypeToString( Resolvable::Ptr resolvable, bool plural = false );
+
+/**
+ * lack of instrospection sucks
+ */
+std::string resolvableKindToString( Resolvable::Kind kind, bool plural = false );
+
+template<> // or constPtr?
+std::string toXML( Package::Ptr obj );
+
+template<> // or constPtr?
+std::string toXML( Script::Ptr obj );
+
+template<> // or constPtr?
+std::string toXML( Message::Ptr obj );
+
+template<> // or constPtr?
+std::string toXML( Patch::Ptr obj );
+
+/////////////////////////////////////////////////////////////////
+} // namespace devel.dmacvicar
+       ///////////////////////////////////////////////////////////////////
+       /////////////////////////////////////////////////////////////////
+} // namespace devel
+///////////////////////////////////////////////////////////////////
+#endif // DEVEL_DEVEL_DMACVICAR_SQLITEBACKEND_H
diff --git a/zypp/target/store/xml_escape_parser.cpp b/zypp/target/store/xml_escape_parser.cpp
new file mode 100644 (file)
index 0000000..6d0cd67
--- /dev/null
@@ -0,0 +1,149 @@
+/*\r
+IoBind Library License:\r
+--------------------------\r
+\r
+The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
+\r
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
+\r
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
+\r
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
+\r
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
+\r
+3. This notice may not be removed or altered from any source distribution\r
+*/\r
+\r
+\r
+#include <string>\r
+#include <sstream>\r
+#include <boost/format.hpp>\r
+#include <boost/spirit.hpp> \r
+#include "parser_utils.hpp"\r
+#include "xml_escape_parser.hpp"\r
+\r
+\r
+namespace iobind{\r
+namespace parser{\r
+namespace detail{\r
+\r
+struct escapes : boost::spirit::symbols<std::string>\r
+{\r
+    escapes()\r
+    {\r
+        add\r
+            ("<"    , "lt")\r
+            (">"    , "gt")\r
+            ("&"    , "amp")\r
+            ("'"    , "apos")\r
+            ("\""    , "quot")\r
+        ;\r
+    }\r
+\r
+} escapes_p;\r
+\r
+struct unescapes : boost::spirit::symbols<std::string>\r
+{\r
+    unescapes()\r
+    {\r
+        add\r
+            ("lt", "<")\r
+            ("gt",">")\r
+            ("amp","&")\r
+            ("apos","\'")\r
+            ("quot","\"")\r
+        ;\r
+    }\r
+} unescapes_p;\r
+\r
+struct unescape_from_xml_grammar : boost::spirit::grammar<unescape_from_xml_grammar>\r
+{\r
+       std::ostream& out;\r
+\r
+       explicit unescape_from_xml_grammar( std::ostream& out_)\r
+               :out(out_){};\r
+\r
+   template <typename ScannerT>\r
+   struct definition\r
+   {    \r
+        definition(unescape_from_xml_grammar const& self)  \r
+               {\r
+                       using namespace boost::spirit;\r
+\r
+                       begin = ch_p('&');\r
+                       end = ch_p(';');\r
+                       // the rest is ok\r
+                       encoded_string=\r
+                               *( \r
+                                        begin >> unescapes_p[concat_symbol(self.out)] >> end\r
+                                  | anychar_p[concat_string(self.out)]\r
+                                );\r
+               };\r
+\r
+               boost::spirit::rule<ScannerT> encoded_string, begin, end;\r
+               boost::spirit::rule<ScannerT> const& start() const { return encoded_string; };\r
+   };\r
+};\r
+\r
+struct escape_to_xml_grammar : boost::spirit::grammar<escape_to_xml_grammar>\r
+{\r
+       std::ostream& out;\r
+\r
+       explicit escape_to_xml_grammar( std::ostream& out_)\r
+               :out(out_){};\r
+  \r
+   template <typename ScannerT>\r
+   struct definition\r
+   {    \r
+        definition(escape_to_xml_grammar const& self)  \r
+               {\r
+                       using namespace boost::spirit;\r
+                       concat_pre_post_symbol concatener(self.out, "&", ";");\r
+\r
+                       // the rest is ok\r
+                       encoded_string=\r
+                               *( \r
+                                        escapes_p[concatener]\r
+                                  | anychar_p[concat_string(self.out)]\r
+                                );\r
+               };\r
+\r
+               boost::spirit::rule<ScannerT> encoded_string;\r
+               boost::spirit::rule<ScannerT> const& start() const { return encoded_string; };\r
+   };\r
+};\r
+\r
+}; //details\r
+\r
+\r
+std::string xml_escape_parser::escape( std::string const& str) const\r
+{\r
+       using namespace boost::spirit;\r
+\r
+       std::ostringstream out;\r
+\r
+       parse_info<> info = boost::spirit::parse(\r
+               str.c_str(), \r
+                          detail::escape_to_xml_grammar(out)\r
+                          );\r
+\r
+       return out.str();\r
+};\r
+\r
+std::string xml_escape_parser::unescape( std::string const& str) const\r
+{\r
+       using namespace boost::spirit;\r
+\r
+       std::ostringstream out;\r
+\r
+       parse_info<> info = boost::spirit::parse(\r
+               str.c_str(), \r
+               detail::unescape_from_xml_grammar(out)\r
+                          );\r
+\r
+       return out.str();\r
+};\r
+}; // parser\r
+}; // iobind\r
+\r
diff --git a/zypp/target/store/xml_escape_parser.hpp b/zypp/target/store/xml_escape_parser.hpp
new file mode 100644 (file)
index 0000000..205d2a7
--- /dev/null
@@ -0,0 +1,37 @@
+/*\r
+IoBind Library License:\r
+--------------------------\r
+\r
+The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux\r
+\r
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r
+\r
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\r
+\r
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r
+\r
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
+\r
+3. This notice may not be removed or altered from any source distribution\r
+*/\r
+\r
+\r
+#ifndef IOBIND_XML_ESCAPE_PARSER_HPP\r
+#define IOBIND_XML_ESCAPE_PARSER_HPP\r
+\r
+#include<string>\r
+\r
+namespace iobind{\r
+namespace parser{\r
+\r
+       struct xml_escape_parser\r
+       {\r
+               std::string escape( std::string const&) const;\r
+               std::string unescape( std::string const&) const;\r
+       };\r
+};\r
+};//iobind\r
+\r
+#endif\r
+\r
+\r