WebAddress Class Reference

Represents a URL. More...

#include <webaddr.h>

Inheritance diagram for WebAddress:

CCObject CCObject SimpleCCObject SimpleCCObject List of all members.

Public Member Functions

WebAddressoperator= (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_256GetScheme () const
const String_256GetNetLoc () const
const String_256GetPath () const
const String_256GetParameters () const
const String_256GetQuery () const
const String_256GetFragment () 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)
WebAddressoperator= (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_256GetScheme () const
const String_256GetNetLoc () const
const String_256GetPath () const
const String_256GetParameters () const
const String_256GetQuery () const
const String_256GetFragment () 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)

Detailed Description

Represents a URL.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/96

Definition at line 115 of file webaddr.h.


Constructor & Destructor Documentation

WebAddress::WebAddress  ) 
 

Default WebAddress class constructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

Definition at line 126 of file webaddr.cpp.

00127 {
00128     Absolute = FALSE;
00129 }

WebAddress::WebAddress const WebAddress InAddress  ) 
 

Copy Constructor for the WebAddress class.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96
Parameters:
InAddress [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

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 }

WebAddress::WebAddress const String_256 StringToParse,
WebCorrectFlags  wcfToUse = WebCorrectFlags()
 

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 }

WebAddress::WebAddress  ) 
 

WebAddress::WebAddress const WebAddress InAddress  ) 
 

WebAddress::WebAddress const String_256 StringToParse,
WebCorrectFlags  wcfToUse = WebCorrectFlags()
 


Member Function Documentation

WebAddress::CC_DECLARE_DYNAMIC WebAddress   )  [private]
 

WebAddress::CC_DECLARE_DYNAMIC WebAddress   )  [private]
 

void WebAddress::Combine WebAddress  Relative  ) 
 

void WebAddress::Combine WebAddress  Base  ) 
 

Combines this Web Address with a base Web Address.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96
Parameters:
A Base URL [INPUTS]
This is used when this Web Address is relative and the base web address is the address of the current document. This function allows this Web Address to inherit the appropriate components of the base address so this Address becomes relative.

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 }

void WebAddress::Correct String_256 pstrCorrect,
WebCorrectFlags  wcfToUse = WebCorrectFlags()
[protected]
 

void WebAddress::Correct String_256 pstrCorrect,
WebCorrectFlags  wcfToUse = WebCorrectFlags()
[protected]
 

Corrects the URL string that the user has entered, according to the correction flags.

void WebAddress::Correct(String_256* pstrCorrect, WebCorrectFlags wcfToUse)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS] wcfToUse - a set of flags which detail how to correct the string
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::ApplyWebAddressToSelection; WebCorrectFlags

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 }

void WebAddress::CorrectBackslashes String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectBackslashes String_256 pstrCorrect  )  [protected]
 

Corrects any backslashes in the entered string to slashes.

void WebAddress::CorrectBackslashes(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::Correct()

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 }

void WebAddress::CorrectFTP String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectFTP String_256 pstrCorrect  )  [protected]
 

Puts "ftp:" on the start of pstrCorrect.

void WebAddress::CorrectFTP(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::Correct()

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 }

void WebAddress::CorrectHTTP String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectHTTP String_256 pstrCorrect  )  [protected]
 

Puts "http:" on the start of pstrCorrect.

void WebAddress::CorrectHTTP(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::Correct()

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 }

void WebAddress::CorrectLocalFilenames String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectLocalFilenames String_256 pstrCorrect  )  [protected]
 

Assumes pstrCorrect is a local filename, then converts it to a URL referring to a local filename.

void WebAddress::CorrectLocalFilenames(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-
It does this by calling the function PathName::GetWebAddress()

Returns:
Errors: -
See also:
WebAddress::Correct(), PathName::GetWebAddress()

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 }

void WebAddress::CorrectMailto String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectMailto String_256 pstrCorrect  )  [protected]
 

Puts "mailto:" on the start of pstrCorrect.

void WebAddress::CorrectMailto(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::Correct()

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 }

void WebAddress::CorrectNetscapeFilenames String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectNetscapeFilenames String_256 pstrCorrect  )  [protected]
 

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)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::Correct(), PathName::GetWebAddress()

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 }

void WebAddress::CorrectNoNetLoc String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectNoNetLoc String_256 pstrCorrect  )  [protected]
 

Ensures that pstrCorrect starts with "http://".

void WebAddress::CorrectNoNetLoc(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::Correct()

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 }

void WebAddress::CorrectNoSlash String_256 pstrCorrect  )  [protected]
 

void WebAddress::CorrectNoSlash String_256 pstrCorrect  )  [protected]
 

Adds a slash to the end of the string.

void WebAddress::CorrectNoSlash(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to correct [INPUTS]
pstrCorrect - the corrected string [OUTPUTS]
Returns:
-

Errors: -

See also:
WebAddress::Correct(); WebAddress::ShouldCorrectNoSlash()

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 }

const BOOL WebAddress::FragmentIsEmpty  )  const [inline]
 

Definition at line 174 of file stemplate.h.

00174 {return Fragment.IsEmpty();}

const BOOL WebAddress::FragmentIsEmpty  )  const [inline]
 

Definition at line 174 of file webaddr.h.

00174 {return Fragment.IsEmpty();}

const String_256& WebAddress::GetFragment  )  const [inline]
 

Definition at line 154 of file stemplate.h.

00154 {return Fragment;}

const String_256& WebAddress::GetFragment  )  const [inline]
 

Definition at line 154 of file webaddr.h.

00154 {return Fragment;}

const String_256& WebAddress::GetNetLoc  )  const [inline]
 

Definition at line 150 of file stemplate.h.

00150 {return NetLoc;}

const String_256& WebAddress::GetNetLoc  )  const [inline]
 

Definition at line 150 of file webaddr.h.

00150 {return NetLoc;}

const String_256& WebAddress::GetParameters  )  const [inline]
 

Definition at line 152 of file stemplate.h.

00152 {return Parameters;}

const String_256& WebAddress::GetParameters  )  const [inline]
 

Definition at line 152 of file webaddr.h.

00152 {return Parameters;}

const String_256& WebAddress::GetPath  )  const [inline]
 

Definition at line 151 of file stemplate.h.

00151 {return Path;}

const String_256& WebAddress::GetPath  )  const [inline]
 

Definition at line 151 of file webaddr.h.

00151 {return Path;}

PathName WebAddress::GetPathName  )  const
 

PathName WebAddress::GetPathName  )  const
 

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 }

const String_256& WebAddress::GetQuery  )  const [inline]
 

Definition at line 153 of file stemplate.h.

00153 {return Query;}

const String_256& WebAddress::GetQuery  )  const [inline]
 

Definition at line 153 of file webaddr.h.

00153 {return Query;}

const String_256& WebAddress::GetScheme  )  const [inline]
 

Definition at line 149 of file stemplate.h.

00149 {return Scheme;}

const String_256& WebAddress::GetScheme  )  const [inline]
 

Definition at line 149 of file webaddr.h.

00149 {return Scheme;}

String_256 WebAddress::GetWebAddress  ) 
 

String_256 WebAddress::GetWebAddress  ) 
 

Returns the URL string.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96
Parameters:
- [INPUTS]
Returns:
The full 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 }

const BOOL WebAddress::IsAbsolute  )  [inline]
 

Definition at line 156 of file stemplate.h.

00156 {return Absolute;}

const BOOL WebAddress::IsAbsolute  )  [inline]
 

Definition at line 156 of file webaddr.h.

00156 {return Absolute;}

const BOOL WebAddress::IsEmpty void   )  const [inline]
 

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()));}

const BOOL WebAddress::IsEmpty  )  const [inline]
 

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()));}

static BOOL WebAddress::IsHTTP const String_256 strTest  )  [static]
 

BOOL WebAddress::IsHTTP  )  const
 

BOOL WebAddress::IsHTTP const String_256 strTest  )  [static]
 

Finds whether strTest starts with "HTTP:".

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96
Parameters:
- [INPUTS]
Returns:
TRUE if strTest starts with HTTP

Definition at line 709 of file webaddr.cpp.

00710 {
00711     WebAddress urlTest(strTest);
00712     return (urlTest.IsHTTP());  
00713 }

BOOL WebAddress::IsHTTP  )  const
 

Finds whether this Web Address starts with "HTTP:".

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96
Parameters:
- [INPUTS]
Returns:
TRUE if 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 }

BOOL WebAddress::IsLocalFile  )  const
 

BOOL WebAddress::IsLocalFile  )  const
 

Works out if we consider this Web Address to be a local filename.

BOOL WebAddress::IsLocalFile()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/6/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we consider pstrCorrect to be a local filename FALSE otherwise
It's a local filename if its scheme is "file:"

Returns:
Errors: -
See also:
WebAddress::GetPathName()

Definition at line 738 of file webaddr.cpp.

00739 {   
00740     return( Scheme == wxT("file:") );
00741 }

BOOL WebAddress::IsValidHTTP  )  const
 

BOOL WebAddress::IsValidHTTP  )  const
 

Finds whether this Web Address is a valid HTTP address.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/97
Parameters:
- [INPUTS]
Returns:
TRUE if this Web Address starts with HTTP and has a net location
We say it's a valid HTTP address if: a. It starts with HTTP b. It has a net location

Note that a valid http address may be valid but refer to a non-existent network location - for example:

http://nonsensenonsense

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 }

const BOOL WebAddress::NetLocIsEmpty  )  const [inline]
 

Definition at line 170 of file stemplate.h.

00170 {return NetLoc.IsEmpty();}

const BOOL WebAddress::NetLocIsEmpty  )  const [inline]
 

Definition at line 170 of file webaddr.h.

00170 {return NetLoc.IsEmpty();}

WebAddress& WebAddress::operator= const WebAddress  ) 
 

WebAddress & WebAddress::operator= const WebAddress InAddress  ) 
 

Assignment operator.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96
Parameters:
InAddress [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

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 }

INT32 WebAddress::operator== WebAddress Other  ) 
 

INT32 WebAddress::operator== WebAddress Other  ) 
 

Equality operator.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/6/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
WebCorrectFlags

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 }

const BOOL WebAddress::ParametersIsEmpty  )  const [inline]
 

Definition at line 172 of file stemplate.h.

00172 {return Parameters.IsEmpty();}

const BOOL WebAddress::ParametersIsEmpty  )  const [inline]
 

Definition at line 172 of file webaddr.h.

00172 {return Parameters.IsEmpty();}

BOOL WebAddress::Parse const String_256 InString  )  [protected]
 

BOOL WebAddress::Parse const String_256 InString  )  [protected]
 

Takes the string and splits it into its component parts.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/9/96
Parameters:
String representing the full URL [INPUTS]
None [OUTPUTS]
Returns:
None
Notes: The parsing rules follow the guidelines given in http://ds.internic.net/rfc/rfc1808.txt. So there! (That means, don't change them unless you know what you're doing).

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 }

const BOOL WebAddress::PathIsEmpty  )  const [inline]
 

Definition at line 171 of file stemplate.h.

00171 {return Path.IsEmpty();}

const BOOL WebAddress::PathIsEmpty  )  const [inline]
 

Definition at line 171 of file webaddr.h.

00171 {return Path.IsEmpty();}

const BOOL WebAddress::QueryIsEmpty  )  const [inline]
 

Definition at line 173 of file stemplate.h.

00173 {return Query.IsEmpty();}

const BOOL WebAddress::QueryIsEmpty  )  const [inline]
 

Definition at line 173 of file webaddr.h.

00173 {return Query.IsEmpty();}

const BOOL WebAddress::SchemeIsEmpty  )  const [inline]
 

Definition at line 169 of file stemplate.h.

00169 {return Scheme.IsEmpty();}

const BOOL WebAddress::SchemeIsEmpty  )  const [inline]
 

Definition at line 169 of file webaddr.h.

00169 {return Scheme.IsEmpty();}

BOOL WebAddress::SetFlags  )  [protected]
 

BOOL WebAddress::SetFlags  )  [protected]
 

Sets the Web Address flags - at the moment the only flag is Absolute - by looking at the Web Address string member variables.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/9/96

Definition at line 419 of file webaddr.cpp.

00420 {
00421     Absolute=!Scheme.IsEmpty();
00422 
00423     return TRUE;
00424 }

void WebAddress::SetFragment String_256 NewFragment  )  [inline]
 

Definition at line 189 of file stemplate.h.

00189 {Fragment=NewFragment;}

void WebAddress::SetFragment String_256 NewFragment  )  [inline]
 

Definition at line 189 of file webaddr.h.

00189 {Fragment=NewFragment;}

void WebAddress::SetNetLoc String_256 NewNetLoc  )  [inline]
 

Definition at line 185 of file stemplate.h.

00185 {NetLoc=NewNetLoc;}

void WebAddress::SetNetLoc String_256 NewNetLoc  )  [inline]
 

Definition at line 185 of file webaddr.h.

00185 {NetLoc=NewNetLoc;}

void WebAddress::SetParameters String_256 NewPara  )  [inline]
 

Definition at line 187 of file stemplate.h.

00187 {Parameters=NewPara;}

void WebAddress::SetParameters String_256 NewPara  )  [inline]
 

Definition at line 187 of file webaddr.h.

00187 {Parameters=NewPara;}

void WebAddress::SetPath String_256 NewPath  )  [inline]
 

Definition at line 186 of file stemplate.h.

00186 {Path=NewPath;}

void WebAddress::SetPath String_256 NewPath  )  [inline]
 

Definition at line 186 of file webaddr.h.

00186 {Path=NewPath;}

void WebAddress::SetQuery String_256 NewQuery  )  [inline]
 

Definition at line 188 of file stemplate.h.

00188 {Query=NewQuery;}

void WebAddress::SetQuery String_256 NewQuery  )  [inline]
 

Definition at line 188 of file webaddr.h.

00188 {Query=NewQuery;}

void WebAddress::SetScheme String_256 NewScheme  )  [inline]
 

Definition at line 184 of file stemplate.h.

00184 {Scheme=NewScheme; SetFlags();}

void WebAddress::SetScheme String_256 NewScheme  )  [inline]
 

Definition at line 184 of file webaddr.h.

00184 {Scheme=NewScheme; SetFlags();}

BOOL WebAddress::ShouldCorrectFTP String_256 pstrCorrect  )  [protected]
 

BOOL WebAddress::ShouldCorrectFTP String_256 pstrCorrect  )  [protected]
 

Works out if we consider this string to be a ftp address with the "ftp:" missing.

BOOL WebAddress::ShouldCorrectFTP(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to test [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we consider pstrCorrect to be an ftp address FALSE otherwise
We do so if the string starts "ftp.".

Returns:
Errors: -
See also:
WebAddress::Correct()

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 }

BOOL WebAddress::ShouldCorrectHTTP String_256 pstrCorrect  )  [protected]
 

BOOL WebAddress::ShouldCorrectHTTP String_256 pstrCorrect  )  [protected]
 

Works out if we consider this string to be a http address with the "http:" missing.

BOOL WebAddress::ShouldCorrectHTTP(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to test [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we consider pstrCorrect to be an http address FALSE otherwise
We do so if the string starts with a string of the following characters:

;?:&=%$-_.+!*'(),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

Returns:
Errors: -
See also:
WebAddress::Correct()

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 }

BOOL WebAddress::ShouldCorrectLocalFilenames String_256 pstrCorrect  )  [protected]
 

BOOL WebAddress::ShouldCorrectLocalFilenames String_256 pstrCorrect  )  [protected]
 

Works out if we consider this string to be a local filename.

BOOL WebAddress::ShouldCorrectLocalFilenames(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to test [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we consider pstrCorrect to be a local filename FALSE otherwise
We consider this to be a local filename if a. It begins with a letter followed by a colon b. It begins with \, in which case it is a UNC pathname

Returns:
Errors: -
See also:
WebAddress::Correct()

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 }

BOOL WebAddress::ShouldCorrectMailto String_256 pstrCorrect  )  [protected]
 

BOOL WebAddress::ShouldCorrectMailto String_256 pstrCorrect  )  [protected]
 

Works out if we consider this string to be a mail address with the "mailto:" missing.

BOOL WebAddress::ShouldCorrectMailto(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to test [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we consider pstrCorrect to be a mail address FALSE otherwise
We do so if it contains an @ character and does not contain a colon

Returns:
Errors: -
See also:
WebAddress::Correct()

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 }

BOOL WebAddress::ShouldCorrectNetscapeFilenames String_256 pstrCorrect  )  [protected]
 

BOOL WebAddress::ShouldCorrectNetscapeFilenames String_256 pstrCorrect  )  [protected]
 

Works out if we consider this string to be a Netscape local filename.

BOOL WebAddress::ShouldCorrectNetscapeFilenames(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/6/97
Parameters:
pstrCorrect - the string to test [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we consider pstrCorrect to be a Netscape local filename. FALSE otherwise
We consider this to be a Netscape local filename if it begins with "file:///", but does not begin with "file:////".

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.

Returns:
Errors: -
See also:
WebAddress::Correct()

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 }

BOOL WebAddress::ShouldCorrectNoNetLoc String_256 pstrCorrect  )  [protected]
 

BOOL WebAddress::ShouldCorrectNoNetLoc String_256 pstrCorrect  )  [protected]
 

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)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/97
Parameters:
pstrCorrect - the string to test [INPUTS]
- [OUTPUTS]
Returns:
TRUE if pstrCorrect starts with "http" but does not have "//" afterwards to signify a net location FALSE otherwise
http:www.xara.com

Returns:
Errors: -
See also:
WebAddress::Correct()

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 }

BOOL WebAddress::ShouldCorrectNoSlash String_256 pstrCorrect  )  [protected]
 

BOOL WebAddress::ShouldCorrectNoSlash String_256 pstrCorrect  )  [protected]
 

Works out if we consider this string to be a URL with a trailing slash missing.

BOOL WebAddress::ShouldCorrectNoSlash(String_256* pstrCorrect)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/97
Parameters:
pstrCorrect - the string to test [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we consider that pstrCorrect is a URL to which the user has forgotten to add a trailing slash FALSE otherwise
We do this by creating a Web Address object to parse the string. (Note that if this function is called, then the URL will already have had an "http://" added to the front if necessary).

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.

Returns:
Errors: -
See also:
WebAddress::Correct()

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 }


Member Data Documentation

BOOL WebAddress::Absolute [protected]
 

Definition at line 120 of file webaddr.h.

String_256 WebAddress::Fragment [protected]
 

Definition at line 127 of file webaddr.h.

String_256 WebAddress::NetLoc [protected]
 

Definition at line 123 of file webaddr.h.

String_256 WebAddress::Parameters [protected]
 

Definition at line 125 of file webaddr.h.

String_256 WebAddress::Path [protected]
 

Definition at line 124 of file webaddr.h.

String_256 WebAddress::Query [protected]
 

Definition at line 126 of file webaddr.h.

String_256 WebAddress::Scheme [protected]
 

Definition at line 122 of file webaddr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:03:06 2007 for Camelot by  doxygen 1.4.4