Defined in file: hzUrl.h
hzUrl holds a URL (Universal Resource Locator) value. For the avoidance of confusion, a URL is not the same as a URI (Universal Resource Identifier). URIs identify resources in a broader sense and can identify both offline and online resources. URLs locate resources online and specify the exact location. Thus, all URLs are a URI but not all URIs are URLs. HadronZoo does not have a URI data type. The anticipation being that only URLs would be useful in webapps. URL values have the following parts:- - Protocol Optional e.g. https://. If omitted the protocol is taken as https://, or http:// if the website in question does not support HTTPS - Domain Compulsory e.g. www.hadronzoo.com. This can be specified as an IP address. - Port Optional, e.g. ':8434'. Use is rare and the port is only needed if it differs from the standard port used by the protocol. - Resource Optional, e.g. /contacts. If the resource is not stated, the website homepage is assumed. To qualify as a URL, a string only needs to contain the domain. Note that the reource part can be complex. It need not be a simple set of one or more strings separated by a forward slash representing 'directories' relative to the root for the domain. The resource can go on to include additional qualifiers, consisting of one or more name-values pairs delimited by the query character. For this reason industy standards for URL maximum size, vary around the 2,000 mark.
Constructors/Detructors
| hzUrl* | hzUrl | (void) | |
| hzUrl* | hzUrl | (hzUrl& op) | |
| hzUrl* | hzUrl | (const char* cpUrl) | |
| hzUrl* | hzUrl | (hzString& url) | |
| void | ~hzUrl | (void) |
Public Methods:
| void | Clear | (void) | Clear the contents of this instance Arguments: None Returns: None |
| hzString | Domain | (void) | Create and return a string consisting of the domain name only. Arguments: None |
| hzString | Filename | (void) | Convert a URL to a string suitable for a filename as used in webscraping. The following conversions occur:- 1) The sequence http:// is converted to h: (but only if it occurs at the start) 2) The sequence https:// is converted to s: (but only if it occurs at the start) 3) The slash is converted to an @ 4) The @ (which should not exist Converts non-URL and non-filename chars into %xx form. Note that no assumptions can be made about the input except that it may contain chars unsuitable for filenames (eg the forward slash). The encoding must therefore be reversible. This function assumes the chars a-z, A-Z, 0-9, the period and the underscore are the only valid filename chars. Any other char will be converted to a set of chars consisting of a percent sign and two hexidecimal numbers. This means that when it comes to decoding, such a set will be converted to a single char. This would be fine if we could assume that no input would ever have such a sequence but alas we cannot assume this. It is nessesary therefore to convert percent chars in the input to a %hh set even if they are blatently part of such a set already! Arguments: None |
| bool | IsSSL | (void) | Return true is the URL indicates a would-be connection would use SSL Arguments: None |
| uint32_t | Length | (void) | Return the total length of the URL (including the http:// bit) Arguments: None |
| uint32_t | Port | (void) | Return the port (default is 80) that the URL states (if any) Arguments: None |
| hzString | Resource | (void) | Create and return a string consisting of the resource component only. Arguments: None |
| hzUrl& | SetValue | (hzString domain)hzString resource, bool bSecure, uint32_t nPort, | This is used as an alternative to the assignement operator, specifically to deal with such URLs as links in webpages. These may be full URLs with or without the scheme, but with the domain - or they can simply start with a / and consist only of the resource. Where the link lacks the domain, the supplied domain is used. Where the link does have a domain specified this takes precedence. |
| hzString | Whole | (void) | Return a pointer to the whole string as a null terminated sequence. Arguments: None |
| void | _dec_copy | (void) | |
| void | _inc_copy | (void) | |
| uint32_t | _int_addr | (void) | |
| void | _int_clr | (void) | |
| void | _int_set | (uint32_t addr) | |
| bool | valid | (void) |
Overloaded operators:
| const char* | hzUrl :: operator const char * | (void) | Returns the string data (a null terminated string) Arguments: None Pointer to value as null terminated string |
| const char* | operator const char * | (void) | |
| bool | operator! | (void) | |
| bool | operator!= | (const char* cpStr) | Return true if this hzUrl is not equal to the supplied character string |
| bool | operator!= | (hzString& S) | Return true if this hzUrl is not equal to the supplied string |
| const char* | operator* | (void) | Returns the URL data (a null terminated string) Arguments: None Pointer to value as null terminated string |
| bool | operator< | (hzUrl& testUrl) | Test for this URL being less than the supplied test URL. The domain part takes precedence, followed by the resource part and finally the port. |
| ostream& | operator<< | (ostream& os)hzUrl& url, | |
| bool | operator<= | (hzUrl& testUrl) | Test for this URL being lexically less or equal to than the supplied test URL |
| hzUrl& | operator= | (const char* url) | Assign the URL by character string |
| hzUrl& | operator= | (hzString& S) | Assign the URL by string instance |
| hzUrl& | operator= | (hzUrl& url) | Assign the URL by copying another hzUrl instance |
| bool | operator== | (hzUrl& testUrl) | Test for equality between this URL and a supplied test value |
| bool | operator== | (const char* cpStr) | Return true if this hzUrl is equal to the supplied character string |
| bool | operator== | (hzString& S) | Return true if this hzUrl is equal to the supplied string |
| bool | operator> | (hzUrl& testUrl) | Test for this URL being lexically greater than the supplied test URL |
| bool | operator>= | (hzUrl& testUrl) | Test for this URL being lexically greater than or equal the supplied test URL |
| ostream& | operator>> | (ostream& os)hzUrl& url, |
Member Variables:
| uint32_t | m_addr | Address of data and control space |