2003-09-11 12:26:53 +02:00
|
|
|
#ifndef ARABICA_INPUT_SOURCE_RESOLVER_H
|
|
|
|
#define ARABICA_INPUT_SOURCE_RESOLVER_H
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <SAX/ArabicaConfig.hpp>
|
2002-06-21 13:16:28 +02:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <SAX/InputSource.hpp>
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-05 11:49:18 +02:00
|
|
|
namespace Arabica
|
|
|
|
{
|
|
|
|
namespace SAX
|
|
|
|
{
|
|
|
|
|
2002-06-21 13:16:28 +02:00
|
|
|
class InputSourceResolver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
template<class stringT, class stringAdaptorT>
|
2007-09-06 00:08:51 +02:00
|
|
|
InputSourceResolver(const SAX::InputSource<stringT, stringAdaptorT>& inputSource,
|
2009-11-28 02:12:28 +01:00
|
|
|
const stringAdaptorT& /*SA*/) :
|
2002-06-21 13:16:28 +02:00
|
|
|
deleteStream_(false),
|
|
|
|
byteStream_(0)
|
|
|
|
{
|
2007-07-19 19:01:08 +02:00
|
|
|
open(stringAdaptorT::asStdString(inputSource.getPublicId()),
|
|
|
|
stringAdaptorT::asStdString(inputSource.getSystemId()),
|
2002-06-21 13:16:28 +02:00
|
|
|
inputSource.getByteStream());
|
|
|
|
} // InputSourceResolver
|
|
|
|
~InputSourceResolver();
|
|
|
|
|
|
|
|
std::istream* resolve() const { return byteStream_; }
|
|
|
|
|
|
|
|
typedef std::istream* (*URIResolver)(const std::string& url);
|
|
|
|
static bool registerResolver(const std::string& method, URIResolver resolver);
|
|
|
|
static bool unRegisterResolver(const std::string& method);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// no impl
|
|
|
|
InputSourceResolver(const InputSourceResolver&);
|
|
|
|
InputSourceResolver& operator=(const InputSourceResolver&);
|
|
|
|
bool operator==(const InputSourceResolver&);
|
|
|
|
|
|
|
|
// instance variables
|
|
|
|
bool deleteStream_;
|
|
|
|
std::istream* byteStream_;
|
|
|
|
|
|
|
|
void open(const std::string& publicId,
|
|
|
|
const std::string& systemId,
|
|
|
|
std::istream* byteStream);
|
|
|
|
|
|
|
|
// class variables
|
|
|
|
static URIResolver findResolver(std::string method);
|
|
|
|
|
|
|
|
typedef std::map<std::string, URIResolver> resolverMapT;
|
|
|
|
static resolverMapT& resolverMap()
|
|
|
|
{
|
|
|
|
static resolverMapT theMap;
|
|
|
|
return theMap;
|
|
|
|
} // resolverMap
|
|
|
|
}; // class InputSourceResolver
|
|
|
|
|
2007-09-05 11:49:18 +02:00
|
|
|
} // namespace SAX
|
|
|
|
} // namespace Arabica
|
2002-06-21 13:16:28 +02:00
|
|
|
#endif
|
|
|
|
|