author | František Kučera <franta-hg@frantovo.cz> |
Thu, 17 Jan 2019 23:26:48 +0100 | |
branch | v_0 |
changeset 9 | 5a2c4a8d715b |
parent 2 | 3ab78bf63467 |
child 15 | 177321664baf |
permissions | -rw-r--r-- |
2
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info) |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
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 |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
*/ |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
#pragma once |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include <istream> |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
#include <xercesc/sax/InputSource.hpp> |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include <xercesc/util/PlatformUtils.hpp> |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
#include <xercesc/util/BinInputStream.hpp> |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
namespace relpipe { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
namespace in { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
namespace xml { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
class StreamInputSource : public xercesc::InputSource { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
private: |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
std::istream& input; |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
class StreamBinInputStream : public xercesc::BinInputStream { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
private: |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
std::istream& input; |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
public: |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
StreamBinInputStream(std::istream& input) : BinInputStream(), input(input) { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
XMLFilePos curPos() const override { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
return input.tellg(); |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
const XMLCh* getContentType() const override { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
return nullptr; |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
XMLSize_t readBytes(XMLByte * const toFill, const XMLSize_t maxToRead) override { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
input.read((char*) toFill, maxToRead); |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
return input.gcount(); |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
}; |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
public: |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
StreamInputSource(std::istream& input, xercesc::MemoryManager * const manager = xercesc::XMLPlatformUtils::fgMemoryManager) : InputSource(manager), input(input) { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
virtual ~StreamInputSource() { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
xercesc::BinInputStream* makeStream() const override { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
// TODO: avoid multiple calls, input can be used only once |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
return new StreamBinInputStream(input); |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
}; |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
|
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
} |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
} |