#include <webaddr.h>
Inheritance diagram for WebAddress:
Public Member Functions | |
WebAddress & | operator= (const WebAddress &) |
Assignment operator. | |
void | Combine (WebAddress Relative) |
Combines this Web Address with a base Web Address. | |
WebAddress () | |
Default WebAddress class constructor. | |
WebAddress (const WebAddress &InAddress) | |
Copy Constructor for the WebAddress class. | |
WebAddress (const String_256 &StringToParse, WebCorrectFlags wcfToUse=WebCorrectFlags()) | |
INT32 | operator== (WebAddress &Other) |
Equality operator. | |
String_256 | GetWebAddress () |
Returns the URL string. | |
const String_256 & | GetScheme () const |
const String_256 & | GetNetLoc () const |
const String_256 & | GetPath () const |
const String_256 & | GetParameters () const |
const String_256 & | GetQuery () const |
const String_256 & | GetFragment () const |
const BOOL | IsAbsolute () |
BOOL | IsHTTP () const |
Finds whether this Web Address starts with "HTTP:". | |
BOOL | IsValidHTTP () const |
Finds whether this Web Address is a valid HTTP address. | |
BOOL | IsLocalFile () const |
Works out if we consider this Web Address to be a local filename. | |
PathName | GetPathName () const |
const BOOL | SchemeIsEmpty () const |
const BOOL | NetLocIsEmpty () const |
const BOOL | PathIsEmpty () const |
const BOOL | ParametersIsEmpty () const |
const BOOL | QueryIsEmpty () const |
const BOOL | FragmentIsEmpty () const |
const BOOL | IsEmpty () const |
void | SetScheme (String_256 &NewScheme) |
void | SetNetLoc (String_256 &NewNetLoc) |
void | SetPath (String_256 &NewPath) |
void | SetParameters (String_256 &NewPara) |
void | SetQuery (String_256 &NewQuery) |
void | SetFragment (String_256 &NewFragment) |
WebAddress & | operator= (const WebAddress &) |
void | Combine (WebAddress Relative) |
WebAddress () | |
WebAddress (const WebAddress &InAddress) | |
WebAddress (const String_256 &StringToParse, WebCorrectFlags wcfToUse=WebCorrectFlags()) | |
INT32 | operator== (WebAddress &Other) |
String_256 | GetWebAddress () |
const String_256 & | GetScheme () const |
const String_256 & | GetNetLoc () const |
const String_256 & | GetPath () const |
const String_256 & | GetParameters () const |
const String_256 & | GetQuery () const |
const String_256 & | GetFragment () const |
const BOOL | IsAbsolute () |
BOOL | IsHTTP () const |
BOOL | IsValidHTTP () const |
BOOL | IsLocalFile () const |
PathName | GetPathName () const |
const BOOL | SchemeIsEmpty () const |
const BOOL | NetLocIsEmpty () const |
const BOOL | PathIsEmpty () const |
const BOOL | ParametersIsEmpty () const |
const BOOL | QueryIsEmpty () const |
const BOOL | FragmentIsEmpty () const |
const BOOL | IsEmpty () const |
void | SetScheme (String_256 &NewScheme) |
void | SetNetLoc (String_256 &NewNetLoc) |
void | SetPath (String_256 &NewPath) |
void | SetParameters (String_256 &NewPara) |
void | SetQuery (String_256 &NewQuery) |
void | SetFragment (String_256 &NewFragment) |
Static Public Member Functions | |
static BOOL | IsHTTP (const String_256 &strTest) |
Finds whether strTest starts with "HTTP:". | |
static BOOL | IsHTTP (const String_256 &strTest) |
Protected Member Functions | |
BOOL | Parse (const String_256 &InString) |
Takes the string and splits it into its component parts. | |
BOOL | SetFlags () |
Sets the Web Address flags - at the moment the only flag is Absolute - by looking at the Web Address string member variables. | |
void | Correct (String_256 *pstrCorrect, WebCorrectFlags wcfToUse=WebCorrectFlags()) |
Corrects the URL string that the user has entered, according to the correction flags. | |
void | CorrectBackslashes (String_256 *pstrCorrect) |
Corrects any backslashes in the entered string to slashes. | |
void | CorrectLocalFilenames (String_256 *pstrCorrect) |
Assumes pstrCorrect is a local filename, then converts it to a URL referring to a local filename. | |
void | CorrectNetscapeFilenames (String_256 *pstrCorrect) |
Converts a Netscape local filename (file:///xxxxxxx) to an IE3 local filename (file://xxxxxxx) by simply removing the third slash. | |
void | CorrectFTP (String_256 *pstrCorrect) |
Puts "ftp:" on the start of pstrCorrect. | |
void | CorrectHTTP (String_256 *pstrCorrect) |
Puts "http:" on the start of pstrCorrect. | |
void | CorrectMailto (String_256 *pstrCorrect) |
Puts "mailto:" on the start of pstrCorrect. | |
void | CorrectNoSlash (String_256 *pstrCorrect) |
Adds a slash to the end of the string. | |
void | CorrectNoNetLoc (String_256 *pstrCorrect) |
Ensures that pstrCorrect starts with "http://". | |
BOOL | ShouldCorrectLocalFilenames (String_256 *pstrCorrect) |
Works out if we consider this string to be a local filename. | |
BOOL | ShouldCorrectNetscapeFilenames (String_256 *pstrCorrect) |
Works out if we consider this string to be a Netscape local filename. | |
BOOL | ShouldCorrectFTP (String_256 *pstrCorrect) |
Works out if we consider this string to be a ftp address with the "ftp:" missing. | |
BOOL | ShouldCorrectHTTP (String_256 *pstrCorrect) |
Works out if we consider this string to be a http address with the "http:" missing. | |
BOOL | ShouldCorrectMailto (String_256 *pstrCorrect) |
Works out if we consider this string to be a mail address with the "mailto:" missing. | |
BOOL | ShouldCorrectNoSlash (String_256 *pstrCorrect) |
Works out if we consider this string to be a URL with a trailing slash missing. | |
BOOL | ShouldCorrectNoNetLoc (String_256 *pstrCorrect) |
Works out if we consider this string to be an HTTP address with the "//" to signify a network location missing. For example:. | |
BOOL | Parse (const String_256 &InString) |
BOOL | SetFlags () |
void | Correct (String_256 *pstrCorrect, WebCorrectFlags wcfToUse=WebCorrectFlags()) |
void | CorrectBackslashes (String_256 *pstrCorrect) |
void | CorrectLocalFilenames (String_256 *pstrCorrect) |
void | CorrectNetscapeFilenames (String_256 *pstrCorrect) |
void | CorrectFTP (String_256 *pstrCorrect) |
void | CorrectHTTP (String_256 *pstrCorrect) |
void | CorrectMailto (String_256 *pstrCorrect) |
void | CorrectNoSlash (String_256 *pstrCorrect) |
void | CorrectNoNetLoc (String_256 *pstrCorrect) |
BOOL | ShouldCorrectLocalFilenames (String_256 *pstrCorrect) |
BOOL | ShouldCorrectNetscapeFilenames (String_256 *pstrCorrect) |
BOOL | ShouldCorrectFTP (String_256 *pstrCorrect) |
BOOL | ShouldCorrectHTTP (String_256 *pstrCorrect) |
BOOL | ShouldCorrectMailto (String_256 *pstrCorrect) |
BOOL | ShouldCorrectNoSlash (String_256 *pstrCorrect) |
BOOL | ShouldCorrectNoNetLoc (String_256 *pstrCorrect) |
Protected Attributes | |
BOOL | Absolute |
String_256 | Scheme |
String_256 | NetLoc |
String_256 | Path |
String_256 | Parameters |
String_256 | Query |
String_256 | Fragment |
Private Member Functions | |
CC_DECLARE_DYNAMIC (WebAddress) | |
CC_DECLARE_DYNAMIC (WebAddress) |
Definition at line 115 of file webaddr.h.
|
Default WebAddress class constructor.
Definition at line 126 of file webaddr.cpp.
|
|
Copy Constructor for the WebAddress class.
Definition at line 145 of file webaddr.cpp. 00146 { 00147 Absolute = InAddress.Absolute; 00148 00149 Scheme=InAddress.Scheme; 00150 NetLoc=InAddress.NetLoc; 00151 Path=InAddress.Path; 00152 Parameters=InAddress.Parameters; 00153 Query=InAddress.Query; 00154 Fragment=InAddress.Fragment; 00155 }
|
|
Definition at line 205 of file webaddr.cpp. 00206 { 00207 //First make a copy of the string we've been given 00208 String_256 strCopy=StringToParse; 00209 00210 //And correct the copy 00211 Correct(&strCopy, wcfToUse); 00212 00213 //Then parse the corrected string 00214 Parse(strCopy); 00215 00216 //And finally set the class's flags 00217 SetFlags(); 00218 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Combines this Web Address with a base Web Address.
This is quite hard to explain, so here's an example: if this Web address is "myfile.xar" and the base Web Address is "http://www.xara.com/currentfile.xar" then this function makes this Web Address into "http://www.xara.com/myfile.xar". This function follows the guidelines given in some international standard somewhere. (The one I was talking about above) Because it follows these guidelines (almost) exactly, this function contains one hell of a lot of loops within loops. Sorry! I've tried to comment them helpfully. Notes: The parsing rules follow the guidelines given in http://ds,internic.net/rfc/rfc1808.txt. Please* don't change the parsing rules unless you really know what you're doing and have read the guideline document referred to above. The code below is written according to that document. Do not imitate at home what you have seen on Gladiators, etc, etc. Definition at line 462 of file webaddr.cpp. 00463 { 00464 //Strings are hard coded to reduce code size 00465 String_256 sSlashDotSlash="/./"; 00466 String_256 sSlashDotDotSlash="/../"; 00467 00468 TCHAR cSlash='/'; 00469 00470 //Now start the parsing. 00471 00472 //If the base Web Address is empty, this Web Address does not change 00473 if (Base.IsEmpty()) 00474 goto ReturnNow; 00475 00476 //If this Web Address is empty, then it inherits everything from the 00477 //base Web Address 00478 if (IsEmpty()) 00479 { 00480 Absolute = Base.Absolute; 00481 00482 Scheme=Base.Scheme; 00483 NetLoc=Base.NetLoc; 00484 Path=Base.Path; 00485 Parameters=Base.Parameters; 00486 Query=Base.Query; 00487 Fragment=Base.Fragment; 00488 goto ReturnNow; 00489 } 00490 00491 //If this Web Address is absolute, it does not change 00492 if (IsAbsolute()) 00493 goto ReturnNow; 00494 00495 //If none of the above apply, this Web Address inherits the scheme of 00496 //the Base address 00497 Scheme=Base.Scheme; 00498 00499 //If this Web Address has a net location, we need do nothing more to it. 00500 if (!NetLoc.IsEmpty()) 00501 goto ReturnNow; 00502 00503 //Otherwise, this Web Address inherits the Net Location of the base address. 00504 NetLoc=Base.NetLoc; 00505 00506 //If the path of this Web Address starts with a slash, it is non-relative 00507 //and we need only add it on to the Net Location 00508 if ((*(Path))==cSlash) goto ReturnNow; 00509 00510 00511 //This is where all the loops within loops start. Hang on to your curly brackets. 00512 00513 //Does this Web Address have a path? 00514 if (!Path.IsEmpty()) 00515 { 00516 //Yes. Then the full path is given by: 00517 //The Base URL path up to the rightmost slash + the URL of this Web Address 00518 00519 //This string will hold the base URL path up to the rightmost slash 00520 String_256 sTempPath=""; 00521 00522 //First find the rightmost slash in Base.Path 00523 INT32 iFound=Base.Path.ReverseFind(cSlash); 00524 00525 //Did we find a slash? 00526 if (iFound>=0) 00527 { 00528 //Yes. So copy everything up to that slash into sTempPath 00529 00530 00531 Base.Path.Split(&sTempPath, NULL, iFound, TRUE); 00532 00533 sTempPath+=Path; 00534 00535 Path=sTempPath; 00536 }//End IF there's a slash in Base.Path 00537 00538 00539 //We now need to check the path for ../ and ./ 00540 //First let's search for /./ 00541 iFound=Path.Sub(sSlashDotSlash); 00542 00543 //If we've found a /./ 00544 while (iFound>=0) 00545 { 00546 //Then remove the ./ part of it. 00547 Path.Remove(iFound+1, 2); 00548 00549 //And look for the next /./ to remove 00550 iFound=Path.Sub(sSlashDotSlash); 00551 } 00552 00553 //Now we want to remove all occurrences of /[path segment/../ 00554 //So first let's do a search for /../ 00555 00556 iFound=Path.Sub(sSlashDotDotSlash); 00557 00558 //If we've found a /./ 00559 while (iFound>=0) 00560 { 00561 //Then go back until we find the start of the path segment before it 00562 INT32 iStartOfSection=iFound-1; 00563 00564 while (iStartOfSection>=0 && Path[iStartOfSection]!=cSlash) 00565 iStartOfSection--; 00566 00567 if (iStartOfSection>=0) 00568 { 00569 //Get iStartOfSection to represent the character after the slash, 00570 //rather than the slash 00571 iStartOfSection++; 00572 00573 //So if we've found something, then set a pointer to the end of that 00574 //section 00575 INT32 iEndOfSection=iFound+3; 00576 00577 Path.Remove(iStartOfSection, (iEndOfSection-iStartOfSection+1)); 00578 } 00579 else 00580 //If we found an unparsable /../, then break now before we 00581 //get into trouble... 00582 break; 00583 00584 //And find the next /../ 00585 iFound=Path.Sub(sSlashDotDotSlash); 00586 } 00587 } 00588 else 00589 { 00590 //No, this Web Address doesn't have a path. 00591 //So it inherits the path of the base URL. 00592 Path=Base.Path; 00593 00594 //If this Web Address has some parameters, we need do nothin more to it 00595 if (!Parameters.IsEmpty()) 00596 goto ReturnNow; 00597 00598 //Otherwise this Web Address inherits the parameters of the base URL 00599 Parameters=Base.Parameters; 00600 00601 //If this Web Address has a query, we need do nothin more to it 00602 if (!Query.IsEmpty()) 00603 goto ReturnNow; 00604 00605 //Otherwise this Web Address inherits the parameters of the base URL 00606 Query=Base.Query; 00607 00608 //And that's it. (Fragments are never inherited). 00609 //So we can return. 00610 goto ReturnNow; 00611 00612 }//End if (!Path.IsEmpty()) else... 00613 00614 ReturnNow: 00615 //Set the "Absolute" flag to whatever it's meant to be, and return 00616 SetFlags(); 00617 return; 00618 }
|
|
|
|
Corrects the URL string that the user has entered, according to the correction flags. void WebAddress::Correct(String_256* pstrCorrect, WebCorrectFlags wcfToUse)
Definition at line 855 of file webaddr.cpp. 00856 { 00857 //If we should be correcting backslashes to forward slashes, do so now 00858 if (wcfToUse.CorrectBackslashes()) 00859 CorrectBackslashes(pstrCorrect); 00860 00861 //If we should be correcting local filenames 00862 if (wcfToUse.CorrectLocalFilenames() && ShouldCorrectLocalFilenames(pstrCorrect)) 00863 { 00864 //Then correct it to a URL pointing to a local filename 00865 CorrectLocalFilenames(pstrCorrect); 00866 } 00867 00868 //Now, if we should be correcting Netscape local URLs to IE3 ones 00869 if (wcfToUse.CorrectNetscapeFilenames() && ShouldCorrectNetscapeFilenames(pstrCorrect)) 00870 { 00871 //Then correct it 00872 CorrectNetscapeFilenames(pstrCorrect); 00873 } 00874 //Otherwise if we should be correcting ftp addresses 00875 else if (wcfToUse.CorrectFTP() && ShouldCorrectFTP(pstrCorrect)) 00876 { 00877 //Then add "ftp:" to the front 00878 CorrectFTP(pstrCorrect); 00879 } 00880 //Otherwise if we should be adding http:// to the front 00881 else if (wcfToUse.CorrectHTTP() && ShouldCorrectHTTP(pstrCorrect)) 00882 { 00883 //Then add "http://" to the front 00884 CorrectHTTP(pstrCorrect); 00885 00886 } 00887 //Otherwise if the string contains an @ 00888 else if (ShouldCorrectMailto(pstrCorrect)) 00889 { 00890 //Then add "mailto:" to the front 00891 CorrectMailto(pstrCorrect); 00892 } 00893 00894 //If we should be ensuring that http addresses have a net location 00895 if (wcfToUse.CorrectNoNetLoc() && ShouldCorrectNoNetLoc(pstrCorrect)) 00896 { 00897 //Then add a slash to the end 00898 CorrectNoNetLoc(pstrCorrect); 00899 } 00900 00901 00902 //And finally, if we should be adding a slash to the end 00903 if (wcfToUse.CorrectNoSlash() && ShouldCorrectNoSlash(pstrCorrect)) 00904 { 00905 //Then add a slash to the end 00906 CorrectNoSlash(pstrCorrect); 00907 } 00908 00909 }
|
|
|
|
Corrects any backslashes in the entered string to slashes. void WebAddress::CorrectBackslashes(String_256* pstrCorrect)
Definition at line 930 of file webaddr.cpp. 00931 { 00932 //Check our parameter 00933 if (pstrCorrect==NULL) 00934 { 00935 ERROR2RAW("WebAddress::CorrectBackslashes - NULL parameter"); 00936 return; 00937 } 00938 00939 //And correct all backslashes to forward slashes 00940 pstrCorrect->SwapChar('\\', '/'); 00941 00942 }
|
|
|
|
Puts "ftp:" on the start of pstrCorrect. void WebAddress::CorrectFTP(String_256* pstrCorrect)
Definition at line 1182 of file webaddr.cpp. 01183 { 01184 //Check our parameter 01185 if(pstrCorrect==NULL) 01186 { 01187 ERROR2RAW("WebAddress::CorrectBackslash - NULL parameter"); 01188 return; 01189 } 01190 01191 //If our string is over two hundred and fifty characters long, return 01192 if (pstrCorrect->Length()>250) 01193 return; 01194 01195 //Otherwise, create a new string containing "ftp://" 01196 String_256 strToReturn="ftp://"; 01197 01198 //Add our other string onto the end of it 01199 strToReturn+=*pstrCorrect; 01200 01201 //And copy our new string into our old string 01202 *pstrCorrect=strToReturn; 01203 }
|
|
|
|
Puts "http:" on the start of pstrCorrect. void WebAddress::CorrectHTTP(String_256* pstrCorrect)
Definition at line 1322 of file webaddr.cpp. 01323 { 01324 //Check our parameter 01325 if(pstrCorrect==NULL) 01326 { 01327 ERROR2RAW("WebAddress::CorrectBackslash - NULL parameter"); 01328 return; 01329 } 01330 01331 //If our string is over two hundred and fifty characters long, return 01332 if (pstrCorrect->Length()>250) 01333 return; 01334 01335 //Otherwise, create a new string containing "http:" 01336 String_256 strToReturn="http://"; 01337 01338 //Add our other string onto the end of it 01339 strToReturn+=*pstrCorrect; 01340 01341 //And copy our new string into our old string 01342 *pstrCorrect=strToReturn; 01343 }
|
|
|
|
Assumes pstrCorrect is a local filename, then converts it to a URL referring to a local filename. void WebAddress::CorrectLocalFilenames(String_256* pstrCorrect)
Definition at line 1017 of file webaddr.cpp. 01018 { 01019 //Check our parameter 01020 if(pstrCorrect==NULL) 01021 { 01022 ERROR2RAW("WebAddress::CorrectBackslash - NULL parameter"); 01023 return; 01024 } 01025 01026 01027 //Now, create a pathname out of our string 01028 PathName pthTemp=*pstrCorrect; 01029 01030 //And call the GetWebAddress function 01031 *pstrCorrect=pthTemp.GetWebAddress(); 01032 01033 }
|
|
|
|
Puts "mailto:" on the start of pstrCorrect. void WebAddress::CorrectMailto(String_256* pstrCorrect)
Definition at line 1553 of file webaddr.cpp. 01554 { 01555 //Check our parameter 01556 if(pstrCorrect==NULL) 01557 { 01558 ERROR2RAW("WebAddress::CorrectBackslash - NULL parameter"); 01559 return; 01560 } 01561 01562 //If our string is over two hundred and fifty characters long, return 01563 if (pstrCorrect->Length()>250) 01564 return; 01565 01566 //Otherwise, create a new string containing "mailto:" 01567 String_256 strToReturn="mailto:"; 01568 01569 //Add our other string onto the end of it 01570 strToReturn+=*pstrCorrect; 01571 01572 //And copy our new string into our old string 01573 *pstrCorrect=strToReturn; 01574 }
|
|
|
|
Converts a Netscape local filename (file:///xxxxxxx) to an IE3 local filename (file://xxxxxxx) by simply removing the third slash. void WebAddress::CorrectNetscapeFilenames(String_256* pstrCorrect)
Definition at line 1112 of file webaddr.cpp. 01113 { 01114 //Check our parameter 01115 if(pstrCorrect==NULL) 01116 { 01117 ERROR2RAW("WebAddress::CorrectBackslash - NULL parameter"); 01118 return; 01119 } 01120 01121 //Simply delete the fifth character, removing one of the slashes 01122 pstrCorrect->Remove(6, 1); 01123 01124 }
|
|
|
|
Ensures that pstrCorrect starts with "http://". void WebAddress::CorrectNoNetLoc(String_256* pstrCorrect)
Definition at line 1632 of file webaddr.cpp. 01633 { 01634 //Check our parameter 01635 if(pstrCorrect==NULL) 01636 { 01637 ERROR2RAW("WebAddress::CorrectBackslash - NULL parameter"); 01638 return; 01639 } 01640 01641 //We already know that our string does not start with "http://" 01642 //But does it start with "http:/"? 01643 if (pstrCorrect->SubWithoutCase(String_256("http:/"))==0) 01644 { 01645 //Yes it does. So insert an extra slash 01646 pstrCorrect->Insert( String_256("/"), 5 ); 01647 } 01648 else 01649 { 01650 //No it doesn't. So insert an extra two slashes after the HTTP 01651 pstrCorrect->Insert( String_256("//"), 5 ); 01652 } 01653 }
|
|
|
|
Adds a slash to the end of the string. void WebAddress::CorrectNoSlash(String_256* pstrCorrect)
Definition at line 1466 of file webaddr.cpp. 01467 { 01468 //Check our parameter 01469 if(pstrCorrect==NULL) 01470 { 01471 ERROR2RAW("WebAddress::CorrectNoSlash - NULL parameter"); 01472 return; 01473 } 01474 01475 //And if the string is long enough 01476 if (pstrCorrect->Length()<255) 01477 { 01478 //Add a slash to the end 01479 *pstrCorrect+='/'; 01480 } 01481 }
|
|
Definition at line 174 of file stemplate.h.
|
|
Definition at line 174 of file webaddr.h.
|
|
Definition at line 154 of file stemplate.h. 00154 {return Fragment;}
|
|
Definition at line 154 of file webaddr.h. 00154 {return Fragment;}
|
|
Definition at line 150 of file stemplate.h. 00150 {return NetLoc;}
|
|
Definition at line 150 of file webaddr.h. 00150 {return NetLoc;}
|
|
Definition at line 152 of file stemplate.h. 00152 {return Parameters;}
|
|
Definition at line 152 of file webaddr.h. 00152 {return Parameters;}
|
|
Definition at line 151 of file stemplate.h. 00151 {return Path;}
|
|
Definition at line 151 of file webaddr.h. 00151 {return Path;}
|
|
|
|
Definition at line 793 of file webaddr.cpp. 00794 { 00795 //We needn't actually do anything to remove the Scheme - we just don't 00796 //use it 00797 00798 //First concatenate the net location and the path 00799 String_256 strToReturn=NetLoc; 00800 strToReturn+=Path; 00801 00802 //So, does that string start with "//"? 00803 if (strToReturn.Sub(String_256("//"))==0) 00804 { 00805 //Yes. So remove it 00806 strToReturn.Split(NULL, &strToReturn, 1, TRUE); 00807 } 00808 00809 //Convert all forward slashes to backslashes 00810 strToReturn.SwapChar('/', '\\'); 00811 00812 //Convert all | characters to colons 00813 strToReturn.SwapChar('|', ':'); 00814 00815 //Put our string into a PathName object 00816 PathName pthToReturn(strToReturn); 00817 00818 //And return it 00819 return pthToReturn; 00820 00821 }
|
|
Definition at line 153 of file stemplate.h. 00153 {return Query;}
|
|
Definition at line 153 of file webaddr.h. 00153 {return Query;}
|
|
Definition at line 149 of file stemplate.h. 00149 {return Scheme;}
|
|
Definition at line 149 of file webaddr.h. 00149 {return Scheme;}
|
|
|
|
Returns the URL string.
Definition at line 632 of file webaddr.cpp. 00633 { 00634 String_256 strToReturn=Scheme; 00635 00636 strToReturn+=NetLoc; 00637 strToReturn+=Path; 00638 strToReturn+=Parameters; 00639 strToReturn+=Query; 00640 strToReturn+=Fragment; 00641 00642 return strToReturn; 00643 00644 00645 }
|
|
Definition at line 156 of file stemplate.h. 00156 {return Absolute;}
|
|
Definition at line 156 of file webaddr.h. 00156 {return Absolute;}
|
|
Definition at line 176 of file stemplate.h. 00176 {return ((Scheme.IsEmpty())&& 00177 (NetLoc.IsEmpty())&& 00178 (Path.IsEmpty())&& 00179 (Parameters.IsEmpty())&& 00180 (Query.IsEmpty())&& 00181 (Fragment.IsEmpty()));}
|
|
Definition at line 176 of file webaddr.h. 00176 {return ((Scheme.IsEmpty())&& 00177 (NetLoc.IsEmpty())&& 00178 (Path.IsEmpty())&& 00179 (Parameters.IsEmpty())&& 00180 (Query.IsEmpty())&& 00181 (Fragment.IsEmpty()));}
|
|
|
|
|
|
Finds whether strTest starts with "HTTP:".
Definition at line 709 of file webaddr.cpp. 00710 { 00711 WebAddress urlTest(strTest); 00712 return (urlTest.IsHTTP()); 00713 }
|
|
Finds whether this Web Address starts with "HTTP:".
Definition at line 660 of file webaddr.cpp. 00661 { 00662 return (Scheme.SubWithoutCase(String_256(_R(IDS_URL_HTTPCOLON)))==0); 00663 }
|
|
|
|
Works out if we consider this Web Address to be a local filename. BOOL WebAddress::IsLocalFile()
Definition at line 738 of file webaddr.cpp.
|
|
|
|
Finds whether this Web Address is a valid HTTP address.
Note that a valid http address may be valid but refer to a non-existent network location - for example: is a valid HTTP URL that refers to a server called "nonsensenonsense", which does not exist. Definition at line 691 of file webaddr.cpp. 00692 { 00693 return (IsHTTP() && !NetLocIsEmpty()); 00694 }
|
|
Definition at line 170 of file stemplate.h.
|
|
Definition at line 170 of file webaddr.h.
|
|
|
|
Assignment operator.
Definition at line 171 of file webaddr.cpp. 00172 { 00173 Absolute = InAddress.Absolute; 00174 00175 Scheme=InAddress.Scheme; 00176 NetLoc=InAddress.NetLoc; 00177 Path=InAddress.Path; 00178 Parameters=InAddress.Parameters; 00179 Query=InAddress.Query; 00180 Fragment=InAddress.Fragment; 00181 00182 return *this; 00183 }
|
|
|
|
Equality operator.
Definition at line 235 of file webaddr.cpp. 00236 { 00237 return (Scheme==Other.Scheme && 00238 NetLoc==Other.NetLoc && 00239 Path==Other.Path && 00240 Parameters==Other.Parameters && 00241 Query==Other.Query && 00242 Fragment==Other.Fragment); 00243 }
|
|
Definition at line 172 of file stemplate.h. 00172 {return Parameters.IsEmpty();}
|
|
Definition at line 172 of file webaddr.h. 00172 {return Parameters.IsEmpty();}
|
|
|
|
Takes the string and splits it into its component parts.
These rules can be pretty unforgiving...if you get the query, fragment and parameters in the wrong order, the parsing rules don't accommodate this. But I'm sticking with the rules because of funny things like... a query could, theoretically, have a # in the middle of it. Note that this parsing function should split InString into several different strings and put those strings into member variables, but it should not change the actual text of InString. In other words, if you concatenate the following member variables: Scheme+NetLoc+Path+Parameters+Query+Fragment You should *always* end up with the string InString you passed into the function. Please* don't change the parsing rules unless you really know what you're doing and have read the guideline document referred to above. The parsing that is performed below may look easy, but it is performed by qualified professionals and is extremely dangerous. Do not imitate the parsing that you see below at home. Definition at line 288 of file webaddr.cpp. 00289 { 00290 //First set all the member strings to zero. 00291 Absolute=FALSE; 00292 00293 Scheme.Empty(); 00294 NetLoc.Empty(); 00295 Path.Empty(); 00296 Parameters.Empty(); 00297 Query.Empty(); 00298 Fragment.Empty(); 00299 Scheme.Empty(); 00300 00301 //If InString="", that's all we need to do... 00302 if (InString.IsEmpty()) 00303 return TRUE; 00304 00305 //And set up a couple of strings we can play around with 00306 String_256 StringToParse=InString; 00307 00308 //If the parse string is empty, we need do nothing, because all our fields are 00309 //already blank. Return TRUE. 00310 00311 if (StringToParse.IsEmpty()) return TRUE; 00312 00313 //Now set up some strings. These are all hard coded cos it reduces code size 00314 //This shouldn't matter for purposes of internationalisation, because URLs 00315 //are an international system. 00316 String_256 sNetloc="//"; 00317 00318 // INT32 iLowerCaseA=INT32 ('a'); 00319 // INT32 iLowerCaseZ=INT32 ('z'); 00320 // INT32 iUpperCaseA=INT32 ('A'); 00321 // INT32 iUpperCaseZ=INT32 ('Z'); 00322 00323 // char cBackslash='\\'; 00324 char cSlash='/'; 00325 char cHash='#'; 00326 char cColon=':'; 00327 char cQuestionmark='?'; 00328 char cSemicolon=';'; 00329 00330 //First we want to find the Fragment section of the URL. 00331 //This should start with a # 00332 INT32 iFound=StringToParse.FindNextChar(cHash); 00333 00334 //If we've found a #, copy the whole identifier into the "fragment" member variable 00335 if(iFound>=0) 00336 StringToParse.Split(&StringToParse, &Fragment, iFound, FALSE); 00337 00338 //Now search the parse string for a scheme (the bit at the start, 00339 //e.g. http:). To do this we search for a colon. 00340 iFound=StringToParse.FindNextChar(cColon); 00341 00342 //Have we found a colon? 00343 if(iFound>=0) 00344 { 00345 BOOL IsAScheme=TRUE; 00346 00347 //Yes. We now need to check that everything before that colon is a letter. 00348 for (INT32 iStringPtr=(iFound-1); iStringPtr>=0; iStringPtr--) 00349 { 00350 if (!StringBase::IsAlpha(StringToParse[iStringPtr])) 00351 { 00352 IsAScheme=FALSE; 00353 } 00354 } 00355 00356 00357 //Was everything before the colon a letter? 00358 if (IsAScheme) 00359 //Yes, so split the string after that colon 00360 StringToParse.Split(&Scheme, &StringToParse, iFound, TRUE); 00361 } 00362 00363 //Now look for a network location 00364 iFound=StringToParse.Sub(sNetloc); 00365 00366 //Have we found a //? 00367 if(iFound>=0) 00368 { 00369 //Yes. So find the next / (or the end of the string) 00370 00371 //To do this, set up a string pointer that starts from two 00372 //characters after iFound 00373 INT32 iStringPtr=iFound+2; 00374 00375 //And move that string pointer forwards until 00376 //either it points at a slash or it reaches the end of the 00377 //string 00378 while (iStringPtr<StringToParse.Length() && StringToParse[iStringPtr]!=cSlash) 00379 { 00380 iStringPtr++; 00381 } 00382 00383 StringToParse.Split(&NetLoc, &StringToParse, iStringPtr, FALSE); 00384 } 00385 00386 //Now look for query information. 00387 iFound=StringToParse.FindNextChar(cQuestionmark); 00388 00389 //Have we found a question mark? 00390 if(iFound>=0) 00391 StringToParse.Split(&StringToParse, &Query, iFound,FALSE); 00392 00393 00394 //Now look for parameter information. 00395 iFound=StringToParse.FindNextChar(cSemicolon); 00396 00397 //Have we found a semicolon? 00398 if(iFound>=0) 00399 StringToParse.Split(&StringToParse, &Parameters, iFound, FALSE); 00400 00401 //And whatever is left is the path. 00402 Path=StringToParse; 00403 00404 00405 return TRUE; 00406 }
|
|
Definition at line 171 of file stemplate.h. 00171 {return Path.IsEmpty();}
|
|
Definition at line 171 of file webaddr.h. 00171 {return Path.IsEmpty();}
|
|
Definition at line 173 of file stemplate.h.
|
|
Definition at line 173 of file webaddr.h.
|
|
Definition at line 169 of file stemplate.h.
|
|
Definition at line 169 of file webaddr.h.
|
|
|
|
Sets the Web Address flags - at the moment the only flag is Absolute - by looking at the Web Address string member variables.
Definition at line 419 of file webaddr.cpp.
|
|
Definition at line 189 of file stemplate.h. 00189 {Fragment=NewFragment;}
|
|
Definition at line 189 of file webaddr.h. 00189 {Fragment=NewFragment;}
|
|
Definition at line 185 of file stemplate.h. 00185 {NetLoc=NewNetLoc;}
|
|
Definition at line 185 of file webaddr.h. 00185 {NetLoc=NewNetLoc;}
|
|
Definition at line 187 of file stemplate.h. 00187 {Parameters=NewPara;}
|
|
Definition at line 187 of file webaddr.h. 00187 {Parameters=NewPara;}
|
|
Definition at line 186 of file stemplate.h. 00186 {Path=NewPath;}
|
|
Definition at line 186 of file webaddr.h. 00186 {Path=NewPath;}
|
|
Definition at line 188 of file stemplate.h. 00188 {Query=NewQuery;}
|
|
Definition at line 188 of file webaddr.h. 00188 {Query=NewQuery;}
|
|
Definition at line 184 of file stemplate.h.
|
|
Definition at line 184 of file webaddr.h.
|
|
|
|
Works out if we consider this string to be a ftp address with the "ftp:" missing. BOOL WebAddress::ShouldCorrectFTP(String_256* pstrCorrect)
Definition at line 1149 of file webaddr.cpp. 01150 { 01151 //Check our parameter 01152 ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectBackslash - NULL parameter"); 01153 01154 //Are the first four characters "ftp." ? 01155 if (pstrCorrect->SubWithoutCase(String_256("ftp."))==0) 01156 return TRUE; 01157 01158 //Otherwise return FALSE 01159 return FALSE; 01160 01161 }
|
|
|
|
Works out if we consider this string to be a http address with the "http:" missing. BOOL WebAddress::ShouldCorrectHTTP(String_256* pstrCorrect)
;?:&=%$-_.+!*'(),abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ...which contains at least two full stops. (This string of characters is taken from http://ds.internic.net/rfc/rfc1808.txt, page 4, but altered slightly). The first character should not be a full stop and there should not be two full stops together. For example: abc-def12.gh4i3.jkl.mno
Definition at line 1243 of file webaddr.cpp. 01244 { 01245 //Check our parameter 01246 ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectBackslash - NULL parameter"); 01247 01248 //Get the length of the string 01249 INT32 iLength=pstrCorrect->Length(); 01250 01251 //If the string is empty, return FALSE 01252 if (iLength<=0) 01253 return FALSE; 01254 01255 //Now, here is the set of characters to test for 01256 TCHAR *strAllowed = _T(";?&=%abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$-_.+!*'(),"); 01257 01258 //If the first character is a full stop, return FALSE 01259 if ((*pstrCorrect)[0]=='.') 01260 return FALSE; 01261 01262 //And this variable will keep a count of the number of full stops 01263 INT32 iFullStops=0; 01264 01265 //This variable will tell us if the last character we looked at 01266 //was a full stop 01267 BOOL fLastCharWasFullStop=FALSE; 01268 01269 //Now, starting at the first character in the string, scan through 01270 //each character in turn until we get to something that is not 01271 //in our set of allowed characters 01272 for (INT32 i=0; i<iLength && (camStrchr(strAllowed, (*pstrCorrect)[i]))!=NULL; i++) 01273 { 01274 //If the letter we are looking at is a full stop, 01275 if ((*pstrCorrect)[i]=='.') 01276 { 01277 //Then, was the last character we looked at a full stop? 01278 if (fLastCharWasFullStop) 01279 { 01280 //Yes. So we've found two full stops together. Return FALSE 01281 return FALSE; 01282 } 01283 else 01284 { 01285 //No. So add one to our count of full stops and remember 01286 //that this character was a full stop 01287 iFullStops++; 01288 fLastCharWasFullStop=TRUE; 01289 } 01290 } 01291 else 01292 { 01293 //No, this character is not a full stop 01294 fLastCharWasFullStop=FALSE; 01295 } 01296 } 01297 01298 //And return true if we found more than one full stop 01299 return (iFullStops>=2); 01300 01301 }
|
|
|
|
Works out if we consider this string to be a local filename. BOOL WebAddress::ShouldCorrectLocalFilenames(String_256* pstrCorrect)
Definition at line 968 of file webaddr.cpp. 00969 { 00970 //Check our parameter 00971 ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectBackslash - NULL parameter"); 00972 00973 //If the length of the string is less than two characters, return FALSE 00974 if (pstrCorrect->Length()<2) 00975 return FALSE; 00976 00977 //Now, if the first character is a letter and the second character is a 00978 //colon, return TRUE 00979 if (StringBase::IsAlpha((*pstrCorrect)[0]) && (*pstrCorrect)[1]==':') 00980 { 00981 return TRUE; 00982 } 00983 00984 //Otherwise, if the first two characters are forward slashes, return TRUE 00985 if ((*pstrCorrect)[0]=='/' && (*pstrCorrect)[1]=='/') 00986 { 00987 return TRUE; 00988 } 00989 00990 //Otherwise return FALSE 00991 return FALSE; 00992 00993 }
|
|
|
|
Works out if we consider this string to be a mail address with the "mailto:" missing. BOOL WebAddress::ShouldCorrectMailto(String_256* pstrCorrect)
Definition at line 1511 of file webaddr.cpp. 01512 { 01513 //Check our parameter 01514 ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectBackslash - NULL parameter"); 01515 01516 //Find the first @ symbol 01517 INT32 iLocationOfAtSymbol=pstrCorrect->FindNextChar('@'); 01518 01519 //If we found one 01520 if (iLocationOfAtSymbol>0) 01521 { 01522 //Then check for a colon 01523 INT32 iLocationOfColon=pstrCorrect->FindNextChar(':'); 01524 01525 //If we didn't find one, return TRUE 01526 if (iLocationOfColon<0) 01527 return TRUE; 01528 } 01529 01530 return FALSE; 01531 01532 }
|
|
|
|
Works out if we consider this string to be a Netscape local filename. BOOL WebAddress::ShouldCorrectNetscapeFilenames(String_256* pstrCorrect)
The problem here is that Netscape refers to local filenames as follows: file:///d|/dir1/myname.htm But IE3 refers to local filenames as: file://d|/dir1/myname.htm Note the difference in the number of slashes. We correct it to the IE3 version.
Definition at line 1069 of file webaddr.cpp. 01070 { 01071 //Check our parameter 01072 ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectNetscapeFilenames - NULL parameter"); 01073 01074 //Set up some strings to search for 01075 String_256 strThreeSlashes("file:///"); 01076 String_256 strFourSlashes("file:////"); 01077 01078 //Now, if the string begins with "file:///"... 01079 if (pstrCorrect->SubWithoutCase(strThreeSlashes)==0) 01080 { 01081 //But the string doesn't begin with "file:////" 01082 if (pstrCorrect->SubWithoutCase(strFourSlashes)!=0) 01083 //Then we shoul correct it 01084 return TRUE; 01085 } 01086 01087 //Otherwise return FALSE 01088 return FALSE; 01089 01090 }
|
|
|
|
Works out if we consider this string to be an HTTP address with the "//" to signify a network location missing. For example:. BOOL WebAddress::ShouldCorrectNoNetLoc(String_256* pstrCorrect)
Definition at line 1600 of file webaddr.cpp. 01601 { 01602 //Check our parameter 01603 ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectBackslash - NULL parameter"); 01604 01605 //Return TRUE if the string starts with "http:" but doesn't start with "http://" 01606 String_256 strHTTP("http:"); 01607 String_256 strHTTPSlashSlash("http://"); 01608 01609 return (pstrCorrect->SubWithoutCase(strHTTP)==0 && pstrCorrect->SubWithoutCase(strHTTPSlashSlash)!=0); 01610 01611 }
|
|
|
|
Works out if we consider this string to be a URL with a trailing slash missing. BOOL WebAddress::ShouldCorrectNoSlash(String_256* pstrCorrect)
Then we consider that the URL should have a slash added if a. The string consists of a net location but no path (e.g. "http://www.xara.com", which should become "http://www.xara.com/") b. The path portion of the URL does not end in a slash, and the final segment of the path does not have a full stop character in it. That is, "http://www.bbc.co.uk/radio1" should have a slash added on the end, but "http://www.bbc.co.uk/index.htm" should not.
Definition at line 1385 of file webaddr.cpp. 01386 { 01387 //Check our parameter 01388 ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectNoSlash - NULL parameter"); 01389 01390 //First create a Web Address from our string 01391 WebAddress urlTest(*pstrCorrect); 01392 01393 //Now, does the Web Address start with HTTP:, and does it have a net location 01394 //specified? 01395 if (urlTest.IsHTTP() && !urlTest.NetLocIsEmpty()) 01396 { 01397 //Yes. 01398 01399 //So, does the Web Address have an empty path? 01400 if (urlTest.PathIsEmpty()) 01401 { 01402 //Yes. So we should add a slash to it. 01403 return TRUE; 01404 } 01405 else 01406 { 01407 //No, there is something in the path. 01408 01409 //So, does the path end in something other than a slash? 01410 INT32 iLength=urlTest.Path.Length(); 01411 01412 if (urlTest.Path[iLength-1]!='/') 01413 { 01414 //Yes. So we should add a slash only if 01415 //the last segment of the path does not contain a full stop. 01416 01417 //First try and find a slash in the path string, starting 01418 //from the end 01419 INT32 iSlashFound=urlTest.Path.ReverseFind('/'); 01420 01421 //Now try and find a full stop in the path string, starting 01422 //from the end 01423 INT32 iFullStopFound=urlTest.Path.ReverseFind('.'); 01424 01425 //Now... 01426 01427 //If we didn't find a full stop, we should add a slash 01428 if (iFullStopFound==-1) 01429 return TRUE; 01430 01431 //Otherwise, we should only add a slash if the slash 01432 //was found after the full stop 01433 if (iSlashFound>iFullStopFound) 01434 return TRUE; 01435 01436 //Otherwise, we don't add a slash 01437 } 01438 } 01439 } 01440 01441 //So, none of our conditions were met. 01442 //So we don't add a slash 01443 return FALSE; 01444 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|