Text substitution Replace within this string, all instances of strA with strB. This string is unchanged if strA does not exist within it.

Return TypeFunction nameArguments
hzString&hzString::Replace(const char*,const char*,)

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

Function Logic:

0:START 1:unknown 2:Return *this 3:unknown 4:Return *this 5:thisCtl nLen i 6:unknown 7:unknown 8:unknown 9:unknown 10:bFound 11:unknown 12:items 13:i 14:items items 15:unknown 16:items items 17:Return *this

Function body:

hzString& hzString::Replace (const char* strA)const char* strB, 
{
   //  Text substitution
   //  
   //  Replace within this string, all instances of strA with strB. This string is unchanged if strA does not exist within it.
   //  
   //  Arguments: 1) strA Patern to be substituted out
   //     2) strB Patern to be used instead
   //  
   //  Returns: Reference to this string in all cases
   _hzfunc("hzString::Replace") ;
   hzChain         Z ;                 //  Working chain buffer
   _strItem*       thisCtl ;           //  This string's control area
   const char*     i ;                 //  Pointer into string data
   uint32_t        nLen ;              //  Lenth of supplied strings
   bool            bFound = false ;    //  Indicates string to be replace is found
   if (!strA)
       return *this ;
   if (!m_addr)
       return *this ;
   thisCtl = _strXlate(m_addr) ;
   nLen = strlen(strA) ;
   i = (char*) thisCtl->_data() ;
   if (strstr(i, strA))
   {
       for (; *i ;)
       {
           if (*i == strA[0])
           {
               if (!memcmp(i, strA, nLen))
               {
                   bFound = true ;
                   if (strB && strB[0])
                       Z << strB ;
                   i += nLen ;
                   continue ;
               }
           }
           Z.AddByte(*i) ;
           i++ ;
       }
   }
   if (bFound)
       { Clear() ; operator=(Z) ; }
   return *this ;
}