Add an item. The first item should have a NULL parent

Return TypeFunction nameArguments
hzEcodehdsNavtree::AddItem(hzString&,hzString&,hzString&,hdsArticle*,bool,)

Declared in file: hzDissemino.h
Defined in file : hdsNavtree.cpp

Function Logic:

0:START 1:unknown 2:Return hzerr(E_ARGUMENT,%s: No item item id supplied,*m_Groupname) 3:unknown 4:Return hzerr(E_ARGUMENT,%s: No item headline supplied,*m_Groupname) 5:unknown 6:Return hzerr(E_DUPLICATE,%s: Duplicate entry attempted: Item %s alredy exists,*m_Groupname,*refname) 7:unknown 8:unknown 9:Return hzerr(E_CORRUPT,%s: Adding first item %s but with non-null parent,*m_Groupname,*title) 10:unknown 11:Return hzerr(E_CORRUPT,%s: Supplied parent (%s) does not exist,*m_Groupname,*parent) 12:parItem 13:items item item 14:unknown 15:item 16:item 17:unknown 18:item 19:parItem 20:item 21:rc 22:unknown 23:Return hzerr(rc,%s: Could not insert parent for article %s,*m_Groupname,*title) 24:rc 25:unknown 26:Return hzerr(rc,%s: Could not insert article %s,*m_Groupname,*title) 27:Return rc

Function body:

hzEcode hdsNavtree::AddItem (hzString& parent)hzString& refname, hzString& title, hdsArticle* pArt, bool bSlct, 
{
   //  Add an item. The first item should have a NULL parent
   //  
   //  Arguments: 1) parent Parent refname
   //     2) refname Reference name of new item
   //     3) title Title (how item appears in tree)
   //     4) pItem Tree item (if any)
   //     5) bSlct Show as open
   //  
   //  Returns: E_ARGUMENT If either the itemId or headline is not supplied
   //     E_DUPLICATE If the supplied item id already exists
   _hzfunc("hdsNavtree::AddItem") ;
   _navitem    item ;          //  New item
   _navitem    parItem ;       //  Parent item
   hzEcode     rc = E_OK ;     //  Return code
   //  Qualify item
   //  threadLog("Adding article %p %s\n", pArt, *refname) ;
   if (!refname)   return hzerr(E_ARGUMENT, "%s: No item item id supplied", *m_Groupname) ;
   if (!title)     return hzerr(E_ARGUMENT, "%s: No item headline supplied", *m_Groupname) ;
   //  Check item id (item id) is unique
   if (m_ItemsByName.Exists(refname))
       return hzerr(E_DUPLICATE, "%s: Duplicate entry attempted: Item %s alredy exists", *m_Groupname, *refname) ;
   //  If parent is supplied, it must exist
   if (parent)
   {
       if (!m_ItemsByName.Count())
           return hzerr(E_CORRUPT, "%s: Adding first item %s but with non-null parent", *m_Groupname, *title) ;
       if (!m_ItemsByName.Exists(parent))
           return hzerr(E_CORRUPT, "%s: Supplied parent (%s) does not exist", *m_Groupname, *parent) ;
       parItem = m_ItemsByName[parent] ;
   }
   //  ADD the item
   m_Articles.Add(pArt) ;
   item.m_ItemId = m_Articles.Count() ;
   item.m_Title = title ;
   if (bSlct)
       item.m_bFlags |= HZ_TREEITEM_OPEN ;
   item.m_bFlags |= HZ_TREEITEM_LINK ;
   if (!parent)
       item.m_nLevel = 0;
   else
       item.m_nLevel = parItem.m_nLevel + 1;
   rc = m_ItemsByParent.Insert(parent, refname) ;
   if (rc != E_OK)
       return hzerr(rc, "%s: Could not insert parent for article %s", *m_Groupname, *title) ;
   rc = m_ItemsByName.Insert(refname, item) ;
   if (rc != E_OK)
       return hzerr(rc, "%s: Could not insert article %s", *m_Groupname, *title) ;
   return rc ;
}