URIStreamFactory.h 2.0 KB

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