diff options
-rw-r--r-- | default.nix | 25 | ||||
-rw-r--r-- | flake.lock | 27 | ||||
-rw-r--r-- | flake.nix | 29 | ||||
-rw-r--r-- | src/support/dom/document_cache.cc | 15 | ||||
-rw-r--r-- | src/support/dom/document_cache.h | 9 |
5 files changed, 66 insertions, 39 deletions
diff --git a/default.nix b/default.nix deleted file mode 100644 index 38f3d65..0000000 --- a/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ system ? builtins.currentSystem }: - -let - pkgs = import <nixpkgs> { inherit system; }; - stdenv = pkgs.stdenv; - -in stdenv.mkDerivation rec { - name = "input-xslt"; - - src = pkgs.lib.cleanSource ./.; - - buildInputs = with pkgs; [ - cmake boost xalanc xercesc discount - ]; - - meta = with stdenv.lib; { - description = "InputXSLT"; - homepage = https://tree.kummerlaender.eu/projects/xslt/input_xslt/; - license = stdenv.lib.licenses.asl20; - }; - - shellHook = '' - export NIX_SHELL_NAME="${name}" - ''; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..42b6658 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1659914493, + "narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..76820d8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +{ + description = "InputXSLT"; + + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-21.05; + }; + + outputs = { self, nixpkgs, ... }: { + defaultPackage.x86_64-linux = let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + + in pkgs.stdenv.mkDerivation rec { + name = "input-xslt"; + + src = pkgs.lib.cleanSource ./.; + + buildInputs = with pkgs; [ + cmake boost xalanc xercesc discount + ]; + + meta = { + description = "InputXSLT"; + homepage = https://tree.kummerlaender.eu/projects/xslt/input_xslt/; + license = pkgs.lib.licenses.asl20; + }; + }; + }; +} diff --git a/src/support/dom/document_cache.cc b/src/support/dom/document_cache.cc index c000aef..0133234 100644 --- a/src/support/dom/document_cache.cc +++ b/src/support/dom/document_cache.cc @@ -11,7 +11,10 @@ namespace InputXSLT { auto DomDocumentCache::createDocument() -> document_ptr { return document_ptr( - xercesc::DOMImplementation::getImplementation()->createDocument() + xercesc::DOMImplementation::getImplementation()->createDocument(), + [](xercesc::DOMDocument* ptr) { + ptr->release(); + } ); } @@ -21,7 +24,10 @@ auto DomDocumentCache::createDocument(const std::string& name) -> document_ptr { nullptr, *XercesStringGuard<XMLCh>(name), nullptr - ) + ), + [](xercesc::DOMDocument* ptr) { + ptr->release(); + } ); } @@ -41,9 +47,4 @@ xalan::XalanDocument* DomDocumentCache::create(document_ptr&& document) { return this->cache_.top()->getXalanDocument(); } -void DomDocumentCache::document_deleter::operator()( - xercesc::DOMDocument* document) { - document->release(); -} - } diff --git a/src/support/dom/document_cache.h b/src/support/dom/document_cache.h index f472249..115d194 100644 --- a/src/support/dom/document_cache.h +++ b/src/support/dom/document_cache.h @@ -8,22 +8,17 @@ #include <mutex> #include <stack> #include <memory> +#include <functional> #include "common.h" namespace InputXSLT { class DomDocumentCache { - class document_deleter { - friend std::unique_ptr<xercesc::DOMDocument, document_deleter>; - - void operator()(xercesc::DOMDocument*); - }; - public: typedef std::unique_ptr< xercesc::DOMDocument, - document_deleter + std::function<void(xercesc::DOMDocument*)> > document_ptr; static document_ptr createDocument(); |