| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbClass::DescCheck | (hzChain&,hzChain&,) |
Declared in file: hzDatabase.h
Defined in file : hdbClass.cpp
Function Logic:
Function body:
hzEcode hdbClass::DescCheck (hzChain& report, hzChain& desc)
{
_hzfunc("hdbClass::DescCheck") ;
const hdbDatatype* pType ;
hzDocXml doc ;
hzXmlNode* pRoot ;
hzXmlNode* pN2 ;
hzAttrset ai ;
hzString cname ;
hzString str_id ;
hzString str_uid ;
hzString str_min ;
hzString str_max ;
hzString str_typ ;
hzString str_sub ;
hzString str_nam ;
hzEcode rc = E_OK ;
int16_t n ;
rc = doc.Load(desc) ;
if (rc != E_OK)
{ report << "Could not load XML document with supplied description\n" ; return E_SYNTAX ; }
pRoot = doc.GetRoot() ;
if (!pRoot)
{ report << "No XML root found in supplied description\n" ; return E_SYNTAX ; }
if (!pRoot->NameEQ("class"))
{ report << "Expected first tag of <class>\n" ; return E_SYNTAX ; }
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_SYNTAX ; report.Printf("Line %d: <class> bad param %s=%s\n", pRoot->Line(), ai.Name(), ai.Value()) ; break ; }
}
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) ;
}
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;
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 ;
}