URIStreamFactory.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // URIStreamFactory.h
  3. //
  4. // Library: Foundation
  5. // Package: URI
  6. // Module: URIStreamFactory
  7. //
  8. // Definition of the URIStreamFactory class.
  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 Foundation_URIStreamFactory_INCLUDED
  16. #define Foundation_URIStreamFactory_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include <istream>
  19. namespace Poco {
  20. class URI;
  21. class Foundation_API URIStreamFactory
  22. /// This class defines the interface that all
  23. /// URI stream factories must implement.
  24. ///
  25. /// Subclasses must implement the open() method.
  26. {
  27. public:
  28. URIStreamFactory();
  29. /// Creates the URIStreamFactory.
  30. virtual std::istream* open(const URI& uri) = 0;
  31. /// Tries to create and open an input stream for the
  32. /// resource specified by the given URI.
  33. ///
  34. /// If the stream cannot be opened for whatever reason,
  35. /// an appropriate IOException must be thrown.
  36. ///
  37. /// If opening the stream results in a redirect, a
  38. /// URIRedirection exception should be thrown.
  39. protected:
  40. virtual ~URIStreamFactory();
  41. /// Destroys the URIStreamFactory.
  42. private:
  43. URIStreamFactory(const URIStreamFactory&);
  44. URIStreamFactory& operator = (const URIStreamFactory&);
  45. friend class URIStreamOpener;
  46. };
  47. class Foundation_API URIRedirection
  48. /// An instance of URIRedirection is thrown by a URIStreamFactory::open()
  49. /// if opening the original URI resulted in a redirection response
  50. /// (such as a MOVED PERMANENTLY in HTTP).
  51. {
  52. public:
  53. URIRedirection(const std::string& uri);
  54. URIRedirection(const URIRedirection& redir);
  55. URIRedirection& operator = (const URIRedirection& redir);
  56. void swap(URIRedirection& redir);
  57. const std::string& uri() const;
  58. /// Returns the new URI.
  59. private:
  60. URIRedirection();
  61. std::string _uri;
  62. };
  63. //
  64. // inlines
  65. //
  66. inline const std::string& URIRedirection::uri() const
  67. {
  68. return _uri;
  69. }
  70. } // namespace Poco
  71. #endif // Foundation_URIStreamFactory_INCLUDED