author | František Kučera <franta-hg@frantovo.cz> |
Sun, 04 Jul 2021 11:51:13 +0200 | |
branch | v_0 |
changeset 27 | d9cc2d356cdb |
parent 24 | 114810ee2386 |
child 40 | 85b6f13f1088 |
permissions | -rw-r--r-- |
1
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2021 František Kučera (Frantovo.cz, GlobalCode.info) |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#pragma once |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
24
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
19 |
#include "ProxyVector.h" |
9
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
20 |
|
1
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
namespace relpipe { |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
namespace in { |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
namespace asn1 { |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
namespace lib { |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
7
afb7f3a4981a
rename SAXContentHandler to XMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
26 |
class XMLContentHandler { |
1
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
public: |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
|
7
afb7f3a4981a
rename SAXContentHandler to XMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
29 |
virtual ~XMLContentHandler() = default; |
1
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
9
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
31 |
// FIXME: namespaces, check names |
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
32 |
|
6
6a4a348426d9
bit more meaningful methods in SAXContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
33 |
virtual void writeStartElement(const std::string& name, const std::vector<std::string>& attributes = {}) = 0; |
6a4a348426d9
bit more meaningful methods in SAXContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
34 |
virtual void writeEndElement() = 0; |
9
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
35 |
virtual void writeCharacters(const std::string& value) = 0; |
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
36 |
virtual void writeComment(const std::string& value, bool addSpaces = true) = 0; |
4
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
37 |
|
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
38 |
}; |
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
39 |
|
7
afb7f3a4981a
rename SAXContentHandler to XMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
40 |
class XMLContentHandlerProxy : XMLContentHandler { |
4
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
41 |
private: |
24
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
42 |
ProxyVector<XMLContentHandler> handlers; |
4
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
43 |
public: |
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
44 |
|
7
afb7f3a4981a
rename SAXContentHandler to XMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
45 |
void addHandler(std::shared_ptr<XMLContentHandler> handler) { |
4
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
46 |
handlers.push_back(handler); |
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
47 |
} |
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
48 |
|
9
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
49 |
void writeStartElement(const std::string& name, const std::vector<std::string>& attributes = {}) override { |
24
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
50 |
handlers.forward(&XMLContentHandler::writeStartElement, name, attributes); |
4
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
51 |
} |
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
52 |
|
9
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
53 |
void writeEndElement() override { |
24
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
54 |
handlers.forward(&XMLContentHandler::writeEndElement); |
4
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
55 |
} |
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
56 |
|
9
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
57 |
void writeCharacters(const std::string& value) override { |
24
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
58 |
handlers.forward(&XMLContentHandler::writeCharacters, value); |
6
6a4a348426d9
bit more meaningful methods in SAXContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
59 |
} |
6a4a348426d9
bit more meaningful methods in SAXContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
60 |
|
9
7a6abdd00ab5
partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
61 |
void writeComment(const std::string& value, bool addSpaces = true) override { |
24
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
62 |
handlers.forward(&XMLContentHandler::writeComment, value, addSpaces); |
4
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
63 |
} |
7230e1ea0b07
proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
64 |
|
1
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
}; |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
|
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
} |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
} |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
} |
2179f13227f4
AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
} |