src/lib/ASN1ContentHandler.h
author František Kučera <franta-hg@frantovo.cz>
Fri, 02 Jul 2021 00:42:01 +0200
branchv_0
changeset 23 8941a679299f
parent 22 9b6f86760384
child 24 114810ee2386
permissions -rw-r--r--
BitString and OctetString support
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    19
#include <memory>
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    20
#include <vector>
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    21
#include <sstream>
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    22
#include <iomanip>
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    23
#include <cmath>
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    24
1
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
namespace relpipe {
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
namespace in {
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
namespace asn1 {
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
namespace lib {
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
class ASN1ContentHandler {
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    31
public:
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    32
14
02725d301010 somehow parse nested SEQUENCEs and SETs + support definite long form of lengths (multiple length octets)
František Kučera <franta-hg@frantovo.cz>
parents: 9
diff changeset
    33
	enum class CollectionType : uint64_t {
15
95ca127ba816 support constructed (like a collection)
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    34
		Constructed, // TODO: special event?
14
02725d301010 somehow parse nested SEQUENCEs and SETs + support definite long form of lengths (multiple length octets)
František Kučera <franta-hg@frantovo.cz>
parents: 9
diff changeset
    35
		Sequence = 16,
02725d301010 somehow parse nested SEQUENCEs and SETs + support definite long form of lengths (multiple length octets)
František Kučera <franta-hg@frantovo.cz>
parents: 9
diff changeset
    36
		Set = 17
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    37
	};
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    38
14
02725d301010 somehow parse nested SEQUENCEs and SETs + support definite long form of lengths (multiple length octets)
František Kučera <franta-hg@frantovo.cz>
parents: 9
diff changeset
    39
	enum class StringType : uint64_t {
23
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    40
		UTF8String = 0xC,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    41
		NumericString = 0x12,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    42
		PrintableString = 0x13,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    43
		T61String = 0x14,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    44
		VideotexString = 0x15,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    45
		IA5String = 0x16,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    46
		GraphicString = 0x19,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    47
		VisibleString = 0x1A,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    48
		GeneralString = 0x1B,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    49
		UniversalString = 0x1C,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    50
		CharacterString = 0x1D,
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
    51
		BMPString = 0x1E,
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    52
	};
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    53
21
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    54
	enum class DateTimeType : uint64_t {
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    55
		UTCTime,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    56
		GeneralizedTime,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    57
		Time,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    58
		Date,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    59
		TimeOfDay,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    60
		DateTime,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    61
		Duration,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    62
		// TODO: review date/time types
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    63
	};
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    64
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    65
	class Integer {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    66
	private:
18
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    67
		// TODO: use std::string (of octets, not ASCII) instead of std::vector?
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    68
		// TODO: use this class as BigInteger across Relational pipes?
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    69
		std::vector<uint8_t> data;
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    70
	public:
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    71
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    72
		/**
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    73
		 * @param data integer octets as in BER encoding
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    74
		 */
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    75
		Integer(std::vector<uint8_t> data) : data(data) {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    76
		}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    77
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    78
		virtual ~Integer() {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    79
		}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    80
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    81
		size_t size() const {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    82
			return data.size();
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    83
		}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    84
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    85
		const uint8_t& operator[](std::size_t index) const {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    86
			return data[index];
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    87
		}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    88
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    89
		const std::string toHex() const {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    90
			std::stringstream hex;
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    91
			hex << std::hex << std::setfill('0');
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    92
			for (uint8_t b : data) hex << std::setw(2) << (int) b;
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    93
			return hex.str();
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    94
		}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    95
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    96
		const std::string toString() const {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    97
			try {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    98
				return std::to_string(toInt64());
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    99
			} catch (...) {
18
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   100
				// integer has more than 64 bits → only HEX form value will be available
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   101
				// TODO: support longer values than 64 bits
18
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   102
				// TODO: do not ignore zero-length error?
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   103
				return "";
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   104
			}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   105
		}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   106
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   107
		const int64_t toInt64() const {
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   108
			int64_t value = 0;
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   109
18
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   110
			if (data.size() > sizeof (value)) throw std::invalid_argument("Integer is too long");
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   111
			else if (data.size() == 0) throw std::invalid_argument("Integer has zero length");
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   112
18
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   113
			value = data[0];
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   114
			bool negative = data[0] & 0x80;
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   115
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   116
			for (size_t i = 1, limit = data.size(); i < limit; i++) value = (value << 8) | data[i];
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   117
cb85500c4a30 some support for Integers – improved
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
   118
			if (negative) value -= std::pow(256, data.size());
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   119
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   120
			return value;
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   121
		}
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   122
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   123
	};
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   124
20
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   125
	class ObjectIdentifier {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   126
	private:
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   127
		// TODO: use std::string (of octets, not ASCII) instead of std::vector?
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   128
		// TODO: use this class across Relational pipes as one of basic types?
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   129
		std::vector<uint8_t> data;
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   130
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   131
	public:
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   132
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   133
		/**
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   134
		 * @param data integer octets as in BER encoding
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   135
		 */
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   136
		ObjectIdentifier(std::vector<uint8_t> data) : data(data) {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   137
			// TODO: cache size and element values?
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   138
		}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   139
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   140
		virtual ~ObjectIdentifier() {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   141
		}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   142
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   143
		/**
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   144
		 * @return number of elements, not octets
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   145
		 */
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   146
		size_t size() const {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   147
			return 0; // FIXME: correct OID size
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   148
		}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   149
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   150
		/**
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   151
		 * @param index 0 = root element
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   152
		 * @return value of the element at given position
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   153
		 */
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   154
		const uint8_t& operator[](std::size_t index) const {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   155
			return data[index]; // FIXME: correct OID value
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   156
		}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   157
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   158
		const std::string toString() const {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   159
			if (data.size() == 0) return "";
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   160
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   161
			std::stringstream result;
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   162
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   163
			result << (data[0] / 40) << "." << (data[0] % 40); // first two elements are encoded in the first octet
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   164
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   165
			for (size_t i = 1, limit = data.size(), octet = 0, element = 0; i < limit; i++) {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   166
				octet = data[i];
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   167
				element = element << 7 | (octet & 0xFF >> 1);
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   168
				// TODO: throw exception if the element value overflows? (should not happen) or format even longer values
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   169
				if ((octet & 1 << 7) == 0) {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   170
					result << "." << element;
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   171
					element = 0;
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   172
				}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   173
			}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   174
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   175
			return result.str();
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   176
		}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   177
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   178
	};
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   179
21
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   180
	class DateTime {
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   181
	public:
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   182
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   183
		enum class Precision {
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   184
			Year,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   185
			Month,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   186
			Day,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   187
			Hour,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   188
			Minute,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   189
			Second,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   190
			Milisecond,
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   191
			Nanosecond
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   192
		};
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   193
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   194
		// TODO: timezone (in minutes or 1/4 hours)
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   195
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   196
		Precision precision = Precision::Second;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   197
		int32_t year = 1970;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   198
		int8_t month = 1;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   199
		int8_t day = 1;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   200
		int8_t hour = 0;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   201
		int8_t minute = 0;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   202
		int8_t second = 0;
22
9b6f86760384 slightly improved UTCTime and GeneralizedTime support
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
   203
		int32_t nanosecond = 0;
9b6f86760384 slightly improved UTCTime and GeneralizedTime support
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
   204
		int8_t timezoneHour = 0;
9b6f86760384 slightly improved UTCTime and GeneralizedTime support
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
   205
		int8_t timezoneMinute = 0;
21
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   206
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   207
		virtual ~DateTime() {
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   208
		}
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   209
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   210
		const std::string toString() const {
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   211
			std::stringstream result;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   212
			result << std::setfill('0');
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   213
			result << std::setw(4) << (int) year;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   214
			result << "-" << std::setw(2) << (int) month;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   215
			result << "-" << std::setw(2) << (int) day;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   216
			result << "T" << std::setw(2) << (int) hour;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   217
			result << ":" << std::setw(2) << (int) minute;
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   218
			result << ":" << std::setw(2) << (int) second;
22
9b6f86760384 slightly improved UTCTime and GeneralizedTime support
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
   219
			if (precision == Precision::Nanosecond) result << "," << (int) nanosecond;
9b6f86760384 slightly improved UTCTime and GeneralizedTime support
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
   220
			result << (timezoneHour < 0 ? "-" : "+");
9b6f86760384 slightly improved UTCTime and GeneralizedTime support
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
   221
			result << std::setw(2) << (int) std::abs(timezoneHour);
9b6f86760384 slightly improved UTCTime and GeneralizedTime support
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
   222
			result << ":" << std::setw(2) << (int) timezoneMinute;
21
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   223
			return result.str();
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   224
		}
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   225
	};
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   226
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   227
	virtual ~ASN1ContentHandler() = default;
20
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   228
19
b7431bc6069b support tag numbers > 30 (multiple octets)
František Kučera <franta-hg@frantovo.cz>
parents: 18
diff changeset
   229
	// TODO: more metadata, support OID decoding and ASN.1 modules (schema), probably through a plug-in
21
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   230
	// TODO: support also extension extractor plug-ins? (could decode some opaque structures like octet strings and replace them with nested elements) e.g. subjectAltName in https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.6
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   231
9
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   232
	virtual void writeStreamStart() = 0;
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   233
	virtual void writeStreamEnd() = 0;
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   234
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   235
	virtual void writeCollectionStart(CollectionType type) = 0;
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   236
	virtual void writeCollectionEnd() = 0;
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   237
	virtual void writeBoolean(bool value) = 0;
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   238
	virtual void writeNull() = 0;
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   239
	virtual void writeInteger(Integer value) = 0;
23
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   240
	/**
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   241
	 * @param type original type in ASN.1
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   242
	 * @param value original text converted to UTF-8
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   243
	 */
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   244
	virtual void writeTextString(StringType type, std::string value) = 0;
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   245
	/**
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   246
	 * @param value arbitrary sequence of octets (bytes), usually not a human-readable text
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   247
	 */
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   248
	virtual void writeOctetString(std::string value) = 0;
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   249
	/**
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   250
	 * @param value arbitrary sequence of bits (booleans), usually not a human-readable text
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   251
	 */
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   252
	virtual void writeBitString(std::vector<bool> value) = 0;
20
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   253
	virtual void writeOID(ObjectIdentifier value) = 0;
21
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   254
	virtual void writeDateTime(DateTimeType type, DateTime value) = 0;
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   255
	// Object descriptor
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   256
	// virtual void writeReal(float value) = 0;
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   257
	// Enumerated
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   258
	// Embedded PVD
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   259
	// Relative OID
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   260
	// OID-IRI
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   261
	// Relative OID-IRI
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   262
1
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   263
};
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   264
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   265
class ASN1ContentHandlerProxy : public ASN1ContentHandler {
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   266
private:
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   267
	std::vector<std::shared_ptr<ASN1ContentHandler>> handlers;
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   268
public:
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   269
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   270
	void addHandler(std::shared_ptr<ASN1ContentHandler> handler) {
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   271
		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
   272
	}
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   273
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   274
#define handler for (auto ___h : handlers) ___h
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   275
9
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   276
	void writeStreamStart() override {
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   277
		handler->writeStreamStart();
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   278
	}
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   279
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   280
	void writeStreamEnd() override {
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   281
		handler->writeStreamEnd();
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   282
	}
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   283
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   284
	void writeCollectionStart(CollectionType type) override {
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   285
		handler->writeCollectionStart(type);
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   286
	}
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   287
9
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   288
	void writeCollectionEnd() override {
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   289
		handler->writeCollectionEnd();
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   290
	}
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   291
9
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   292
	void writeBoolean(bool value) override {
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   293
		handler->writeBoolean(value);
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   294
	}
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   295
9
7a6abdd00ab5 partial implementation of DOMBuildingXMLContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
   296
	void writeNull() override {
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   297
		handler->writeNull();
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   298
	}
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   299
17
f5281ab3e68f some support for Integers
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
   300
	void writeInteger(Integer value) override {
8
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   301
		handler->writeInteger(value);
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   302
	}
d37c1a5d09ce bit more meaningful methods in ASN1ContentHandler
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
   303
23
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   304
	void writeTextString(StringType type, std::string value) override {
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   305
		handler->writeTextString(type, value);
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   306
	}
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   307
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   308
	void writeOctetString(std::string value) override {
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   309
		handler->writeOctetString(value);
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   310
	}
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   311
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   312
	void writeBitString(std::vector<bool> value) override {
8941a679299f BitString and OctetString support
František Kučera <franta-hg@frantovo.cz>
parents: 22
diff changeset
   313
		handler->writeBitString(value);
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   314
	}
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   315
20
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   316
	void writeOID(ObjectIdentifier value) override {
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   317
		handler->writeOID(value);
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   318
	}
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   319
21
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   320
	void writeDateTime(DateTimeType type, DateTime value) override {
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   321
		handler->writeDateTime(type, value);
705036445672 partial UTCTime support
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
   322
	}
20
fac034e3e867 support object identifiers (OID)
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
   323
4
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   324
#undef handler
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   325
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   326
};
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   327
7230e1ea0b07 proxy handlers forwarding events to all subordinate handlers
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   328
1
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   329
}
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   330
}
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   331
}
2179f13227f4 AbstractParser: AbstractParser, ASN1Reader, ASN1ContentHandler, SAXContentHandler, BasicASN1Reader, DOMBuildingSAXContentHandler, GenericASN1ContentHandler skeletons
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   332
}