separate the „std::istream to DOM“ phase v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 25 Oct 2020 21:48:11 +0100
branchv_0
changeset 14 5be268bc4c69
parent 13 530a83382aee
child 15 f4fb07ed8753
separate the „std::istream to DOM“ phase
nbproject/configurations.xml
src/XMLDocumentConstructor.h
src/XMLTableCommand.h
--- a/nbproject/configurations.xml	Sat Oct 24 00:08:17 2020 +0200
+++ b/nbproject/configurations.xml	Sun Oct 25 21:48:11 2020 +0100
@@ -42,6 +42,7 @@
   <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
     <df root="." name="0">
       <df name="src">
+        <in>XMLDocumentConstructor.h</in>
         <in>relpipe-in-xmltable.cpp</in>
       </df>
     </df>
@@ -100,6 +101,8 @@
           <preBuildFirst>true</preBuildFirst>
         </preBuild>
       </makefileType>
+      <item path="src/XMLDocumentConstructor.h" ex="false" tool="3" flavor2="0">
+      </item>
       <item path="src/relpipe-in-xmltable.cpp" ex="false" tool="1" flavor2="0">
         <ccTool flags="0">
         </ccTool>
@@ -139,6 +142,8 @@
           <preBuildFirst>true</preBuildFirst>
         </preBuild>
       </makefileType>
+      <item path="src/XMLDocumentConstructor.h" ex="false" tool="3" flavor2="0">
+      </item>
       <item path="src/relpipe-in-xmltable.cpp" ex="false" tool="1" flavor2="0">
         <ccTool flags="0">
         </ccTool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/XMLDocumentConstructor.h	Sun Oct 25 21:48:11 2020 +0100
@@ -0,0 +1,41 @@
+/**
+ * Relational pipes
+ * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+namespace relpipe {
+namespace in {
+namespace xmltable {
+
+#include <libxml++-2.6/libxml++/libxml++.h>
+
+class XMLDocumentConstructor {
+private:
+	std::istream* input = nullptr;
+	xmlpp::DomParser* parser = nullptr;
+public:
+
+	XMLDocumentConstructor(std::istream* input, xmlpp::DomParser* parser) : input(input), parser(parser) {
+	}
+
+	void process() {
+		parser->parse_stream(*input);
+	}
+};
+
+}
+}
+}
\ No newline at end of file
--- a/src/XMLTableCommand.h	Sat Oct 24 00:08:17 2020 +0200
+++ b/src/XMLTableCommand.h	Sun Oct 25 21:48:11 2020 +0100
@@ -30,6 +30,7 @@
 #include <relpipe/writer/typedefs.h>
 
 #include "Configuration.h"
+#include "XMLDocumentConstructor.h"
 
 namespace relpipe {
 namespace in {
@@ -86,7 +87,8 @@
 		std::shared_ptr<RelationalWriter> writer(Factory::create(output));
 
 		xmlpp::DomParser parser;
-		parser.parse_stream(input);
+		XMLDocumentConstructor documentConstructor(&input, &parser);
+		documentConstructor.process();
 		if (configuration.xinclude) parser.get_document()->process_xinclude(true);
 		xmlpp::Element* root = parser.get_document()->get_root_node();