SNAP Library, Developer Reference  2012-10-02 12:56:23
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
url.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef TPair< TInt, PUrl > TIdUrlPr
typedef TQQueue< TIdUrlPrTIdUrlPrQ
typedef THash< TInt, PUrl > TIdToUrlH

Enumerations

enum  TUrlScheme { usUndef, usHttp, usOther }

Functions

void GetAbs (const TStr &AbsUrlStr)
void GetAbsFromBase (const TStr &RelUrlStr, const TStr &BaseUrlStr)
 UndefDefaultCopyAssign (TUrl)
 TUrl (const TStr &_RelUrlStr, const TStr &_BaseUrlStr=TStr())
static PUrl New (const TStr &RelUrlStr, const TStr &BaseUrlStr=TStr())
 ~TUrl ()
 TUrl (TSIn &)
static PUrl Load (TSIn &)
void Save (TSOut &)
bool IsOk (const TUrlScheme _Scheme=usUndef) const
TUrlScheme GetScheme ()
TStr GetUrlStr () const
TStr GetRelUrlStr () const
bool IsBaseUrl ()
TStr GetBaseUrlStr () const
TStr GetSchemeNm () const
TStr GetHostNm () const
TStr GetDmNm (const int &MxDmSegs=-1) const
bool IsPortOk () const
TStr GetPortStr () const
int GetPortN () const
TStr GetPathStr () const
int GetPathSegs () const
TStr GetPathSeg (const int &PathSegN) const
TStr GetSearchStr () const
TStr GetFragIdStr () const
bool IsIpNum () const
void PutIpNum (const TStr &_IpNum)
TStr GetIpNum () const
TStr GetIpNumOrHostNm () const
bool IsDefFinalUrl () const
TStr GetFinalUrlStr () const
TStr GetAsFinalUrlStr () const
TStr GetFinalHostNm () const
TStr GetAsFinalHostNm () const
void DefUrlAsFinal ()
void DefFinalUrl (const TStr &_FinalHostNm)
void PutHttpRqStr (const TStr &_HttpRqStr)
TStr GetHttpRqStr () const
bool IsHttpRqStr () const
void ChangeHttpRqStr (const TStr &SrcStr, const TStr &DstStr)
bool IsInHost (const TStr &_HostNm) const
bool IsInPath (const TStr &_PathStr) const
void ToLcPath ()
static bool IsAbs (const TStr &UrlStr)
static bool IsScript (const TStr &UrlStr)
static bool IsSite (const TStr &UrlStr)
static PUrl GetUrlFromShortcut (const TStr &ShortcutUrlStr, const TStr &DfHostNmPrefix, const TStr &DfHostNmSufix)
static TStr GetUrlSearchStr (const TStr &Str)
static TStr DecodeUrlStr (const TStr &UrlStr)
static TStr GetDocStrFromUrlStr (const TStr &UrlStr, const int &Copies=1)
static TStr GetTopDownDocNm (const TStr &UrlStr, const int &MxLen=-1, const bool &HostOnlyP=false)
 TUrlEnv ()
 TUrlEnv (const TUrlEnv &UrlEnv)
static PUrlEnv New ()
static PUrlEnv New (const TStr &BaseUrlStr, const TStr &KeyNm1=TStr(), const TStr &ValStr1=TStr(), const TStr &KeyNm2=TStr(), const TStr &ValStr2=TStr(), const TStr &KeyNm3=TStr(), const TStr &ValStr3=TStr(), const TStr &KeyNm4=TStr(), const TStr &ValStr4=TStr())
 ~TUrlEnv ()
 TUrlEnv (TSIn &SIn)
TUrlEnvoperator= (const TUrlEnv &Env)
void PutBaseUrlStr (const TStr &_BaseUrlStr)
void AddKeyVal (const TStr &KeyNm, const TStr &ValStr)
void AddToKeyVal (const TStr &KeyNm, const TStr &ValStr)
bool Empty () const
int GetKeys () const
bool IsKey (const TStr &KeyNm) const
int GetKeyN (const TStr &KeyNm) const
TStr GetKeyNm (const int &KeyN) const
int GetVals (const int &KeyN) const
int GetVals (const TStr &KeyNm) const
TStr GetVal (const int &KeyN, const int &ValN=0) const
TStr GetVal (const TStr &KeyNm, const int &ValN=0, const TStr &DfVal="") const
TStr GetFullUrlStr () const
static PUrlEnv MkClone (const PUrlEnv &UrlEnv)

Variables

static ClassTPV(TUrl, PUrl,
TUrlV) private const TStr 
UrlHttpAbsPrefixStr = "http://"
TUrlScheme Scheme
TStr UrlStr
TStr RelUrlStr
TStr BaseUrlStr
TStr SchemeNm
TStr HostNm
TStr PortStr
TStr PathStr
TStr SearchStr
TStr FragIdStr
int PortN
TStrV PathSegV
TStr IpNum
TStr FinalUrlStr
TStr FinalHostNm
TStr HttpRqStr
ClassTP(TUrlEnv, PUrlEnv)
private TStrV 
KeyNmV
TStrStrVH KeyNmToValH

Typedef Documentation

typedef THash<TInt, PUrl> TIdToUrlH

Definition at line 96 of file url.h.

typedef TPair<TInt, PUrl> TIdUrlPr

Definition at line 93 of file url.h.

Definition at line 95 of file url.h.


Enumeration Type Documentation

enum TUrlScheme
Enumerator:
usUndef 
usHttp 
usOther 

Definition at line 3 of file url.h.


Function Documentation

void AddKeyVal ( const TStr KeyNm,
const TStr ValStr 
)

Definition at line 137 of file url.h.

References TVec< TVal >::Add(), THash< TKey, TDat, THashFunc >::AddKey(), THash< TKey, TDat, THashFunc >::GetDat(), IsKey(), KeyNmToValH, and KeyNmV.

                                                       {
    if (!IsKey(KeyNm)){KeyNmV.Add(KeyNm); KeyNmToValH.AddKey(KeyNm);}
    KeyNmToValH.GetDat(KeyNm).Clr();
    KeyNmToValH.GetDat(KeyNm).Add(ValStr);}

Here is the call graph for this function:

void AddToKeyVal ( const TStr KeyNm,
const TStr ValStr 
)

Definition at line 141 of file url.h.

References TVec< TVal >::Add(), THash< TKey, TDat, THashFunc >::AddKey(), THash< TKey, TDat, THashFunc >::GetDat(), IsKey(), KeyNmToValH, and KeyNmV.

                                                         {
    if (!IsKey(KeyNm)){KeyNmV.Add(KeyNm); KeyNmToValH.AddKey(KeyNm);}
    KeyNmToValH.GetDat(KeyNm).Add(ValStr);}

Here is the call graph for this function:

void ChangeHttpRqStr ( const TStr SrcStr,
const TStr DstStr 
)

Definition at line 73 of file url.h.

References TStr::ChangeStr(), and HttpRqStr.

                                                              {
    HttpRqStr.ChangeStr(SrcStr, DstStr);}

Here is the call graph for this function:

TStr TUrl::DecodeUrlStr ( const TStr UrlStr) [static]

Definition at line 386 of file url.cpp.

References TCh::GetHex(), TCh::IsHex(), TChA::Len(), and UrlStr.

                                          {
  TChA InChA=UrlStr; TChA OutChA;
  for (int ChN=0; ChN<InChA.Len(); ChN++){
    char Ch=InChA[ChN];
    if (Ch=='+'){
      OutChA+=' ';
    } else if (Ch=='%') {
      ChN++; if (ChN==InChA.Len()) { break; }
      char FirstCh = InChA[ChN];
      if (!TCh::IsHex(FirstCh)) { break; }
      ChN++; if (ChN==InChA.Len()) { break; }
      char SecondCh = InChA[ChN];
      if (!TCh::IsHex(SecondCh)) { break; }
      OutChA+=char(TCh::GetHex(FirstCh)*16 + TCh::GetHex(SecondCh));
    } else {
      OutChA+=Ch;
    }
  }
  return OutChA;
}

Here is the call graph for this function:

void TUrl::DefFinalUrl ( const TStr _FinalHostNm)

Definition at line 284 of file url.cpp.

References EAssert, TStr::Empty(), FinalHostNm, FinalUrlStr, TStr::GetLc(), HostNm, IsDefFinalUrl(), IsOk(), PathStr, PortStr, SchemeNm, SearchStr, UrlStr, and usHttp.

Referenced by ToLcPath().

                                              {
  EAssert(IsOk(usHttp));
  EAssert(!IsDefFinalUrl());
  FinalHostNm=_FinalHostNm.GetLc();
  if (HostNm==FinalHostNm){
    FinalUrlStr=UrlStr;
  } else {
    TChA FinalUrlChA;
    FinalUrlChA+=SchemeNm; FinalUrlChA+="://";
    FinalUrlChA+=FinalHostNm;
    if (!PortStr.Empty()){
      FinalUrlChA+=":"; FinalUrlChA+=PortStr;}
    FinalUrlChA+=PathStr;
    FinalUrlChA+=SearchStr;
    FinalUrlStr=FinalUrlChA;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void DefUrlAsFinal ( )

Definition at line 65 of file url.h.

References EAssert, FinalHostNm, FinalUrlStr, HostNm, IsDefFinalUrl(), IsOk(), UrlStr, and usHttp.

Here is the call graph for this function:

bool Empty ( ) const

Definition at line 146 of file url.h.

References TVec< TVal >::Empty(), and KeyNmV.

{return KeyNmV.Empty();}

Here is the call graph for this function:

void TUrl::GetAbs ( const TStr AbsUrlStr)

Definition at line 154 of file url.cpp.

References TStr::Clr(), THttp::DfPortN, EAssertR, TStr::Empty(), TUrlLx::Eof(), FragIdStr, TUrlLx::GetCh(), TUrlLx::GetHostPort(), TUrlLx::GetHPath(), TUrlLx::GetScheme(), TUrlLx::GetSearch(), TUrlLx::GetStr(), TUrlLx::GetToCh(), HostNm, IsAbs(), PathSegV, PathStr, TUrlLx::PeekCh(), PortN, PortStr, Scheme, SchemeNm, SearchStr, Str, UrlStr, usHttp, and usOther.

Referenced by GetAbsFromBase(), and TUrl().

                                      {
  EAssertR(IsAbs(AbsUrlStr), AbsUrlStr);
  TUrlLx Lx(AbsUrlStr); TChA Str;
  Str+=SchemeNm=Lx.GetScheme(); Str+=Lx.GetCh(':');
  if (SchemeNm=="http"){
    Scheme=usHttp;
    const char *DbSlashStr="//";
    Str+=Lx.GetStr(DbSlashStr);
    Str+=Lx.GetHostPort(HostNm, PortStr, PortN);
    if (PortN==-1){PortN=THttp::DfPortN; PortStr.Clr();}
    else if (PortN==THttp::DfPortN){PortStr.Clr();}
    //**if (!PortStr.Empty()){Str+=':'; Str+=PortStr;}
    if (Lx.PeekCh()=='/'){
      PathStr=Lx.GetCh('/'); PathStr+=Lx.GetHPath(PathSegV); Str+=PathStr;}
    if (PathStr.Empty()){PathStr="/"; Str+=PathStr;}
    if (Lx.PeekCh()=='?'){
      SearchStr=Lx.GetCh('?'); SearchStr+=Lx.GetSearch(); Str+=SearchStr;}
  } else {
    Scheme=usOther; Str+=Lx.GetToCh();
  }
  while (Lx.PeekCh()==' '){Lx.GetCh();}
  if (Lx.PeekCh()=='#'){
    FragIdStr=Lx.GetCh('#'); FragIdStr+=Lx.GetToCh();
  }
  EAssertR(Lx.Eof(), "");
  UrlStr=Str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TUrl::GetAbsFromBase ( const TStr RelUrlStr,
const TStr BaseUrlStr 
)

Definition at line 182 of file url.cpp.

References BaseUrlStr, TStr::DelStr(), TStr::DelSubStr(), EAssertR, TStr::Empty(), GetAbs(), TStr::GetLc(), TStr::GetSubStr(), IsAbs(), TStr::IsPrefix(), TStr::Len(), New(), RelUrlStr, TStr::SearchStr(), Str, and Url.

Referenced by TUrl().

                                                                      {
  EAssertR(!BaseUrlStr.Empty(), "");
  PUrl Url=TUrl::New(BaseUrlStr); EAssertR(Url->IsOk(), "");
  EAssertR(IsAbs(BaseUrlStr), "");
  TStr AbsUrlStr=BaseUrlStr;
  TStr NrRelUrlStr=RelUrlStr;
  if (NrRelUrlStr.GetLc().IsPrefix(UrlHttpPrefixStr)){
    NrRelUrlStr.DelSubStr(0, UrlHttpPrefixStr.Len()-1);}
  if (NrRelUrlStr.Len()>0){
    if (NrRelUrlStr[0]=='/'){
      TStr SlashStr; int SlashChN=0;
      while ((SlashChN<NrRelUrlStr.Len())&&(NrRelUrlStr[SlashChN]=='/')){
        SlashChN++; SlashStr+="/";}
      int ChN=0; bool Found=false;
      while ((!Found)&&((ChN=AbsUrlStr.SearchStr(SlashStr, ChN))!=-1)){
        TStr Str=AbsUrlStr.GetSubStr(ChN-1, ChN+SlashStr.Len()-1+1);
        Found=((ChN==0)||(Str[0]!='/'))&&
         ((ChN+SlashStr.Len()-1==AbsUrlStr.Len()-1)||(Str[Str.Len()-1]!='/'));
        if (!Found){ChN++;}
      }
      if (Found){
        AbsUrlStr.DelSubStr(ChN, AbsUrlStr.Len()-1);
        AbsUrlStr+=NrRelUrlStr;
      }
    } else {
      int ChN=AbsUrlStr.Len()-1;
      while ((ChN>=0)&&(AbsUrlStr[ChN]!='/')){ChN--;}
      AbsUrlStr.DelSubStr(ChN+1, AbsUrlStr.Len()-1);
      AbsUrlStr+=NrRelUrlStr;
    }
  }

  const char *PrevDirStr="/../";
  {int ChN;
  while ((ChN=AbsUrlStr.SearchStr(PrevDirStr))!=-1){
    int BChN=ChN; int EChN=ChN+(int) strlen(PrevDirStr)-1;
    while ((BChN-1>=0)&&(AbsUrlStr[BChN-1]!='/')){BChN--;}
    AbsUrlStr.DelSubStr(BChN, EChN);
  }}

  const char *CurDirStr="/.";
  while (AbsUrlStr.DelStr(CurDirStr)){}

  GetAbs(AbsUrlStr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file url.h.

References FinalHostNm, HostNm, and IsDefFinalUrl().

                                {
    if (IsDefFinalUrl()){return FinalHostNm;} else {return HostNm;}}

Here is the call graph for this function:

Definition at line 59 of file url.h.

References FinalUrlStr, IsDefFinalUrl(), and UrlStr.

                                {
    if (IsDefFinalUrl()){return FinalUrlStr;} else {return UrlStr;}}

Here is the call graph for this function:

TStr GetBaseUrlStr ( ) const

Definition at line 37 of file url.h.

References BaseUrlStr.

{return BaseUrlStr;}
TStr TUrl::GetDmNm ( const int &  MxDmSegs = -1) const

Definition at line 269 of file url.cpp.

References EAssert, HostNm, IsOk(), TStr::Len(), and TChA::Reverse().

                                            {
  EAssert(IsOk());
  TChA DmChA; int DmSegs=0;
  for (int ChN=HostNm.Len()-1; ChN>=0; ChN--){
    if (HostNm[ChN]=='.'){
      DmSegs++;
      if (DmSegs==MxDmSegs){break;} else {DmChA+='.';}
    } else {
      DmChA+=HostNm[ChN];
    }
  }
  DmChA.Reverse();
  return DmChA;
}

Here is the call graph for this function:

TStr TUrl::GetDocStrFromUrlStr ( const TStr UrlStr,
const int &  Copies = 1 
) [static]

Definition at line 407 of file url.cpp.

References TChA::Empty(), TVec< TVal >::Len(), TStr::Len(), and TStr::SplitOnNonAlNum().

                                                                   {
  TStrV StrV; UrlStr.SplitOnNonAlNum(StrV);
  TChA DocChA;
  for (int StrN=0; StrN<StrV.Len(); StrN++){
    TStr UcStr=StrV[StrN].GetUc();
    if ((UcStr.Len()>3)&&(UcStr!="HTTP")&&(UcStr!="HTML")&&(UcStr!="INDEX")&&(UcStr!="DEFAULT")){
      for (int CopyN=0; CopyN<Copies; CopyN++){
        if (!DocChA.Empty()){DocChA+=' ';} DocChA+=StrV[StrN];
      }
    }
  }
  return DocChA;
}

Here is the call graph for this function:

TStr GetFinalHostNm ( ) const

Definition at line 61 of file url.h.

References EAssert, FinalHostNm, and IsDefFinalUrl().

Here is the call graph for this function:

TStr GetFinalUrlStr ( ) const

Definition at line 57 of file url.h.

References EAssert, FinalUrlStr, and IsDefFinalUrl().

Here is the call graph for this function:

TStr GetFragIdStr ( ) const

Definition at line 48 of file url.h.

References EAssert, FragIdStr, and IsOk().

{EAssert(IsOk()); return FragIdStr;}

Here is the call graph for this function:

Definition at line 445 of file url.cpp.

References BaseUrlStr, THash< TKey, TDat, THashFunc >::GetDat(), GetKeyNm(), GetKeys(), GetUrlSearchStr(), KeyNmToValH, and TVec< TVal >::Len().

                                  {
  if (GetKeys()==0){return TStr();}
  TChA SearchChA;
  SearchChA+=BaseUrlStr;
  SearchChA+="?";
  int KeyVals=0;
  for (int KeyN=0; KeyN<GetKeys(); KeyN++){
    TStr KeyNm=GetKeyNm(KeyN);
    TStrV ValStrV=KeyNmToValH.GetDat(KeyNm);
    for (int ValStrN=0; ValStrN<ValStrV.Len(); ValStrN++){
      if (KeyVals>0){SearchChA+="&";}
      SearchChA+=TUrl::GetUrlSearchStr(KeyNm);
      SearchChA+='=';
      SearchChA+=TUrl::GetUrlSearchStr(ValStrV[ValStrN]);
      KeyVals++;
    }
  }
  return SearchChA;
}

Here is the call graph for this function:

TStr GetHostNm ( ) const

Definition at line 39 of file url.h.

References EAssert, HostNm, and IsOk().

Referenced by GetIpNumOrHostNm().

{EAssert(IsOk()); return HostNm;}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr GetHttpRqStr ( ) const

Definition at line 71 of file url.h.

References HttpRqStr.

{return HttpRqStr;}
TStr GetIpNum ( ) const

Definition at line 52 of file url.h.

References EAssert, IpNum, and IsIpNum().

{EAssert(IsIpNum()); return IpNum;}

Here is the call graph for this function:

Definition at line 53 of file url.h.

References GetHostNm(), GetIpNum(), and IsIpNum().

{return IsIpNum() ? GetIpNum() : GetHostNm();}

Here is the call graph for this function:

int GetKeyN ( const TStr KeyNm) const

Definition at line 149 of file url.h.

References KeyNmV, and TVec< TVal >::SearchForw().

{return KeyNmV.SearchForw(KeyNm);}

Here is the call graph for this function:

TStr GetKeyNm ( const int &  KeyN) const

Definition at line 150 of file url.h.

References KeyNmV.

Referenced by GetFullUrlStr().

{return KeyNmV[KeyN];}

Here is the caller graph for this function:

int GetKeys ( ) const

Definition at line 147 of file url.h.

References KeyNmV, and TVec< TVal >::Len().

Referenced by GetFullUrlStr().

{return KeyNmV.Len();}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr GetPathSeg ( const int &  PathSegN) const

Definition at line 46 of file url.h.

References PathSegV.

{return PathSegV[PathSegN];}
int GetPathSegs ( ) const

Definition at line 45 of file url.h.

References TVec< TVal >::Len(), and PathSegV.

{return PathSegV.Len();}

Here is the call graph for this function:

TStr GetPathStr ( ) const

Definition at line 44 of file url.h.

References EAssert, IsOk(), and PathStr.

{EAssert(IsOk()); return PathStr;}

Here is the call graph for this function:

int GetPortN ( ) const

Definition at line 43 of file url.h.

References EAssert, IsOk(), and PortN.

{EAssert(IsOk()&&(PortN!=-1)); return PortN;}

Here is the call graph for this function:

TStr GetPortStr ( ) const

Definition at line 42 of file url.h.

References EAssert, IsOk(), and PortStr.

{EAssert(IsOk()); return PortStr;}

Here is the call graph for this function:

TStr GetRelUrlStr ( ) const

Definition at line 35 of file url.h.

References RelUrlStr.

{return RelUrlStr;}

Definition at line 33 of file url.h.

References Scheme.

{return Scheme;}
TStr GetSchemeNm ( ) const

Definition at line 38 of file url.h.

References EAssert, IsOk(), and SchemeNm.

{EAssert(IsOk()); return SchemeNm;}

Here is the call graph for this function:

TStr GetSearchStr ( ) const

Definition at line 47 of file url.h.

References EAssert, IsOk(), and SearchStr.

{EAssert(IsOk()); return SearchStr;}

Here is the call graph for this function:

TStr TUrl::GetTopDownDocNm ( const TStr UrlStr,
const int &  MxLen = -1,
const bool &  HostOnlyP = false 
) [static]

Definition at line 421 of file url.cpp.

References TStr::GetLc(), HostNm, TVec< TVal >::Len(), New(), TStr::SplitOnAllCh(), TChA::Trunc(), and Url.

                                                             {
  PUrl Url=TUrl::New(UrlStr);
  TChA DocNm;
  if (Url->IsOk()){
    TStr HostNm=Url->GetHostNm().GetLc();
    TStrV HostNmSegV; HostNm.SplitOnAllCh('.', HostNmSegV, false);
    for (int HostNmSegN=0; HostNmSegN<HostNmSegV.Len(); HostNmSegN++){
      if (HostNmSegN>0){DocNm+='.';}
      DocNm+=HostNmSegV[HostNmSegV.Len()-HostNmSegN-1];
    }
    if (!HostOnlyP){
      DocNm+=Url->GetPathStr().GetLc();
    }
  } else {
    DocNm=UrlStr.GetLc();
  }
  if (MxLen!=-1){
    DocNm.Trunc(MxLen);}
  return DocNm;
}

Here is the call graph for this function:

PUrl TUrl::GetUrlFromShortcut ( const TStr ShortcutUrlStr,
const TStr DfHostNmPrefix,
const TStr DfHostNmSufix 
) [static]

Definition at line 343 of file url.cpp.

References TStr::IsChIn(), New(), Url, UrlHttpAbsPrefixStr, and UrlStr.

                                                       {
  // shortcut is already correct url
  TStr UrlStr=ShortcutUrlStr;
  PUrl Url=TUrl::New(UrlStr);
  if (Url->IsOk()){return Url;}
  // add 'http://' to shortcut (if shortcut is from more segments)
  if (ShortcutUrlStr.IsChIn('.')){
    UrlStr=TUrl::UrlHttpAbsPrefixStr+ShortcutUrlStr;
    Url=TUrl::New(UrlStr);
    if (Url->IsOk()){return Url;}
  }
  // add 'http://' and '/' to shortcut (if shortcut is from more segments)
  if (ShortcutUrlStr.IsChIn('.')){
    UrlStr=TUrl::UrlHttpAbsPrefixStr+ShortcutUrlStr+"/";
    Url=TUrl::New(UrlStr);
    if (Url->IsOk()){return Url;}
  }
  // add 'http://', prefix, postfix and '/' to shortcut
  UrlStr=UrlHttpAbsPrefixStr+
   DfHostNmPrefix+"."+ShortcutUrlStr+"."+DfHostNmSufix+"/";
  Url=TUrl::New(UrlStr);
  return Url;
}

Here is the call graph for this function:

TStr TUrl::GetUrlSearchStr ( const TStr Str) [static]

Definition at line 368 of file url.cpp.

References TInt::GetHexStr(), TChA::Len(), and Str.

Referenced by GetFullUrlStr().

                                         {
  TChA InChA=Str; TChA OutChA;
  for (int ChN=0; ChN<InChA.Len(); ChN++){
    char Ch=InChA[ChN];
    if (Ch==' '){
      OutChA+='+';
    } else
    if ((' '<Ch)&&(Ch<='~')&&(Ch!='+')&&(Ch!='&')&&(Ch!='%')){
      OutChA+=Ch;
    } else {
      OutChA+='%';
      OutChA+=TInt::GetHexStr(uchar(Ch)/16);
      OutChA+=TInt::GetHexStr(uchar(Ch)%16);
    }
  }
  return OutChA;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr GetUrlStr ( ) const

Definition at line 34 of file url.h.

References UrlStr.

{return UrlStr;}
TStr GetVal ( const TStr KeyNm,
const int &  ValN = 0,
const TStr DfVal = "" 
) const

Definition at line 159 of file url.h.

References THash< TKey, TDat, THashFunc >::GetDat(), THash< TKey, TDat, THashFunc >::IsKey(), and KeyNmToValH.

                                                                                {
    if (KeyNmToValH.IsKey(KeyNm)){
      return KeyNmToValH.GetDat(KeyNm)[ValN];}
    else {return DfVal;}}

Here is the call graph for this function:

int GetVals ( const int &  KeyN) const

Definition at line 153 of file url.h.

References THash< TKey, TDat, THashFunc >::GetDat(), KeyNmToValH, and KeyNmV.

Referenced by GetValVStr().

                                     {
    return KeyNmToValH.GetDat(KeyNmV[KeyN]).Len();}

Here is the call graph for this function:

Here is the caller graph for this function:

int GetVals ( const TStr KeyNm) const

Definition at line 155 of file url.h.

References THash< TKey, TDat, THashFunc >::GetDat(), and KeyNmToValH.

                                       {
    return KeyNmToValH.GetDat(KeyNm).Len();}

Here is the call graph for this function:

bool TUrl::IsAbs ( const TStr UrlStr) [static]

Definition at line 324 of file url.cpp.

References TStr::GetLc(), TStr::IsPrefix(), TStr::SearchCh(), and UrlHttpAbsPrefixStr.

Referenced by GetAbs(), GetAbsFromBase(), and TUrl().

                                  {
  if (UrlStr.GetLc().IsPrefix(UrlHttpPrefixStr)){
    return UrlStr.GetLc().IsPrefix(UrlHttpAbsPrefixStr);
  } else {
    int ColonChN=UrlStr.SearchCh(':'); int SlashChN=UrlStr.SearchCh('/');
    return (ColonChN!=-1)&&((SlashChN==-1)||((SlashChN!=-1)&&(ColonChN<SlashChN)));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsBaseUrl ( )

Definition at line 36 of file url.h.

References BaseUrlStr, and TStr::Empty().

{return !BaseUrlStr.Empty();}

Here is the call graph for this function:

bool IsDefFinalUrl ( ) const

Definition at line 55 of file url.h.

References EAssert, TStr::Empty(), FinalUrlStr, IsOk(), and usHttp.

Referenced by DefFinalUrl(), DefUrlAsFinal(), GetAsFinalHostNm(), GetAsFinalUrlStr(), GetFinalHostNm(), GetFinalUrlStr(), and ToLcPath().

                             {
    EAssert(IsOk(usHttp)); return !FinalUrlStr.Empty();}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsHttpRqStr ( ) const

Definition at line 72 of file url.h.

References TStr::Empty(), and HttpRqStr.

{return !HttpRqStr.Empty();}

Here is the call graph for this function:

bool IsInHost ( const TStr _HostNm) const

Definition at line 76 of file url.h.

References EAssert, TStr::GetUc(), HostNm, IsOk(), and TStr::IsSuffix().

                                           {
    EAssert(IsOk()); return HostNm.GetUc().IsSuffix(_HostNm.GetUc());}

Here is the call graph for this function:

bool IsInPath ( const TStr _PathStr) const

Definition at line 78 of file url.h.

References EAssert, TStr::GetUc(), IsOk(), TStr::IsPrefix(), and PathStr.

                                            {
    EAssert(IsOk()); return PathStr.GetUc().IsPrefix(_PathStr.GetUc());}

Here is the call graph for this function:

bool IsIpNum ( ) const

Definition at line 50 of file url.h.

References TStr::Empty(), and IpNum.

Referenced by GetIpNum(), and GetIpNumOrHostNm().

{return !IpNum.Empty();}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsKey ( const TStr KeyNm) const

Definition at line 148 of file url.h.

References KeyNmV, and TVec< TVal >::SearchForw().

Referenced by AddKeyVal(), AddToKeyVal(), TSparseHash< TKey, TDat, GroupSize >::GetKeyDat(), and TSparseHash< TKey, TDat, GroupSize >::IsKeyGetDat().

{return KeyNmV.SearchForw(KeyNm)!=-1;}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsOk ( const TUrlScheme  _Scheme = usUndef) const

Definition at line 30 of file url.h.

References Scheme, and usUndef.

                                                    {
    if (_Scheme==usUndef){return Scheme!=usUndef;}
    else {return Scheme==_Scheme;}}
bool IsPortOk ( ) const

Definition at line 41 of file url.h.

References EAssert, IsOk(), and PortN.

{ EAssert(IsOk()); return (PortN > 0); }

Here is the call graph for this function:

bool TUrl::IsScript ( const TStr UrlStr) [static]

Definition at line 333 of file url.cpp.

References TStr::IsChIn().

                                     {
  return UrlStr.IsChIn('?');
}

Here is the call graph for this function:

bool TUrl::IsSite ( const TStr UrlStr) [static]

Definition at line 337 of file url.cpp.

References New(), Url, and usHttp.

                                   {
  PUrl Url=TUrl::New(UrlStr);
  return Url->IsOk(usHttp) && (Url->GetPathStr()=="/") &&
   Url->GetSearchStr().Empty() && Url->GetFragIdStr().Empty();
}

Here is the call graph for this function:

static PUrlEnv Load ( TSIn SIn) [static]

Definition at line 27 of file url.h.

References Fail.

{Fail; return NULL;}
static PUrlEnv MkClone ( const PUrlEnv &  UrlEnv) [static]
static PUrl New ( const TStr RelUrlStr,
const TStr BaseUrlStr = TStr() 
) [static]

Definition at line 23 of file url.h.

References TUrl().

                                                                       {
    return PUrl(new TUrl(RelUrlStr, BaseUrlStr));}

Here is the call graph for this function:

static PUrlEnv New ( ) [static]

Definition at line 110 of file url.h.

References TUrlEnv().

{return new TUrlEnv();}

Here is the call graph for this function:

static PUrlEnv New ( const TStr BaseUrlStr,
const TStr KeyNm1 = TStr(),
const TStr ValStr1 = TStr(),
const TStr KeyNm2 = TStr(),
const TStr ValStr2 = TStr(),
const TStr KeyNm3 = TStr(),
const TStr ValStr3 = TStr(),
const TStr KeyNm4 = TStr(),
const TStr ValStr4 = TStr() 
) [static]

Definition at line 111 of file url.h.

References New(), and UrlEnv.

                                                         {
    PUrlEnv UrlEnv=New();
    UrlEnv->PutBaseUrlStr(BaseUrlStr);
    if (!KeyNm1.Empty()){UrlEnv->AddKeyVal(KeyNm1, ValStr1);}
    if (!KeyNm2.Empty()){UrlEnv->AddKeyVal(KeyNm2, ValStr2);}
    if (!KeyNm3.Empty()){UrlEnv->AddKeyVal(KeyNm3, ValStr3);}
    if (!KeyNm4.Empty()){UrlEnv->AddKeyVal(KeyNm4, ValStr4);}
    return UrlEnv;}

Here is the call graph for this function:

TUrlEnv& operator= ( const TUrlEnv Env)

Definition at line 128 of file url.h.

References KeyNmToValH, and KeyNmV.

                                        {
    if (this!=&Env){KeyNmV=Env.KeyNmV; KeyNmToValH=Env.KeyNmToValH;}
    return *this;}
void PutBaseUrlStr ( const TStr _BaseUrlStr)

Definition at line 133 of file url.h.

{BaseUrlStr=_BaseUrlStr;}
void PutHttpRqStr ( const TStr _HttpRqStr)

Definition at line 70 of file url.h.

References HttpRqStr.

{HttpRqStr=_HttpRqStr;}
void PutIpNum ( const TStr _IpNum)

Definition at line 51 of file url.h.

References IpNum.

{IpNum=_IpNum;}
void Save ( TSOut SOut)

Definition at line 28 of file url.h.

References Fail.

{Fail;}
void TUrl::ToLcPath ( )

Definition at line 302 of file url.cpp.

References TStr::Clr(), DefFinalUrl(), TStr::Empty(), FinalHostNm, FinalUrlStr, HostNm, IsDefFinalUrl(), TStr::IsLc(), TVec< TVal >::Len(), PathSegV, PathStr, PortStr, SchemeNm, SearchStr, TStr::ToLc(), and UrlStr.

                   {
  // test if the conversion is needed
  if (!PathStr.IsLc()){
    // convert path strings to lower-case
    PathStr.ToLc();
    for (int PathSegN=0; PathSegN<PathSegV.Len(); PathSegN++){
      PathSegV[PathSegN].ToLc();}
    // recompose url
    TChA UrlChA;
    UrlChA+=SchemeNm; UrlChA+="://";
    UrlChA+=HostNm;
    if (!PortStr.Empty()){
      UrlChA+=":"; UrlChA+=PortStr;}
    UrlChA+=PathStr;
    UrlChA+=SearchStr;
    UrlStr=UrlChA;
    // recompose final-url
    if (IsDefFinalUrl()){
      FinalUrlStr.Clr(); DefFinalUrl(FinalHostNm);}
  }
}

Here is the call graph for this function:

TUrl::TUrl ( const TStr _RelUrlStr,
const TStr _BaseUrlStr = TStr() 
)

Definition at line 228 of file url.cpp.

References BaseUrlStr, TStr::ChangeStrAll(), GetAbs(), GetAbsFromBase(), IsAbs(), RelUrlStr, Scheme, TStr::ToTrunc(), and usUndef.

Referenced by THttpLx::GetUrl(), and New().

                                                         :
  Scheme(usUndef),
  UrlStr(), RelUrlStr(_RelUrlStr), BaseUrlStr(_BaseUrlStr),
  SchemeNm(), HostNm(),
  PortStr(), PathStr(), SearchStr(), FragIdStr(),
  PortN(-1), PathSegV(),
  IpNum(),
  FinalUrlStr(), FinalHostNm(),
  HttpRqStr(){
  RelUrlStr.ToTrunc();
  RelUrlStr.ChangeStrAll(" ", "%20");
  try {
    if (IsAbs(RelUrlStr)){
      GetAbs(RelUrlStr);
    } else
    if (IsAbs(BaseUrlStr)){
      GetAbsFromBase(RelUrlStr, BaseUrlStr);
    } else {
      Scheme=usUndef;
    }
  }
  catch (PExcept&){Scheme=usUndef;}

  //** old version
  /*
  PUrl BaseUrl;
  if (!BaseUrlStr.Empty()){ // must be outside try-block (CBuilder3.0 bug)
    BaseUrl=TUrl::New(BaseUrlStr);}
  try {
    if (!BaseUrlStr.Empty()){
      EAssertR(BaseUrl->IsOk(), "");}
    if (IsAbs(RelUrlStr)){
      GetAbs(RelUrlStr);
    } else {
      GetAbsFromBase(RelUrlStr, BaseUrlStr);
    }
  }
  catch (PExcept&){Scheme=usUndef;}
  */
}

Here is the call graph for this function:

Here is the caller graph for this function:

TUrl ( TSIn )

Definition at line 26 of file url.h.

References Fail.

{Fail;}
TUrlEnv ( )

Definition at line 106 of file url.h.

Referenced by New().

           :
    KeyNmV(), KeyNmToValH(10){}

Here is the caller graph for this function:

TUrlEnv ( const TUrlEnv UrlEnv)

Definition at line 108 of file url.h.

                                :
    KeyNmV(UrlEnv.KeyNmV), KeyNmToValH(UrlEnv.KeyNmToValH){}
TUrlEnv ( TSIn SIn)

Definition at line 124 of file url.h.

: KeyNmV(SIn), KeyNmToValH(SIn){}
~TUrl ( )

Definition at line 25 of file url.h.

{}
~TUrlEnv ( )

Definition at line 123 of file url.h.

{}

Variable Documentation

Definition at line 10 of file url.h.

Referenced by GetAbsFromBase(), GetBaseUrlStr(), GetFullUrlStr(), IsBaseUrl(), and TUrl().

Definition at line 12 of file url.h.

Referenced by GetAbs(), and GetFragIdStr().

Definition at line 17 of file url.h.

Referenced by ChangeHttpRqStr(), GetHttpRqStr(), IsHttpRqStr(), and PutHttpRqStr().

Definition at line 15 of file url.h.

Referenced by GetIpNum(), IsIpNum(), and PutIpNum().

ClassTP (TUrlEnv, PUrlEnv) private TStrV KeyNmV

Definition at line 100 of file url.h.

Referenced by AddKeyVal(), AddToKeyVal(), Empty(), GetKeyN(), GetKeyNm(), GetKeys(), GetVal(), GetVals(), IsKey(), and operator=().

Definition at line 14 of file url.h.

Referenced by GetAbs(), GetPathSeg(), GetPathSegs(), and ToLcPath().

Definition at line 12 of file url.h.

Referenced by DefFinalUrl(), GetAbs(), GetPortStr(), and ToLcPath().

Definition at line 10 of file url.h.

Referenced by GetAbsFromBase(), GetOutDescUrlStrKdV(), GetOutUrlV(), GetRelUrlStr(), and TUrl().

Definition at line 9 of file url.h.

Referenced by GetAbs(), GetScheme(), IsOk(), and TUrl().

Definition at line 11 of file url.h.

Referenced by DefFinalUrl(), GetAbs(), GetSchemeNm(), and ToLcPath().

Definition at line 12 of file url.h.

Referenced by DefFinalUrl(), GetAbs(), GetSearchStr(), ParseHttpRq(), and ToLcPath().

const TStr TUrl::UrlHttpAbsPrefixStr = "http://" [static]

Definition at line 5 of file url.h.

Referenced by GetUrlFromShortcut(), and IsAbs().