source: XMLIO_V2/external/include/Poco/URIStreamOpener.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
1//
2// URIStreamOpener.h
3//
4// $Id: //poco/1.3/Foundation/include/Poco/URIStreamOpener.h#2 $
5//
6// Library: Foundation
7// Package: URI
8// Module:  URIStreamOpener
9//
10// Definition of the URIStreamOpener class.
11//
12// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// Permission is hereby granted, free of charge, to any person or organization
16// obtaining a copy of the software and accompanying documentation covered by
17// this license (the "Software") to use, reproduce, display, distribute,
18// execute, and transmit the Software, and to prepare derivative works of the
19// Software, and to permit third-parties to whom the Software is furnished to
20// do so, all subject to the following:
21//
22// The copyright notices in the Software and this entire statement, including
23// the above license grant, this restriction and the following disclaimer,
24// must be included in all copies of the Software, in whole or in part, and
25// all derivative works of the Software, unless such copies or derivative
26// works are solely in the form of machine-executable object code generated by
27// a source language processor.
28//
29// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35// DEALINGS IN THE SOFTWARE.
36//
37
38
39#ifndef Foundation_URIStreamOpener_INCLUDED
40#define Foundation_URIStreamOpener_INCLUDED
41
42
43#include "Poco/Foundation.h"
44#include "Poco/Mutex.h"
45#include <istream>
46#include <map>
47
48
49namespace Poco {
50
51
52class URI;
53class URIStreamFactory;
54class Path;
55
56
57class Foundation_API URIStreamOpener
58        /// The URIStreamOpener class is used to create and open input streams
59        /// for resourced identified by Uniform Resource Identifiers.
60        ///
61        /// For every URI scheme used, a URIStreamFactory must be registered.
62        /// A FileStreamFactory is automatically registered for file URIs.
63{
64public:
65        enum
66        {
67                MAX_REDIRECTS = 10
68        };
69       
70        URIStreamOpener();
71                /// Creates the URIStreamOpener and registers a FileStreamFactory
72                /// for file URIs.
73
74        ~URIStreamOpener();
75                /// Destroys the URIStreamOpener and deletes all registered
76                /// URI stream factories.
77
78        std::istream* open(const URI& uri) const;
79                /// Tries to create and open an input stream for the resource specified
80                /// by the given uniform resource identifier.
81                ///
82                /// If no URIStreamFactory has been registered for the URI's
83                /// scheme, a UnknownURIScheme exception is thrown.
84                /// If the stream cannot be opened for any reason, an
85                /// IOException is thrown.
86                ///
87                /// The given URI must be a valid one. This excludes file system paths.
88                ///
89                /// Whoever calls the method is responsible for deleting
90                /// the returned stream.
91
92        std::istream* open(const std::string& pathOrURI) const;
93                /// Tries to create and open an input stream for the resource specified
94                /// by the given path or uniform resource identifier.
95                ///
96                /// If the stream cannot be opened for any reason, an
97                /// Exception is thrown.
98                ///
99                /// The method first tries to interpret the given pathOrURI as an URI.
100                /// If this fails, the pathOrURI is treated as local filesystem path.
101                /// If this also fails, an exception is thrown.
102                ///
103                /// Whoever calls the method is responsible for deleting
104                /// the returned stream.
105
106        std::istream* open(const std::string& basePathOrURI, const std::string& pathOrURI) const;
107                /// Tries to create and open an input stream for the resource specified
108                /// by the given path or uniform resource identifier.
109                ///
110                /// pathOrURI is resolved against basePathOrURI (see URI::resolve() and
111                /// Path::resolve() for more information).
112                ///
113                /// If the stream cannot be opened for any reason, an
114                /// Exception is thrown.
115                ///
116                /// Whoever calls the method is responsible for deleting
117                /// the returned stream.
118               
119        void registerStreamFactory(const std::string& scheme, URIStreamFactory* pFactory);
120                /// Registers a URIStreamFactory for the given scheme. If another factory
121                /// has already been registered for the scheme, an ExistsException is thrown.
122                ///
123                /// The URIStreamOpener takes ownership of the factory and deletes it when it is
124                /// no longer needed (in other words, when the URIStreamOpener is deleted).
125
126        void unregisterStreamFactory(const std::string& scheme);
127                /// Unregisters and deletes the URIStreamFactory for the given scheme.
128                ///
129                /// Throws a NotFoundException if no URIStreamFactory has been registered
130                /// for the given scheme.
131               
132        bool supportsScheme(const std::string& scheme);
133                /// Returns true iff a URIStreamFactory for the given scheme
134                /// has been registered.
135
136        static URIStreamOpener& defaultOpener();
137                /// Returns a reference to the default URIStreamOpener.
138
139protected:
140        std::istream* openFile(const Path& path) const;
141        std::istream* openURI(const std::string& scheme, const URI& uri) const;
142
143private:
144        URIStreamOpener(const URIStreamOpener&);
145        URIStreamOpener& operator = (const URIStreamOpener&);
146
147        typedef std::map<std::string, URIStreamFactory*> FactoryMap;
148       
149        FactoryMap        _map;
150        mutable FastMutex _mutex;
151};
152
153
154} // namespace Poco
155
156
157#endif // Foundation_URIStreamOpener_INCLUDED
Note: See TracBrowser for help on using the repository browser.