#include <URL.h>
Inheritance diagram for Net::URL:
Public Member Functions | |
URL (String *protocol) | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual void | parseHost (String *hostname) |
virtual String * | protocol (void) |
virtual String * | host (void) |
virtual ByteArray * | hostAddress (void) |
virtual String * | hostAndPort (void) |
virtual String * | pathString (void) |
virtual unsigned short | port (void) |
virtual IPSocketAddress * | socketAddress (void) |
virtual String * | asString (void) const |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
virtual void | printContentOn (Stream *stream) const |
Static Public Member Functions | |
static URL * | fromString (String *urlString) |
Protected Attributes | |
String * | _proto |
String * | _host |
unsigned short | _port |
String * | _path |
String * | _fragment |
String * | _query |
|
Definition at line 36 of file URL.cc. References _proto. Referenced by fromString(). 00037 { 00038 _proto = protocol; 00039 }
|
|
Definition at line 147 of file URL.cc. References Core::Stream::contents(), and printContentOn(). 00148 { 00149 Stream *stream = (new String(64))->writeStream(); 00150 printContentOn(stream); 00151 return dynamic_cast<String *>(stream->contents()); 00152 }
|
|
Answer receiver class name. Because there isn't any standard way to obtain class name this method comes to place. Every class should rewrite this method but many didn't (yet). Reimplemented from Core::Object. Definition at line 42 of file URL.cc. 00043 { 00044 return new String("URL"); 00045 }
|
|
Definition at line 48 of file URL.cc. References Core::String::copy(), Core::String::includesSubcollection(), Core::String::indexOf(), parseHost(), Core::String::size(), and URL(). 00049 { 00050 URL *url; 00051 String *proto; 00052 long protoIdx; 00053 00054 if (!urlString->includesSubcollection("://")) { 00055 (new Error(new String("Protocol expected in url string."), 00056 new String(__PRETTY_FUNCTION__), urlString))->raise(); 00057 } 00058 protoIdx = urlString->indexOf(':'); 00059 proto = dynamic_cast<String *>(urlString->copy(0, protoIdx)); 00060 urlString = dynamic_cast<String *>(urlString->copy(proto->size() + 3, urlString->size())); 00061 url = new URL(proto); 00062 url->parseHost(urlString); 00063 00064 return url; 00065 }
|
|
Definition at line 107 of file URL.cc. References _host. 00108 { 00109 return _host; 00110 }
|
|
Definition at line 112 of file URL.cc. References socketAddress(). 00113 { 00114 return socketAddress()->hostAddress(); 00115 }
|
|
Definition at line 117 of file URL.cc. 00118 { 00119 if (_port <= 0) 00120 return _host; 00121 return dynamic_cast<String *>(&(*_host + *(String::format(":%u", _port)))); 00122 }
|
|
Definition at line 68 of file URL.cc. References _fragment, _host, _path, _port, _query, Core::String::asNumber(), and Core::String::size(). Referenced by fromString(). 00069 { 00070 long portIdx = urlWithPath->indexOf(':'); 00071 long pathIdx = urlWithPath->indexOf('/'); 00072 long fragmentIdx = urlWithPath->indexOf('#'); 00073 long queryIdx = urlWithPath->indexOf('?'); 00074 00075 if (queryIdx > 0) { 00076 _query = dynamic_cast<String *>(urlWithPath->copy(queryIdx + 1, 00077 urlWithPath->size())); 00078 } else queryIdx = urlWithPath->size(); 00079 00080 if (fragmentIdx > 0) { 00081 _fragment = dynamic_cast<String *>(urlWithPath->copy(fragmentIdx + 1, 00082 queryIdx)); 00083 } else fragmentIdx = queryIdx; 00084 00085 if (pathIdx > 0) { 00086 _path = dynamic_cast<String *>(urlWithPath->copy(pathIdx + 1, fragmentIdx)); 00087 } else pathIdx = fragmentIdx; 00088 00089 if (portIdx > 0) { 00090 String *portStr = dynamic_cast<String *>(urlWithPath->copy(portIdx + 1, 00091 pathIdx)); 00092 _port = portStr->asNumber()->asLong() & 0xffff; 00093 } else { 00094 _port = 0; 00095 portIdx = pathIdx; 00096 } 00097 00098 _host = dynamic_cast<String *>(urlWithPath->copy(0, portIdx)); 00099 }
|
|
Definition at line 124 of file URL.cc. References _path, _query, Core::Stream::contents(), Core::Stream::nextPut(), Core::Stream::nextPutAll(), and nil. 00125 { 00126 Stream *stream = (new String(64))->writeStream(); 00127 stream->nextPut('/'); 00128 stream->nextPutAll(_path); 00129 if (_query != nil) { 00130 stream->nextPut('?'); 00131 stream->nextPutAll(_query); 00132 } 00133 return dynamic_cast<String *>(stream->contents()); 00134 }
|
|
Definition at line 136 of file URL.cc. References _port. 00137 { 00138 return _port; 00139 }
|
|
Definition at line 162 of file URL.cc. References _host, _path, _port, _proto, _query, Core::Stream::nextPut(), Core::Stream::nextPutAll(), nil, and Core::Stream::print(). Referenced by asString(), and printOn(). 00163 { 00164 stream->nextPutAll(_proto); 00165 stream->nextPutAll("://"); 00166 stream->nextPutAll(_host); 00167 if (_port > 0) { 00168 stream->nextPut(':'); 00169 stream->print((long int) _port); 00170 } 00171 stream->nextPut('/'); 00172 stream->nextPutAll(_path); 00173 if (_query != nil) { 00174 stream->nextPut('?'); 00175 stream->nextPutAll(_query); 00176 } 00177 }
|
|
Print object identification into the stream. Object identification is formed from its className() by default. But complicated classes (eg. collections) may print some other information.
Reimplemented from Core::Object. Definition at line 155 of file URL.cc. References Core::Stream::nextPut(), and printContentOn(). 00156 { 00157 stream->nextPut('<'); 00158 printContentOn(stream); 00159 stream->nextPut('>'); 00160 }
|
|
Definition at line 102 of file URL.cc. References _proto. 00103 { 00104 return _proto; 00105 }
|
|
Definition at line 141 of file URL.cc. References _host, _port, and Net::IPSocketAddress::hostName(). Referenced by hostAddress(). 00142 { 00143 return IPSocketAddress::hostName(_host, _port); 00144 }
|
|
Definition at line 43 of file URL.h. Referenced by parseHost(). |
|
Definition at line 40 of file URL.h. Referenced by host(), hostAndPort(), parseHost(), printContentOn(), and socketAddress(). |
|
Definition at line 42 of file URL.h. Referenced by parseHost(), pathString(), and printContentOn(). |
|
Definition at line 41 of file URL.h. Referenced by hostAndPort(), parseHost(), port(), printContentOn(), and socketAddress(). |
|
Definition at line 39 of file URL.h. Referenced by printContentOn(), protocol(), and URL(). |
|
Definition at line 44 of file URL.h. Referenced by parseHost(), pathString(), and printContentOn(). |