Determine if the supplied chain iterator is at the start of a numeric entity of the form &#x[hex number]; or &#[dec number]; Note: This function always leaves the supplied iterator unchanged in accordance with the HadronZoo text-processing rules.

Return TypeFunction nameArguments
boolAtEntity(uint32_t&,uint32_t&,hzChain::Iter&,)

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

Function Logic:

0:START 1:entLen uVal nLen xi 2:unknown 3:Return false 4:items 5:unknown 6:uVal 7:Return 5 8:unknown 9:uVal 10:Return 4 11:unknown 12:uVal 13:Return 4 14:unknown 15:uVal 16:Return 6 17:unknown 18:Return false 19:items 20:unknown 21:nLen 22:unknown 23:uVal 24:unknown 25:* 26:uVal 27:unknown 28:uVal * uVal 29:unknown 30:uVal * uVal 31:nLen 32:unknown 33:uVal * uVal 34:unknown 35:entLen 36:Return true 37:uVal 38:Return false

Function body:

bool AtEntity (uint32_t& uVal)uint32_t& entLen, hzChain::Iter& zi, 
{
   //  Category: Text Processing
   //  
   //  Determine if the supplied chain iterator is at the start of a numeric entity of the form &#x[hex number]; or &#[dec number];
   //  
   //  Arguments: 1) uVal The value of the entity.
   //     2) entLen The length of the entity
   //     3) zi  The chain iterator.
   //  
   //  Returns: True If the chain iterator is at the start of a valid entity
   //     False Otherwise
   //  
   //  Note:  This function always leaves the supplied iterator unchanged in accordance with the HadronZoo text-processing rules.
   _hzfunc(__func__) ;
   chIter      xi ;        //  Input chain iterator
   uint32_t    nLen ;      //  Length of entity
   uVal = entLen = 0;
   nLen = 0;
   //  First char must be an ampersand
   xi = zi ;
   if (*xi != CHAR_AMPSAND)
       return false ;
   //  Second char could be start of a non-numeric entity
   xi++ ;
   if (*xi == ''a''&&xi == "amp;")     { uVal = 38;return 5; }
   if (*xi == ''g''&&xi == "gt;")      { uVal = 62;return 4; }
   if (*xi == ''l''&&xi == "lt;")      { uVal = 60;return 4; }
   if (*xi == ''n''&&xi == "nbsp;")    { uVal = 32;return 6; }
   //  Now we only consider numeric entities and for these the second char must be a hash
   if (*xi != CHAR_HASH)
       return false ;
   xi++ ;
   if (*xi == ''x'')
   {
       //  Examining a suspected hex entity
       nLen = 4;
       for (xi++ ; !xi.eof() && IsHex(*xi) ; nLen++, xi++)
       {
           uVal *= 16;
           if (*xi >&eq; ''0''&&*xi <&eq; ''9''){uVal += (*xi - ''0'');continue ; }
           if (*xi >&eq; ''A''&&*xi <&eq; ''F''){uVal += 10;uVal += (*xi - ''A'');continue ; }
           if (*xi >&eq; ''a''&&*xi <&eq; ''f''){uVal += 10;uVal += (*xi - ''a'');continue ; }
           break ;
       }
   }
   else
   {
       //  Expecting a decimal entity
       nLen = 3;
       for (; !xi.eof() && IsDigit(*xi) ; nLen++, xi++)
       {
           uVal *= 10;
           uVal += (*xi - ''0'');
       }
   }
   if (*xi == '';'')
   {
       //  Entity confirmed
       entLen = nLen ;
       return true ;
   }
   uVal = 0;
   return false ;
}