EntityResolverImpl.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #ifndef SAX_EntityResolverImpl_INCLUDED
  16. #define SAX_EntityResolverImpl_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/XML/XMLString.h"
  19. #include "Poco/SAX/EntityResolver.h"
  20. #include "Poco/URIStreamOpener.h"
  21. namespace Poco {
  22. namespace XML {
  23. class XML_API EntityResolverImpl: public EntityResolver
  24. /// A default implementation of the EntityResolver interface.
  25. ///
  26. /// The system ID is first interpreted as an URI and the
  27. /// URIStreamOpener is used to create and open an istream
  28. /// for an InputSource.
  29. ///
  30. /// If the system ID is not a valid URI, it is
  31. /// interpreted as a filesystem path and a Poco::FileInputStream
  32. /// is opened for it.
  33. {
  34. public:
  35. EntityResolverImpl();
  36. /// Creates an EntityResolverImpl that uses the default
  37. /// URIStreamOpener.
  38. EntityResolverImpl(const Poco::URIStreamOpener& opener);
  39. /// Creates an EntityResolverImpl that uses the given
  40. /// URIStreamOpener.
  41. ~EntityResolverImpl();
  42. /// Destroys the EntityResolverImpl.
  43. InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId);
  44. /// Tries to use the URIStreamOpener to create and open an istream
  45. /// for the given systemId, which is interpreted as an URI.
  46. ///
  47. /// If the systemId is not a valid URI, it is interpreted as
  48. /// a local filesystem path and a Poco::FileInputStream is opened for it.
  49. void releaseInputSource(InputSource* pSource);
  50. /// Deletes the InputSource's stream.
  51. protected:
  52. std::istream* resolveSystemId(const XMLString& systemId);
  53. private:
  54. EntityResolverImpl(const EntityResolverImpl&);
  55. EntityResolverImpl& operator = (const EntityResolverImpl&);
  56. const Poco::URIStreamOpener& _opener;
  57. };
  58. } } // namespace Poco::XML
  59. #endif // SAX_EntityResolverImpl_INCLUDED