Check Class Description With the class initialized, it is possible to check that a class description in a delta or other repository file, matches the class. The description is supplied as a hzChain which is obtained by reading the file or file header. This function loads the hzChain into an XML document and then extracts tags describing the class and its members. Write out XML fragment describing the data class to the supplied chain. Note that as the class description is likely to be part of an Application Delta Profile, the supplied chain is not pre-cleared by this function. Read a <class> tag on behalf of the hdbADProfile::Import function.

Return TypeFunction nameArguments
hzEcodehdbClass::DescCheck(hzChain&,hzChain&,)

Declared in file: hzDatabase.h
Defined in file : hdbClass.cpp

Function Logic:

0:START 1:rc 2:unknown 3:items 4:Return rc 5:pRoot 6:unknown 7:items 8:Return E_CONFIG 9:unknown 10:items 11:Return E_CONFIG 12:cname 13:str_id 14:unknown 15:unknown 16:str_id 17:ai.NameEQ(name) 18:cname 19:rc items 20:unknown 21:items 22:unknown 23:items 24:unknown 25:items 26:unknown 27:items 28:unknown 29:items 30:unknown 31:unknown 32:items 33:str_nam 34:str_sub 35:str_typ 36:str_max 37:str_min 38:str_uid 39:str_id 40:unknown 41:unknown 42:str_id 43:ai.NameEQ(uid) 44:str_uid 45:ai.NameEQ(min) 46:str_min 47:ai.NameEQ(max) 48:str_max 49:ai.NameEQ(datatype) 50:str_typ 51:ai.NameEQ(subclass) 52:str_sub 53:ai.NameEQ(name) 54:str_nam 55:items 56:unknown 57:items 58:unknown 59:items 60:unknown 61:items 62:unknown 63:items 64:unknown 65:items 66:unknown 67:items 68:unknown 69:items 70:unknown 71:items 72:unknown 73:items 74:unknown 75:str_typ 76:pType 77:unknown 78:items 79:unknown 80:Return E_FORMAT 81:Return E_OK

Function body:

hzEcode hdbClass::DescCheck (hzChain& report)hzChain& desc, 
{
   //  Check Class Description
   //  
   //  With the class initialized, it is possible to check that a class description in a delta or other repository file, matches the class. The description is
   //  supplied as a hzChain which is obtained by reading the file or file header. This function loads the hzChain into an XML document and then extracts tags
   //  describing the class and its members.
   //  
   //  Write out XML fragment describing the data class to the supplied chain. Note that as the class description is likely to be part of an Application Delta
   //  Profile, the supplied chain is not pre-cleared by this function.
   //  
   //  Arguments: 1) report To report errors
   //     2) desc The supplied description
   //  
   //  Returns: E_FORMAT If there are ANY descrepancies (details in report)
   //     E_OK  If the description matches the class
   //  
   //  Read a <class> tag on behalf of the hdbADProfile::Import function.
   _hzfunc("hdbClass::DescCheck") ;
   const hdbDatatype*  pType ;     //  Data type
   hzDocXml        doc ;           //  XML document
   hzXmlNode*      pRoot ;         //  XML root node
   hzXmlNode*      pN2 ;           //  Second level node
   hzAttrset       ai ;            //  Attribute iterator
   hzString        cname ;         //  Class name
   hzString        str_id ;        //  Member id
   hzString        str_uid ;       //  Member uid
   hzString        str_min ;       //  Member minPop
   hzString        str_max ;       //  Member minPop
   hzString        str_typ ;       //  Member data type
   hzString        str_sub ;       //  Member sub class
   hzString        str_nam ;       //  Member name
   hzEcode         rc = E_OK ;     //  Return code
   int64_t         n ;             //  Integer test value
   //  Load description into XML doc
   rc = doc.Load(desc) ;
   if (rc != E_OK)
       { report << "Could not load XML document with supplied description\n" ; return rc ; }
   pRoot = doc.GetRoot() ;
   if (!pRoot)
       { report << "No XML root found in supplied description\n" ; return E_CONFIG ; }
   if (!pRoot->NameEQ("class"))
       { report << "Expected first tag of <class>\n" ; return E_CONFIG ; }
   //  Obtain <class> attributes
   str_id = cname = (char*) 0;
   for (ai = pRoot ; ai.Valid() ; ai.Advance())
   {
       if      (ai.NameEQ("id"))   str_id = ai.Value() ;
       else if (ai.NameEQ("name")) cname = ai.Value() ;
       else
           { rc = E_CONFIG ; report.Printf("Line %d: <class> bad param %s=%s\n", pRoot->Line(), ai.Name(), ai.Value()) ; break ; }
   }
   //  Check class name and id
   if (!cname)
       report << "No class name supplied\n" ;
   else
   {
       if (cname != m_Typename)
           report.Printf("Name mismatch. Class actual name is %s. Description names class as %s.\n", *m_Typename, *cname) ;
   }
   if (!str_id)
       report << "No class id supplied\n" ;
   else
   {
       if (!IsInteger(n, *str_id))
           report.Printf("Illegal Class ID: Must be integer. (%s)\n", *str_id) ;
       if (n != m_ClassUID)
           report.Printf("Class Delta ID mismatch. Class actual %d: Description id is %s\n", m_ClassUID, *str_id) ;
   }
   //  Read in members
   for (pN2 = pRoot->GetFirstChild() ; pN2 ; pN2 = pN2->Sibling())
   {
       if (!pN2->NameEQ("member"))
           { report.Printf("<class> only <member> allowed. %s unexpected\n", pN2->txtName()) ; continue ; }
       str_id = str_uid = str_min = str_max = str_typ = str_sub = str_nam = (char*) 0;
       //  Read in member parameters
       for (ai = pN2 ; ai.Valid() ; ai.Advance())
       {
           if      (ai.NameEQ("posn"))     str_id = ai.Value() ;
           else if (ai.NameEQ("uid"))      str_uid = ai.Value() ;
           else if (ai.NameEQ("min"))      str_min = ai.Value() ;
           else if (ai.NameEQ("max"))      str_max = ai.Value() ;
           else if (ai.NameEQ("datatype")) str_typ = ai.Value() ;
           else if (ai.NameEQ("subclass")) str_sub = ai.Value() ;
           else if (ai.NameEQ("name"))     str_nam = ai.Value() ;
           else
               report.Printf("Line %d: <member> bad param %s=%s\n", pN2->Line(), ai.Name(), ai.Value()) ;
       }
       if (!str_id)    report.Printf("No member position suplied (line %d)\n", pN2->Line()) ;
       if (!str_uid)   report.Printf("No member UID suplied (line %d)\n", pN2->Line()) ;
       if (!str_min)   report.Printf("No member min pop suplied (line %d)\n", pN2->Line()) ;
       if (!str_max)   report.Printf("No member max pop suplied (line %d)\n", pN2->Line()) ;
       if (!str_nam)   report.Printf("No member name suplied (line %d)\n", pN2->Line()) ;
       if (!IsInteger(n, *str_id))     report.Printf("Illegal member position: Must be integer 0+ (line %d)\n", pN2->Line()) ;
       if (!IsInteger(n, *str_uid))    report.Printf("Illegal member ID: Must be integer 0+ (line %d)\n", pN2->Line()) ;
       if (!IsInteger(n, *str_min))    report.Printf("Illegal member min-POP: Must be integer 0+ (line %d)\n", pN2->Line()) ;
       if (!IsInteger(n, *str_max))    report.Printf("Illegal member max-POP: Must be integer 0+ (line %d)\n", pN2->Line()) ;
       if (!str_typ)
           str_typ = str_sub ;
       pType = m_pADP->GetDatatype(str_typ) ;
       if (!pType)
           report.Printf("<member> No such data type or sub-class as %s\n", pN2->Line(), *str_typ) ;
   }
   if (report.Size())
       return E_FORMAT ;
   return E_OK ;
}