Return TypeFunction nameArguments
hzEcodehzDocXml::Load(hzChain&,)

Declared in file: hzDocument.h
Defined in file : hzDocXml.cpp

Function Logic:

0:START 1:hzChain::Clear ci 2:*ci&0x80; 3:ci== 4:*ci!=(char)62; 5:*ci<=(char)32; 6:ci.Equiv( 7:*ci&&*ci<=(char)32; 8:tagstate 9:tagstate&&*ci; 10:*ci==(char)60 11:items 12:*ci==(char)62 13:items 14:bNewline 15:!ci.eof(); 16:*ci==(char)13 17:items 18:*ci==(char)10 19:bNewline items 20:bNewline 21:pCN&&nodeContent.Size() 22:hzChain::AddByte 23:bNewline 24:!pCN 25:*ci!=(char)60 26:hzChain::Iter::Line hzChain::Printf rc 27:*ci==(char)60 28:ci== 31:ci.eof() 32:hzChain::Iter::Line hzChain::Printf rc 33:ci 34:ci== </tspan> </text> <rect x="492" y="1242" width="80" height="48" style="fill:#66ff00;stroke:#000000;stroke-width:1;"/> <text fill="#000000" dominant-baseline="top"> <tspan x="492" dy="1262">35:xi </tspan> <tspan x="492" y="1282">xi </tspan> </text> <polygon points="456,1344 472,1328 536,1328 552,1344, 536,1360, 472,1360" style="fill:#ffffe0;stroke:#000000;stroke-width:1"/> <text fill="#000000" dominant-baseline="top"> <tspan x="456" dy="1348">36:!xi.eof(); </tspan> </text> <polygon points="598,1344 614,1328 678,1328 694,1344, 678,1360, 614,1360" style="fill:#ffffe0;stroke:#000000;stroke-width:1"/> <text fill="#000000" dominant-baseline="top"> <tspan x="598" dy="1348">37:xi== 38:xi ci 39:hzChain::AddByte 40:hzXmlNode::SetCDATA hzChain::Clear 41:m_bXmlesce 42:_testHtag(tagval,ci) 43:items hzString::Length ci 44:pCN&&pCN->IsXmlesce() 45:_testHtag(tagval,ci) 46:items hzString::Length ci 47:hzDocXml::_proctagopen tagstate 48:tagstate<0 49:hzChain::Iter::Line hzChain::Printf 50:tagstate==0 51:pNN 52:nodeContent.Size() 53:hzXmlNode::SetPretext 54:hzChain::Clear pCN 55:!m_pRoot 56:m_pRoot 57:hzXmlNode::txtName hzXmlNode::GetUid hzMapM::Insert 58:items 59:tagstate==1 60:pNN 61:nodeContent.Size() 62:hzXmlNode::SetPretext 63:hzChain::Clear 64:!m_pRoot 65:m_pRoot 66:hzXmlNode::txtName hzXmlNode::GetUid hzMapM::Insert 67:items 68:rc _istagclose 69:_istagclose(Test,ci) 70:Test!=pCN->txtName() 71:hzChain::Iter::Line hzXmlNode::txtName hzXmlNode::Line hzChain::Printf rc 72:nodeContent.Size() 73:hzXmlNode::SetContent 74:hzChain::Clear hzChain::Iter::Line hzXmlNode::_setanti hzXmlNode::Parent pCN 75:pCN==0 76:items 77:pCN==0 78:*ci==(char)9 79:hzChain::AddByte 80:hzChain::AddByte 81:items 82:pCN 83:hzChain::Iter::Line hzChain::Printf rc 84:Return rc

Function body:

hzEcode hzDocXml::Load (hzChain& Z)
{
   _hzfunc("hzDocXml::Load") ;
   hzList<hzString>::Iter  exI ;
   std::ifstream   is ;
   hzChain::Iter   ci ;
   hzChain::Iter   xi ;
   hzChain     nodeContent ;
   hzXmlNode*  pCN = 0;
   hzXmlNode*  pNN ;
   hzString    Test ;
   hzString    tagval ;
   uint32_t    tagstate ;
   bool        bNewline ;
   hzEcode     rc = E_OK ;
   m_Error.Clear() ;
   ci = Z ;
   for (; *ci & 0x80;ci++);
   if (ci == "<?xml")
   {
       for (ci++ ; *ci != CHAR_MORE ; ci++) ;
       for (ci++ ; *ci <&eq; CHAR_SPACE ; ci++) ;
   }
   if (ci.Equiv("<!doctype"))
   {
       for (ci += 9; *ci && *ci <&eq; CHAR_SPACE ; ci++) ;
       tagstate = 1;
       for (; tagstate && *ci ; ci++)
       {
           if (*ci == CHAR_LESS)   tagstate++ ;
           if (*ci == CHAR_MORE)   tagstate-- ;
       }
   }
   /*
   **  ** Process document
   **      */
   bNewline = true ;
   for (; !ci.eof() ;)
   {
       if (*ci == CHAR_CR)
           ci++ ;
       if (*ci == CHAR_NL)
           { bNewline = true ; ci++ ; continue ; }
       if (bNewline)
       {
           if (pCN && nodeContent.Size())
               nodeContent.AddByte(CHAR_NL) ;
           bNewline = false ;
       }
       if (!pCN)
       {
           if (*ci != CHAR_LESS)
           {
               m_Error.Printf("File %s Line %d: Encountered char (%c:%d) outside scope of any tag\n", *m_Filename, ci.Line(), *ci, *ci) ;
               rc = E_SYNTAX ;
               break ;
           }
       }
       if (*ci == CHAR_LESS)
       {
           if (ci == "<!--")
           {
               for (ci += 4; !ci.eof() ; ci++)
               {
                   if (*ci == CHAR_MINUS && ci == "-->")
                       break ;
               }
               if (ci.eof())
               {
                   m_Error.Printf("File %s Line %d: HTML comment block begins which is not terminated\n", *m_Filename, ci.Line()) ;
                   rc = E_SYNTAX ;
                   break ;
               }
               ci += 3;
               continue ;
           }
           if (ci == "<![CDATA[")
           {
               xi = ci ;
               for (xi += 9; !xi.eof() ; xi++)
               {
                   if (xi == "]]>")
                       { xi += 3; ci = xi ; break ; }
                   nodeContent.AddByte(*xi) ;
               }
               pCN->SetCDATA(nodeContent) ;
               nodeContent.Clear() ;
               continue ;
           }
           if (m_bXmlesce)
           {
               if (_testHtag(tagval, ci))
               {
                   nodeContent << *tagval ;
                   ci += tagval.Length() ;
                   continue ;
               }
           }
           if (pCN && pCN->IsXmlesce())
           {
               if (_testHtag(tagval, ci))
               {
                   threadLog("m_bXmlesce is on node=%s\n", *tagval) ;
                   nodeContent << *tagval ;
                   ci += tagval.Length() ;
                   continue ;
               }
           }
           /*
           **  ** Handle tag open
           **                */
           tagstate = _proctagopen(&pNN, pCN, ci) ;
           if (tagstate < 0)
               { m_Error.Printf("File %s Line %d: Bad tag format\n", *m_Filename, ci.Line()) ; break ; }
           if (tagstate == 0)
           {
               if (pNN)
               {
                   if (nodeContent.Size())
                       pNN->SetPretext(nodeContent) ;
                   nodeContent.Clear() ;
                   pCN = pNN ;
                   if (!m_pRoot)
                   {
                       m_pRoot = pNN ;
                   }
                   m_NodesName.Insert(pNN->txtName(), pNN->GetUid()) ;
               }
               ci++ ;
               continue ;
           }
           if (tagstate == 1)
           {
               if (pNN)
               {
                   if (nodeContent.Size())
                       pNN->SetPretext(nodeContent) ;
                   nodeContent.Clear() ;
                   if (!m_pRoot)
                   {
                       m_pRoot = pNN ;
                   }
                   m_NodesName.Insert(pNN->txtName(), pNN->GetUid()) ;
               }
               ci++ ;
               continue ;
           }
           rc = E_OK ;
           /*
           **  ** Handle tag close
           **                */
           if (_istagclose(Test, ci))
           {
               if (Test != pCN->txtName())
               {
                   m_Error.Printf("File %s Line %d: Mismatched XML tags: Current <%s> line %d closing <%s>", *m_Filename, ci.Line(), pCN->txtName(), pCN->Line(), *Test) ;
                   rc = E_FORMAT ;
                   break ;
               }
               if (nodeContent.Size())
                   pCN->SetContent(nodeContent) ;
               nodeContent.Clear() ;
               pCN->_setanti(ci.Line()) ;
               pCN = pCN->Parent() ;
               if (pCN == 0)
                   break ;
               ci++ ;
               continue ;
           }
       }
       if (pCN == 0)
           break ;
       if (*ci == CHAR_TAB)
           nodeContent.AddByte(CHAR_SPACE) ;
       else
           nodeContent.AddByte(*ci) ;
       ci++ ;
   }
   if (pCN)
   {
       m_Error.Printf("File %s Line %d: End of file encountered whilst inside tag definition\n", *m_Filename, ci.Line()) ;
       rc = E_FORMAT ;
   }
   return rc ;
}