This is used as an alternative to the assignement operator, specifically to deal with such URLs as links in webpages. These may be full URLs with or without the scheme, but with the domain - or they can simply start with a / and consist only of the resource. Where the link lacks the domain, the supplied domain is used. Where the link does have a domain specified this takes precedence.

Return TypeFunction nameArguments
hzUrl&hzUrl::SetValue(hzString,hzString,bool,uint32_t,)

Declared in file: hzUrl.h
Defined in file : hzUrl.cpp

Function Logic:

0:START 1:items 2:unknown 3:Return *this 4:unknown 5:Return *this 6:res items 7:unknown 8:items 9:Return *this 10:unknown 11:items 12:unknown 13:items 14:items 15:unknown 16:items 17:lenPort 18:items lenDom pRI 19:unknown 20:lenRes items 21:res 22:lenRes lenPort lenDom lenProt 23:lenTotal m_addr pTmp thisCtl pTmp thisCtl thisCtl thisCtl thisCtl thisCtl thisCtl 24:unknown 25:items 26:items 27:items 28:unknown 29:lenProt 30:pTmp items 31:thisCtl items thisCtl 32:Return *this

Function body:

hzUrl& hzUrl::SetValue (hzString domain)hzString resource, bool bSecure, uint32_t nPort, 
{
   //  This is used as an alternative to the assignement operator, specifically to deal with such URLs as links in webpages. These may be full URLs with or without the scheme, but
   //  with the domain - or they can simply start with a / and consist only of the resource. Where the link lacks the domain, the supplied domain is used. Where the link does have
   //  a domain specified this takes precedence.
   //  
   //  Arguments: 1) domain  The domain name part of the URL
   //     2) resource The resource part
   //     3) bSecure  Use SSL so https:// instead of http://
   //     4) nPort  Port number if any
   //  
   //  Returns: Reference to this URL intance
   _url_space*     thisCtl ;       //  This URL space
   const char*     pRI ;           //  Resource iterator
   char*           pTmp ;          //  Shuts compiler up about sprintf to buffer
   hzString        res ;           //  Resource (allowing a truncate after ?)
   uint32_t        lenTotal ;      //  Length of whole URL
   uint32_t        lenProt ;       //  Lenth of protocol part
   uint32_t        lenDom ;        //  Length of domain part
   uint32_t        lenRes ;        //  Length of resource part
   uint32_t        lenPort = 0;    //  Length of port part
   bool            bPort = false ; //  Port specified indicator 
   /*
   **  ** Test arguments
   **      */
   Clear() ;
   if (!domain)    return *this ;
   if (!resource)  return *this ;
   res = resource ;
   res.TruncateUpto("?") ;
   if (memcmp(*res, "http://", 7)== 0)
   {
       operator=(res) ;
       return *this ;
   }
   //  If the port is not set it is determined by the protocol (http is 80 or https is 443).
   if (!nPort)
       nPort = bSecure ? 443:80;
   else
   {
       //  Don't include the :port_no notation unless we have a non-standard port
       if (bSecure)
           bPort = nPort == 443?false: true ;
       else
           bPort = nPort == 80?false : true ;
   }
   if (bPort)
       lenPort = nPort > 9999?6:nPort> 999?5:nPort > 99?4: nPort > 9? 3: 2;
   else
       lenPort = 0;
   lenProt = bSecure ? 8: 7;
   lenDom = domain.Length() ;
   pRI = *res ;
   if (pRI[0]== CHAR_FWSLASH)
   {
       lenRes = res.Length() ;
       pRI++ ;
   }
   else
       lenRes = res.Length() + 1;
   /*
   **  ** Compile finished URL
   **      */
   lenTotal = lenProt + lenDom + lenPort + lenRes ;
   m_addr = _urlAlloc(lenTotal + URL_FACTOR) ;
   pTmp = (char*) _urlXlate(m_addr) ;
   thisCtl = (_url_space*) pTmp ;
   pTmp += 11;
   //  thisCtl = (_url_space*) _urlXlate(m_addr) ;
   thisCtl->m_copy = 1;                //  No copies
   thisCtl->m_lenProt = lenProt ;      //  Length of protocol component
   thisCtl->m_lenDom = lenDom ;        //  Length of domain component
   thisCtl->m_lenPort = lenPort ;      //  Length of port component
   thisCtl->m_lenRes = lenRes ;        //  MSB of length of resource component
   thisCtl->m_port = nPort ;           //  Port number
   if (bSecure)
       memcpy(thisCtl->m_data, "https://", lenProt) ;
   else
       memcpy(thisCtl->m_data, "http://", lenProt) ;
   memcpy(thisCtl->m_data + lenProt, *domain, lenDom) ;
   if (bPort)
   {
       pTmp += (lenProt + lenDom) ;
       sprintf(pTmp, ":%d", nPort) ;
       //  sprintf(thisCtl->m_data + lenProt + lenDom, ":%d", nPort) ;
   }
   thisCtl->m_data[lenProt + lenDom + lenPort] = CHAR_FWSLASH ;
   memcpy(thisCtl->m_data + lenProt + lenDom + lenPort + 1,pRI, lenRes - 1);
   thisCtl->m_data[lenTotal] = 0;
   return *this ;
}