# HG changeset patch # User František Kučera # Date 1623523387 -7200 # Node ID afb7f3a4981acf368368b720ce015ea16b2add8f # Parent 6a4a348426d9df6e44d6e478d47864c32aa5a879 rename SAXContentHandler to XMLContentHandler diff -r 6a4a348426d9 -r afb7f3a4981a nbproject/configurations.xml --- a/nbproject/configurations.xml Sat Jun 12 20:31:23 2021 +0200 +++ b/nbproject/configurations.xml Sat Jun 12 20:43:07 2021 +0200 @@ -48,9 +48,9 @@ AbstractParser.cpp AbstractParser.h BasicASN1Reader.h - DOMBuildingSAXContentHandler.h + DOMBuildingXMLContentHandler.h GenericASN1ContentHandler.h - SAXContentHandler.h + XMLContentHandler.h XMLDocumentConstructor.h relpipe-in-xmltable.cpp @@ -122,7 +122,7 @@ - @@ -132,7 +132,7 @@ tool="3" flavor2="0"> - + @@ -185,7 +185,7 @@ - @@ -195,7 +195,7 @@ tool="3" flavor2="0"> - + diff -r 6a4a348426d9 -r afb7f3a4981a src/XMLDocumentConstructor.h --- a/src/XMLDocumentConstructor.h Sat Jun 12 20:31:23 2021 +0200 +++ b/src/XMLDocumentConstructor.h Sat Jun 12 20:43:07 2021 +0200 @@ -22,7 +22,7 @@ #include "lib/BasicASN1Reader.h" #include "lib/GenericASN1ContentHandler.h" -#include "lib/DOMBuildingSAXContentHandler.h" +#include "lib/DOMBuildingXMLContentHandler.h" namespace relpipe { namespace in { @@ -44,7 +44,7 @@ relpipe::in::asn1::lib::BasicASN1Reader reader; std::shared_ptr asn1handler = make_shared(); - std::shared_ptr saxHandler = make_shared(parser->get_document()); + std::shared_ptr saxHandler = make_shared(parser->get_document()); asn1handler->addHandler(saxHandler); reader.addHandler(asn1handler); diff -r 6a4a348426d9 -r afb7f3a4981a src/lib/DOMBuildingSAXContentHandler.h --- a/src/lib/DOMBuildingSAXContentHandler.h Sat Jun 12 20:31:23 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/** - * Relational pipes - * Copyright © 2021 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 . - */ -#pragma once - -#include - -#include "SAXContentHandler.h" - -namespace relpipe { -namespace in { -namespace asn1 { -namespace lib { - -class DOMBuildingSAXContentHandler : public SAXContentHandler { -private: - xmlpp::Document* document; - -public: - - DOMBuildingSAXContentHandler(xmlpp::Document* document) : document(document) { - document->create_root_node("DOMBuildingSAXContentHandler"); // FIXME: real implementation - } - - void writeStartElement(const std::string& name, const std::vector& attributes) override { - } - - void writeEndElement() override { - } - - void writeCharacters(const std::string& text) override { - } - - void writeComment(const std::string& text, bool addSpaces) override { - document->get_root_node()->add_child_comment(addSpaces ? " " + text + " " : text); - } - -}; - -} -} -} -} diff -r 6a4a348426d9 -r afb7f3a4981a src/lib/DOMBuildingXMLContentHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/DOMBuildingXMLContentHandler.h Sat Jun 12 20:43:07 2021 +0200 @@ -0,0 +1,56 @@ +/** + * Relational pipes + * Copyright © 2021 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 . + */ +#pragma once + +#include + +#include "XMLContentHandler.h" + +namespace relpipe { +namespace in { +namespace asn1 { +namespace lib { + +class DOMBuildingXMLContentHandler : public XMLContentHandler { +private: + xmlpp::Document* document; + +public: + + DOMBuildingXMLContentHandler(xmlpp::Document* document) : document(document) { + document->create_root_node("DOMBuildingXMLContentHandler"); // FIXME: real implementation + } + + void writeStartElement(const std::string& name, const std::vector& attributes) override { + } + + void writeEndElement() override { + } + + void writeCharacters(const std::string& text) override { + } + + void writeComment(const std::string& text, bool addSpaces) override { + document->get_root_node()->add_child_comment(addSpaces ? " " + text + " " : text); + } + +}; + +} +} +} +} diff -r 6a4a348426d9 -r afb7f3a4981a src/lib/GenericASN1ContentHandler.h --- a/src/lib/GenericASN1ContentHandler.h Sat Jun 12 20:31:23 2021 +0200 +++ b/src/lib/GenericASN1ContentHandler.h Sat Jun 12 20:43:07 2021 +0200 @@ -17,7 +17,7 @@ #pragma once #include "ASN1ContentHandler.h" -#include "SAXContentHandler.h" +#include "XMLContentHandler.h" namespace relpipe { namespace in { @@ -31,10 +31,10 @@ */ class GenericASN1ContentHandler : public ASN1ContentHandler { private: - SAXContentHandlerProxy handlers; + XMLContentHandlerProxy handlers; public: - void addHandler(std::shared_ptr handler) { + void addHandler(std::shared_ptr handler) { handlers.addHandler(handler); } diff -r 6a4a348426d9 -r afb7f3a4981a src/lib/SAXContentHandler.h --- a/src/lib/SAXContentHandler.h Sat Jun 12 20:31:23 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/** - * Relational pipes - * Copyright © 2021 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 . - */ -#pragma once - -namespace relpipe { -namespace in { -namespace asn1 { -namespace lib { - -class SAXContentHandler { -public: - - virtual ~SAXContentHandler() = default; - - virtual void writeStartElement(const std::string& name, const std::vector& attributes = {}) = 0; - virtual void writeEndElement() = 0; - virtual void writeCharacters(const std::string& text) = 0; - virtual void writeComment(const std::string& text, bool addSpaces = true) = 0; - -}; - -class SAXContentHandlerProxy : SAXContentHandler { -private: - std::vector> handlers; -public: - - void addHandler(std::shared_ptr handler) { - handlers.push_back(handler); - } - -#define handler for (auto ___h : handlers) ___h - - void writeStartElement(const std::string& name, const std::vector& attributes = {}) { - handler->writeStartElement(name, attributes); - } - - void writeEndElement() { - handler->writeEndElement(); - } - - void writeCharacters(const std::string& text) { - handler->writeCharacters(text); - } - - void writeComment(const std::string& text, bool addSpaces = true) { - handler->writeComment(text, addSpaces); - } - -#undef handler - -}; - -} -} -} -} diff -r 6a4a348426d9 -r afb7f3a4981a src/lib/XMLContentHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/XMLContentHandler.h Sat Jun 12 20:43:07 2021 +0200 @@ -0,0 +1,70 @@ +/** + * Relational pipes + * Copyright © 2021 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 . + */ +#pragma once + +namespace relpipe { +namespace in { +namespace asn1 { +namespace lib { + +class XMLContentHandler { +public: + + virtual ~XMLContentHandler() = default; + + virtual void writeStartElement(const std::string& name, const std::vector& attributes = {}) = 0; + virtual void writeEndElement() = 0; + virtual void writeCharacters(const std::string& text) = 0; + virtual void writeComment(const std::string& text, bool addSpaces = true) = 0; + +}; + +class XMLContentHandlerProxy : XMLContentHandler { +private: + std::vector> handlers; +public: + + void addHandler(std::shared_ptr handler) { + handlers.push_back(handler); + } + +#define handler for (auto ___h : handlers) ___h + + void writeStartElement(const std::string& name, const std::vector& attributes = {}) { + handler->writeStartElement(name, attributes); + } + + void writeEndElement() { + handler->writeEndElement(); + } + + void writeCharacters(const std::string& text) { + handler->writeCharacters(text); + } + + void writeComment(const std::string& text, bool addSpaces = true) { + handler->writeComment(text, addSpaces); + } + +#undef handler + +}; + +} +} +} +}