Purpose: Populate a string with a substring of this string. Return an empty string if the requested position goes beyong length of string, Return a partial string if the length requested goes beyond the end of the string

Return TypeFunction nameArguments
hzStringhzString::SubString(uint32_t,uint32_t,)

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

Function Logic:

0:START 1:unknown 2:Return Dest 3:thisCtl Length nRemainder 4:unknown 5:Return Dest 6:unknown 7:nBytes 8:unknown 9:nBytes 10:Dest 11:unknown 12:items 13:destCtl items items destCtl 14:Return Dest

Function body:

hzString hzString::SubString (uint32_t nPosn)uint32_t nBytes, 
{
   //  Purpose: Populate a string with a substring of this string. Return an empty string if the
   //     requested position goes beyong length of string, Return a partial string if the
   //     length requested goes beyond the end of the string
   //  
   //  Arguments: 1) nPosn Starting offset within this string.
   //     2) nBytes Length from here. A value of 0 indicates remainder of this string.
   //  
   //  Returns: Instance of hzString by value being the substring result
   _hzfunc("hzString::SubString") ;
   _strItem*   thisCtl ;       //  This string's control area
   _strItem*   destCtl ;       //  Result string control area
   hzString    Dest ;          //  Target string
   uint32_t    nRemainder ;    //  Remainder of original past the stated position
   if (!m_addr)
       return Dest ;
   thisCtl = _strXlate(m_addr) ;
   nRemainder = Length() - nPosn ;
   if (nRemainder <&eq; 0)
       return Dest ;
   if (nBytes == 0)
       nBytes = nRemainder ;
   if (nBytes > nRemainder)
       nBytes = nRemainder ;
   Dest.m_addr = _strAlloc(nBytes) ;
   if (!Dest.m_addr)
       hzexit(E_MEMORY, "Buffer of (%d) bytes", nBytes) ;
   destCtl = _strXlate(Dest.m_addr) ;
   //  Go to position
   destCtl->_setSize(nBytes) ;
   memcpy(destCtl->_data(), thisCtl->_data() + nPosn, nBytes) ;
   destCtl->m_copy = 1;
   return Dest ;
}