Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
IStreamInputSource.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// Xerces InputSource reading from arbitrary std::istream
20// reimplementation inspired by https://marc.info/?l=xerces-dev&m=86952133511623
21/****************************************************************************/
22#pragma once
23#include <config.h>
24#include <iostream>
25#include <xercesc/util/BinInputStream.hpp>
26#include <xercesc/sax/InputSource.hpp>
27
28
29// ===========================================================================
30// class definitions
31// ===========================================================================
36class IStreamBinInputStream : public XERCES_CPP_NAMESPACE::BinInputStream {
37public:
38 IStreamBinInputStream(std::istream& in) : myIn(in) { }
39 virtual ~IStreamBinInputStream(void) { }
40 virtual XMLFilePos curPos(void) const {
41 return myIn.tellg();
42 }
43 virtual XMLSize_t readBytes(XMLByte* const buf, const XMLSize_t max) {
44 myIn.read((char*)buf, max);
45 return (XMLSize_t)myIn.gcount();
46 }
47 virtual const XMLCh* getContentType() const {
48 return nullptr;
49 }
50private:
51 std::istream& myIn;
52};
53
54
59class IStreamInputSource : public XERCES_CPP_NAMESPACE::InputSource {
60public:
61 IStreamInputSource(std::istream& in) :
62 XERCES_CPP_NAMESPACE::InputSource("istream"), myIn(in) { }
63 virtual ~IStreamInputSource(void) { }
64 virtual XERCES_CPP_NAMESPACE::BinInputStream* makeStream(void) const {
65 return new IStreamBinInputStream(myIn);
66 }
67private:
68 std::istream& myIn;
69};
Xerces BinInputStream reading from arbitrary std::istream.
virtual const XMLCh * getContentType() const
virtual ~IStreamBinInputStream(void)
virtual XMLFilePos curPos(void) const
IStreamBinInputStream(std::istream &in)
virtual XMLSize_t readBytes(XMLByte *const buf, const XMLSize_t max)
Xerces InputSource reading from arbitrary std::istream.
IStreamInputSource(std::istream &in)
virtual ~IStreamInputSource(void)
virtual XERCES_CPP_NAMESPACE::BinInputStream * makeStream(void) const