packages feed

BerkeleyDBXML 0.7 → 0.7.1

raw patch · 4 files changed

+109/−5 lines, 4 filesdep ~BerkeleyDB

Dependency ranges changed: BerkeleyDB

Files

BerkeleyDBXML.cabal view
@@ -1,10 +1,10 @@ name: BerkeleyDBXML-version: 0.7+version: 0.7.1 license: BSD3 license-file: LICENSE cabal-version: >= 1.6 copyright: (c) 2009 Stephen Blackheath, (c) 2010 typLAB-author: Stephen Blackheath+author: Stephen Blackheath, Erik Hesselink <erik@typlab.com> maintainer: http://blacksapphire.com/antispam/, typLAB <code@typlab.com> stability: beta synopsis: Berkeley DB XML binding@@ -37,7 +37,7 @@     exposed-modules: Database.Berkeley.DbXml     c-sources: Database/Berkeley/dbxml_helper.cpp -    build-depends: base == 4.*, bytestring >= 0.9, BerkeleyDB >= 0.8+    build-depends: base == 4.*, bytestring >= 0.9, BerkeleyDB >= 0.8.1     include-dirs: Database/Berkeley/-    extra-libraries: db, dbxml, xqilla, xerces-c, xml2+    extra-libraries: db, dbxml, xqilla, xerces-c, xml2, stdc++ 
Database/Berkeley/DbXml.hs view
@@ -18,6 +18,8 @@         xmlContainer_getName,         xmlContainer_putDocument,         xmlContainer_updateDocument,+        xmlContainer_addIndex,+        xmlContainer_deleteIndex,         -- * XmlDocument         XmlDocument,         xmlDocument_getContent,@@ -557,7 +559,7 @@     :: IO (Ptr XmlValue_struct)  xmlNone :: XmlValue-xmlNone = unsafePerformIO$ do+xmlNone = unsafePerformIO $ do     xv <- _xmlNone     newForeignPtr _xmlValue_delete xv @@ -815,6 +817,71 @@ xmlContainer_close cont =     withForeignPtr cont $ \cont_ ->         _xmlContainer_close cont_+        +foreign import ccall safe "dbxml_helper.h _xmlContainer_addIndex" _xmlContainer_addIndex+    :: Ptr XmlContainer_struct -> Ptr XmlTransaction_struct+    -> CString -> CString -> CString -> Ptr XmlUpdateContext_struct -> IO CInt++xmlContainer_addIndex :: XmlContainer+                      -> Maybe XmlTransaction+                      -> String   -- ^ The namespace of the node to be indexed.+                                  -- The default namespace is selected by passing+                                  -- an empty string for the namespace.+                      -> String   -- ^ The name of the element or attribute node to be indexed+                      -> String   -- ^ A comma-separated list of strings that represent+                                  -- the indexing strategy. The strings must contain the+                                  -- following information in the following order:+                                  --+                                  --   * unique-{path type}-{node type}-{key type}-{syntax}+                      -> XmlUpdateContext  -- ^ The update context to use for the index insertion.+                      -> IO ()+xmlContainer_addIndex cont mTrans uri name index uc =+    withForeignPtr cont $ \c_cont ->+    withCString uri $ \c_uri ->+    withCString name $ \c_name ->+    withCString index $ \c_index ->+    withForeignPtr uc $ \c_uc -> do+        ret <- case mTrans of+            Just trans -> do+                withForeignPtr trans $ \c_trans ->+                    _xmlContainer_addIndex c_cont c_trans c_uri c_name c_index c_uc+            Nothing    -> do+                _xmlContainer_addIndex c_cont nullPtr c_uri c_name c_index c_uc+        if ret /= 0+            then throwDBXML "xmlContainer_addIndex" ret ""+            else return ()++foreign import ccall safe "dbxml_helper.h _xmlContainer_deleteIndex" _xmlContainer_deleteIndex+    :: Ptr XmlContainer_struct -> Ptr XmlTransaction_struct -> CString -> CString -> CString -> Ptr XmlUpdateContext_struct -> IO CInt++xmlContainer_deleteIndex :: XmlContainer+                      -> Maybe XmlTransaction+                      -> String   -- ^ The namespace of the node to be indexed.+                                  -- The default namespace is selected by passing+                                  -- an empty string for the namespace.+                      -> String   -- ^ The name of the element or attribute node to be indexed+                      -> String   -- ^ A comma-separated list of strings that represent+                                  -- the indexing strategy. The strings must contain the+                                  -- following information in the following order:+                                  --+                                  --   * unique-{path type}-{node type}-{key type}-{syntax}+                      -> XmlUpdateContext  -- ^ The update context to use for the index insertion.+                      -> IO ()+xmlContainer_deleteIndex cont mTrans uri name index uc =+    withForeignPtr cont $ \c_cont ->+    withCString uri $ \c_uri ->+    withCString name $ \c_name ->+    withCString index $ \c_index ->+    withForeignPtr uc $ \c_uc -> do+        ret <- case mTrans of+            Just trans -> do+                withForeignPtr trans $ \c_trans ->+                    _xmlContainer_deleteIndex c_cont c_trans c_uri c_name c_index c_uc+            Nothing    -> do+                _xmlContainer_deleteIndex c_cont nullPtr c_uri c_name c_index c_uc+        if ret /= 0+            then throwDBXML "xmlContainer_deleteIndex" ret ""+            else return ()  foreign import ccall safe "dbxml_helper.h _xmlManager_close" _xmlManager_close     :: Ptr XmlManager_struct -> IO ()
Database/Berkeley/dbxml_helper.cpp view
@@ -149,6 +149,8 @@ {     UNWRAP_DBTXN();     try {+        *dbtxnp = NULL;  // Detach from Berkeley DB so we now take responsibility+                         // for cleaning it up.         XmlTransaction t = mgr->mgr.createTransaction(dbtxn);         *trans = new XmlTransaction(t);         return 0;@@ -567,3 +569,34 @@         return asInt(exc);     } }++int _xmlContainer_addIndex(DbXml::XmlContainer** cont, DbXml::XmlTransaction* trans,+        const char* uri, const char* name, const char* index, DbXml::XmlUpdateContext* uctx)+{+    try {+        if (trans != NULL)+            (*cont)->addIndex(*trans, uri, name, index, *uctx);+        else+            (*cont)->addIndex(uri, name, index, *uctx);+        return 0;+    }+    catch (XmlException& exc) {+        return asInt(exc);+    }+}++int _xmlContainer_deleteIndex(DbXml::XmlContainer** cont, DbXml::XmlTransaction* trans,+        const char* uri, const char* name, const char* index, DbXml::XmlUpdateContext* uctx)+{+    try {+        if (trans != NULL)+            (*cont)->deleteIndex(*trans, uri, name, index, *uctx);+        else+            (*cont)->deleteIndex(uri, name, index, *uctx);+        return 0;+    }+    catch (XmlException& exc) {+        return asInt(exc);+    }+}+
Database/Berkeley/dbxml_helper.h view
@@ -80,6 +80,10 @@     int _xmlContainer_deleteDocument(DbXml::XmlContainer** cont, DbXml::XmlTransaction* trans,         DbXml::XmlDocument* doc, DbXml::XmlUpdateContext* uctx);     int _xmlDocument_setMetaData(DbXml::XmlDocument* doc, const char* uri, const char* name, DbXml::XmlValue* value);+    int _xmlContainer_addIndex(DbXml::XmlContainer** cont, DbXml::XmlTransaction* trans,+        const char* uri, const char* name, const char* index, DbXml::XmlUpdateContext* uctx);+    int _xmlContainer_deleteIndex(DbXml::XmlContainer** cont, DbXml::XmlTransaction* trans,+        const char* uri, const char* name, const char* index, DbXml::XmlUpdateContext* uctx); }  #endif