1//
2// EntityResolverImpl.h
3//
4// Library: XML
5// Package: SAX
6// Module: SAX
7//
8// An implementation of EntityResolver.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef SAX_EntityResolverImpl_INCLUDED
18#define SAX_EntityResolverImpl_INCLUDED
19
20
21#include "Poco/XML/XML.h"
22#include "Poco/XML/XMLString.h"
23#include "Poco/SAX/EntityResolver.h"
24#include "Poco/URIStreamOpener.h"
25
26
27namespace Poco {
28namespace XML {
29
30
31class XML_API EntityResolverImpl: public EntityResolver
32 /// A default implementation of the EntityResolver interface.
33 ///
34 /// The system ID is first interpreted as an URI and the
35 /// URIStreamOpener is used to create and open an istream
36 /// for an InputSource.
37 ///
38 /// If the system ID is not a valid URI, it is
39 /// interpreted as a filesystem path and a Poco::FileInputStream
40 /// is opened for it.
41{
42public:
43 EntityResolverImpl();
44 /// Creates an EntityResolverImpl that uses the default
45 /// URIStreamOpener.
46
47 EntityResolverImpl(const Poco::URIStreamOpener& opener);
48 /// Creates an EntityResolverImpl that uses the given
49 /// URIStreamOpener.
50
51 ~EntityResolverImpl();
52 /// Destroys the EntityResolverImpl.
53
54 InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId);
55 /// Tries to use the URIStreamOpener to create and open an istream
56 /// for the given systemId, which is interpreted as an URI.
57 ///
58 /// If the systemId is not a valid URI, it is interpreted as
59 /// a local filesystem path and a Poco::FileInputStream is opened for it.
60
61 void releaseInputSource(InputSource* pSource);
62 /// Deletes the InputSource's stream.
63
64protected:
65 std::istream* resolveSystemId(const XMLString& systemId);
66
67private:
68 EntityResolverImpl(const EntityResolverImpl&);
69 EntityResolverImpl& operator = (const EntityResolverImpl&);
70
71 const Poco::URIStreamOpener& _opener;
72};
73
74
75} } // namespace Poco::XML
76
77
78#endif // SAX_EntityResolverImpl_INCLUDED
79