#include <url.hpp>
Public Member Functions | |
virtual | ~url_stream_factory () |
std::ostream * | get_ostream (url_parser const &url) const |
See do_get_ostream(). | |
std::istream * | get_istream (url_parser const &url) const |
See do_get_istream(). | |
Static Public Member Functions | |
static url_stream_factory * | create_factory_for_scheme (std::string const &scheme) |
Classloads an instance of url_stream_factory associated with the given scheme. | |
template<typename SubclassT> | |
static void | register_factory_for_scheme (std::string const &scheme) |
Registers SubclassT as a subclass of url_stream_factory such that calling create_factory_for_scheme(scheme) will return an instance of SubclassT. | |
Protected Member Functions | |
url_stream_factory () | |
virtual std::ostream * | do_get_ostream (url_parser const &url) const |
Default implementation returns 0. | |
virtual std::istream * | do_get_istream (url_parser const &url) const |
Default implementation returns 0. |
Subclasses must reimplement the virtual functions and register with the classloader like so:
define S11N_FACREG_TYPE my_subclass_type define S11N_FACREG_INTERFACE_TYPE s11n::io::url_stream_factory define S11N_FACREG_TYPE_NAME "my_subclass_type" include <s11n.net/s11n/factory_reg.hpp>
They may also want to set up classloader aliases during the static initialization phase, as demonstrated for the file:// protocol in url.cpp.
Note for subclasser: NEVER EVER call s11n::io::get_i/ostream() from this class, because those functions dispatch to url_stream_factory when possible, and callint those from here can cause an endless loop.
Definition at line 158 of file url.hpp.
s11n::io::url_stream_factory::url_stream_factory | ( | ) | [inline, protected] |
virtual s11n::io::url_stream_factory::~url_stream_factory | ( | ) | [inline, virtual] |
virtual std::ostream* s11n::io::url_stream_factory::do_get_ostream | ( | url_parser const & | url | ) | const [inline, protected, virtual] |
Default implementation returns 0.
Subclasses.should return an instance of a stream capable of writing to the given URL. On error they should return 0 or throw an exception.
The caller owns the returned pointer, which may be 0.
Reimplemented in s11n::io::file_stream_factory.
virtual std::istream* s11n::io::url_stream_factory::do_get_istream | ( | url_parser const & | url | ) | const [inline, protected, virtual] |
Default implementation returns 0.
Subclasses.should return an instance of a stream capable of reading from the given URL. On error they should return 0 or throw an exception.
The caller owns the returned pointer, which may be 0.
Reimplemented in s11n::io::file_stream_factory.
std::ostream* s11n::io::url_stream_factory::get_ostream | ( | url_parser const & | url | ) | const [inline] |
std::istream* s11n::io::url_stream_factory::get_istream | ( | url_parser const & | url | ) | const [inline] |
static url_stream_factory* s11n::io::url_stream_factory::create_factory_for_scheme | ( | std::string const & | scheme | ) | [static] |
Classloads an instance of url_stream_factory associated with the given scheme.
Caller owns the returned pointer, which may be 0.
Subclass authors are responsible for registering their subclasses with the url_stream_factory classloader.
static void s11n::io::url_stream_factory::register_factory_for_scheme | ( | std::string const & | scheme | ) | [inline, static] |
Registers SubclassT as a subclass of url_stream_factory such that calling create_factory_for_scheme(scheme) will return an instance of SubclassT.
SubclassT must be-a url_stream_factory and must be compatible with the s11n::fac factory layer.