#include <URLBase.h>
Classes | |
class | Factory |
Public Member Functions | |
URL_Base () | |
virtual | ~URL_Base () |
virtual bool | parse (const ACE_CString &url_string) |
void | set_path (const ACE_CString &path) |
virtual void | set_query (const ACE_CString &query) |
virtual void | set_fragment (const ACE_CString &fragment) |
virtual const ACE_CString & | get_scheme () const =0 |
const ACE_CString & | get_protocol () const |
virtual ACE_CString | get_authority () const |
const ACE_CString & | get_path () const |
virtual const ACE_CString & | get_query () const |
virtual const ACE_CString & | get_fragment () const |
virtual URLStream | open () const |
virtual URLStream | open (ClientRequestHandler &rh) const |
virtual ACE_CString | to_string () const =0 |
virtual bool | validate () |
Static Public Member Functions | |
static URL_Base * | create_from_string (const ACE_CString &url_string) |
static void | register_factory (Factory *url_factory) |
static void | deregister_factory (Factory *url_factory) |
Protected Member Functions | |
bool | strip_scheme (ACE_CString &url_string) |
virtual int | parse_authority (std::istream &is) |
virtual bool | has_authority () |
virtual ClientRequestHandler * | create_default_request_handler () const =0 |
Static Protected Attributes | |
static const ACE_CString | empty_ |
Private Types | |
typedef ACE_Map_Manager < ACE_CString, Factory *, ACE_SYNCH::MUTEX > | TURLFactoryMap |
typedef ACE_Singleton < TURLFactoryMap, ACE_SYNCH::NULL_MUTEX > | TURLFactorySingleton |
Private Attributes | |
ACE_CString | path_ |
Static Private Attributes | |
static TURLFactoryMap * | factories_ = 0 |
Definition at line 60 of file URLBase.h.
typedef ACE_Map_Manager<ACE_CString, Factory*, ACE_SYNCH::MUTEX> ACE::INet::URL_Base::TURLFactoryMap [private] |
typedef ACE_Singleton<TURLFactoryMap, ACE_SYNCH::NULL_MUTEX> ACE::INet::URL_Base::TURLFactorySingleton [private] |
Reimplemented in ACE::FTP::URL, ACE::HTTP::URL, and ACE::HTTPS::URL.
ACE::INet::URL_Base::URL_Base | ( | ) |
Definition at line 69 of file URLBase.cpp.
{ }
ACE::INet::URL_Base::~URL_Base | ( | ) | [virtual] |
Definition at line 73 of file URLBase.cpp.
{}
virtual ClientRequestHandler* ACE::INet::URL_Base::create_default_request_handler | ( | ) | const [protected, pure virtual] |
Implemented in ACE::FTP::URL, ACE::HTTP::URL, and ACE::HTTPS::URL.
URL_Base * ACE::INet::URL_Base::create_from_string | ( | const ACE_CString & | url_string | ) | [static] |
Definition at line 165 of file URLBase.cpp.
{ ACE_CString::size_type pos = url_string.find (':'); if (pos >0 ) { Factory* url_factory = 0; if (factories_->find (url_string.substr (0, pos), url_factory) == 0) { return url_factory->create_from_string (url_string); } } return 0; }
void ACE::INet::URL_Base::deregister_factory | ( | Factory * | url_factory | ) | [static] |
Definition at line 227 of file URLBase.cpp.
{ if (factories_ && url_factory) { factories_->unbind (url_factory->protocol ()); }; }
ACE_CString ACE::INet::URL_Base::get_authority | ( | ) | const [inline, virtual] |
Reimplemented in ACE::INet::URL_INetBase, and ACE::INet::URL_INetAuthBase.
Definition at line 52 of file URLBase.inl.
{ return empty_; }
const ACE_CString & ACE::INet::URL_Base::get_fragment | ( | ) | const [inline, virtual] |
const ACE_CString & ACE::INet::URL_Base::get_path | ( | ) | const [inline] |
Definition at line 18 of file URLBase.inl.
{ return this->path_; }
const ACE_CString & ACE::INet::URL_Base::get_protocol | ( | ) | const [inline] |
Definition at line 12 of file URLBase.inl.
{ return this->get_scheme (); }
const ACE_CString & ACE::INet::URL_Base::get_query | ( | ) | const [inline, virtual] |
virtual const ACE_CString& ACE::INet::URL_Base::get_scheme | ( | ) | const [pure virtual] |
Implemented in ACE::FTP::URL, ACE::HTTP::URL, and ACE::HTTPS::URL.
bool ACE::INet::URL_Base::has_authority | ( | ) | [protected, virtual] |
Reimplemented in ACE::INet::URL_INetBase.
Definition at line 137 of file URLBase.cpp.
{ return false; }
URLStream ACE::INet::URL_Base::open | ( | void | ) | const [virtual] |
Definition at line 147 of file URLBase.cpp.
{ ClientRequestHandler* rh = this->create_default_request_handler (); if (rh) { rh->handle_open_request (*this); return URLStream (rh); } else return URLStream (0); }
URLStream ACE::INet::URL_Base::open | ( | ClientRequestHandler & | rh | ) | const [virtual] |
Definition at line 159 of file URLBase.cpp.
{ rh.handle_open_request (*this); return URLStream (rh); }
bool ACE::INet::URL_Base::parse | ( | const ACE_CString & | url_string | ) | [virtual] |
Definition at line 75 of file URLBase.cpp.
{ static const int eof = std::char_traits<ACE::IOS::CString_OStream::char_type>::eof (); ACE_CString uri = url_string; if (this->strip_scheme (uri)) { ACE::IOS::CString_OStream sos; ACE::IOS::CString_IStream sis (uri); int ch; // parse authority part (if any) if ((ch = this->parse_authority (sis)) == '/' || !this->has_authority ()) // relative paths allowed if no authority { // parse path part sos.put (ch); for (ch = sis.get (); ch != '?' && ch != '#' && ch != eof ;ch = sis.get ()) sos.put (ch); this->set_path (sos.str ()); sos.clear (); } else { // empty path this->set_path (empty_); } if (ch == '?') { // parse query part for (ch = sis.get (); ch != '#' && ch != eof ;ch = sis.get ()) sos.put (ch); this->set_query (sos.str ()); sos.clear (); } if (ch == '#') { // get fragment sos << sis.rdbuf (); this->set_fragment (sos.str ()); } else if (ch != eof) { // should not happen return false; } // check for (minimum) correctness return this->validate (); } return false; }
int ACE::INet::URL_Base::parse_authority | ( | std::istream & | is | ) | [protected, virtual] |
Reimplemented in ACE::INet::URL_INetBase, and ACE::INet::URL_INetAuthBase.
Definition at line 132 of file URLBase.cpp.
{
return is.get ();
}
void ACE::INet::URL_Base::register_factory | ( | Factory * | url_factory | ) | [static] |
Definition at line 217 of file URLBase.cpp.
{ if (factories_ == 0) { factories_ = URL_Base::TURLFactorySingleton::instance (); } if (url_factory) factories_->bind (url_factory->protocol (), url_factory); }
void ACE::INet::URL_Base::set_fragment | ( | const ACE_CString & | fragment | ) | [inline, virtual] |
Definition at line 35 of file URLBase.inl.
{ }
void ACE::INet::URL_Base::set_path | ( | const ACE_CString & | path | ) | [inline] |
Definition at line 24 of file URLBase.inl.
{ this->path_ = path; }
void ACE::INet::URL_Base::set_query | ( | const ACE_CString & | query | ) | [inline, virtual] |
Definition at line 30 of file URLBase.inl.
{ }
bool ACE::INet::URL_Base::strip_scheme | ( | ACE_CString & | url_string | ) | [protected] |
Definition at line 197 of file URLBase.cpp.
{ // since this will be called at a point where the // actual URL class is already known (and with that // the protocol prefix) we allow for the fact we // may get a url passed without the actual prefix ACE_CString::size_type pos = url_string.find (':'); if (pos > 0 && url_string[pos+1] == '/' && url_string[pos+1] == '/') { // in case we find a scheme check for the right protocol if (this->get_protocol () != url_string.substr (0, pos)) { return false; } url_string = url_string.substr (pos+3); // skip '<protocol>://' } return true; }
virtual ACE_CString ACE::INet::URL_Base::to_string | ( | ) | const [pure virtual] |
Implemented in ACE::FTP::URL, and ACE::HTTP::URL.
bool ACE::INet::URL_Base::validate | ( | ) | [virtual] |
Reimplemented in ACE::INet::URL_INetBase.
Definition at line 142 of file URLBase.cpp.
{ return true; }
const ACE_CString ACE::INet::URL_Base::empty_ [static, protected] |
URL_Base::TURLFactoryMap * ACE::INet::URL_Base::factories_ = 0 [static, private] |
ACE_CString ACE::INet::URL_Base::path_ [private] |