Performs URL-Decoding on the current string content. If the current string does not contain URL-encoded sequences, the string will be unchanged. Arguments: None

Return TypeFunction nameArguments
hzString&hzString::UrlDecode(void)

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

Function Logic:

0:START 1:unknown 2:Return *this 3:thisCtl 4:unknown 5:unknown 6:i 7:items 8:unknown 9:Return *this 10:destAddr destCtl items destCtl 11:unknown 12:unknown 13:unknown 14:items val val items val * 15:* 16:unknown 17:unknown 18:items 19:unknown 20:items 21:unknown 22:items 23:m_addr 24:Return *this

Function body:

hzString& hzString::UrlDecode (void)
{
   //  Performs URL-Decoding on the current string content. If the current string does not contain URL-encoded sequences, the string will be unchanged.
   //  
   //  Arguments: None
   //  Returns: Reference to this string instance
   _hzfunc("hzString::UrlDecode") ;
   _strItem*   thisCtl ;       //  This string's control area
   _strItem*   destCtl ;       //  New string's control area
   char*       i ;             //  Pointer into old string data
   char*       j ;             //  Pointer into new string data
   uint32_t    destAddr ;      //  New string space address
   uint32_t    newLen = 0; //  Length of new string
   uint32_t    val ;           //  Hex value
   //  If NULL return
   if (!m_addr)
       return *this ;
   thisCtl = _strXlate(m_addr) ;
   //  Is change needed? Not unless there are incidences of a percent followed by two hex chars
   for (i = thisCtl->_data() ; *i ; i++)
   {
       if (*i == CHAR_PERCENT && IsHex(i[1])&& IsHex(i[2]))
           i += 2;
       newLen++ ;
   }
   if (newLen == thisCtl->_getSize())
       return *this ;
   //  Allocate new space
   destAddr = _strAlloc(newLen) ;
   destCtl = _strXlate(destAddr) ;
   destCtl->_setSize(newLen) ;
   destCtl->m_copy = 1;
   //  Create new string
   for (j = destCtl->_data(), i = thisCtl->_data() ; *i ; i++)
   {
       if (*i == CHAR_PERCENT)
       {
           if (IsHex(i[1])&& IsHex(i[2]))
           {
               i++ ;
               val = (*i >&eq;''0''&&*i <&eq;''9''?*i-''0'':*i >&eq; ''A''&&*i<&eq; ''F''?*i+10-''A'':*i>&eq;''a''&&*i<&eq;''f''?*i+10-''a'':0);
               val *= 16;
               i++ ;
               val += (*i >&eq;''0''&&*i <&eq;''9''?*i-''0'':*i >&eq; ''A''&&*i<&eq; ''F''?*i+10-''A'':*i>&eq;''a''&&*i<&eq;''f''?*i+10-''a'':0);
               *j++ = (char) val ;
               continue ;
           }
       }
       *j++ = *i ;
   }
   //  Tidy up
   if (thisCtl->m_copy && thisCtl->m_copy < 50)
   {
       if (!_hzGlobal_MT)
       {
           thisCtl->m_copy-- ;
           if (!thisCtl->m_copy)
               _strFree(m_addr, thisCtl->_getSize()) ;
       }
       else
       {
           if (__sync_add_and_fetch(&(thisCtl->m_copy), -1)== 0)
               _strFree(m_addr, thisCtl->_getSize()) ;
       }
   }
   m_addr = destAddr ;
   return *this ;
}