| Return Type | Function name | Arguments |
|---|---|---|
| hdbBasetype | hdsApp::PcEntTest | (hzString&,hdsFormdef*,const hdbClass*,const hzString&,) |
Declared in file: hzDissemino.h
Defined in file : hdsSystem.cpp
Function Logic:
Function body:
hdbBasetype hdsApp::PcEntTest (hzString& err, hdsFormdef* pFormdef, const hdbClass* pHost, const hzString& pcntEnt)
{
_hzfunc("hdsApp::PcEntTest") ;
const hdbClass* pUC ;
const hdbMember* pMbr ;
hdbObjRepos* pRepos = 0;
hdsPage* pPage = 0;
hdsField* pFld ;
hzChain W ;
hzChain erep ;
hzAtom atom ;
const char* i ;
hzString w ;
hzString extn ;
hzString val ;
uint32_t srcInd ;
uint32_t n ;
hdbBasetype dt ;
hzEcode rc = E_OK ;
err.Clear() ;
if (!pcntEnt)
{ err = "null entity" ; return BASETYPE_UNDEF ; }
i = *pcntEnt ;
if (*i != CHAR_PERCENT)
{
erep.Printf("Literal value %s not allowed", *pcntEnt) ;
err = erep ;
return BASETYPE_UNDEF ;
}
i++ ;
srcInd = *i ;
if (srcInd != ''x''&&srcInd != ''u''&&srcInd != ''s''&&srcInd != ''e''&&srcInd != ''i''&&srcInd != ''v'')
{ err = "Invalid percent entity class" ; return BASETYPE_UNDEF ; }
i++ ;
if (*i != CHAR_COLON)
{ err = "Missing colon after percent entity class" ; return BASETYPE_UNDEF ; }
for (i++ ; *i && *i != CHAR_SCOLON && IsAlphanum(*i) ; i++)
W.AddByte(*i) ;
w = W ;
W.Clear() ;
if (*i == CHAR_PERIOD)
{
for (i++ ; *i && *i != CHAR_SCOLON && IsAlphanum(*i) ; i++)
W.AddByte(*i) ;
extn = W ;
W.Clear() ;
}
if (*i != CHAR_SCOLON)
{ erep.Printf("PcEntTest: Missing semicolon after percent entity variable name (%s), char is [%c]", *pcntEnt, *i) ; err = erep ; return BASETYPE_UNDEF ; }
i++ ;
dt = BASETYPE_UNDEF ;
if (!pHost)
{
if (pFormdef)
pHost = pFormdef->m_pClass ;
}
switch (srcInd)
{
case ''x'':
if (w == "count" || w == "objid")
{
pRepos = m_ADP.GetObjRepos(extn) ;
if (!pRepos)
{ rc = E_NOTFOUND ; erep.Printf("%s is not a declared repository", *extn) ; }
else
dt = BASETYPE_INT32 ;
break ;
}
if (w == "date") { dt = BASETYPE_SDATE ; break ; }
if (w == "time") { dt = BASETYPE_TIME ; break ; }
if (w == "datetime") { dt = BASETYPE_XDATE ; break ; }
if (w == "referer") { dt = BASETYPE_URL ; break ; }
if (w == "usecs") { dt = BASETYPE_UINT32 ; break ; }
if (w == "random") { dt = BASETYPE_STRING ; break ; }
if (w == "uid") { dt = BASETYPE_INT32 ; break ; }
if (w == "user") { dt = BASETYPE_STRING ; break ; }
rc = E_RANGE ;
erep.Printf("Invalid system entity (%s)", *w) ;
break ;
case ''u'':
if (!pFormdef)
{ rc = E_ARGUMENT ; erep.Printf("All user variables must occur within a form lying in a page accessable to logged on users") ; break ; }
if (!m_ADP.m_pReposSubscriber)
{ rc = E_RANGE ; erep.Printf("Subscriber Repository not invoked - No users\n") ; break ; }
pMbr = m_ADP.m_pClassSubscriber->GetMember(w) ;
if (pMbr)
{ dt = pMbr->Basetype() ; break ; }
for (n = 0; rc == E_OK && n < m_UserTypes.Count() ; n++)
{
val = m_UserTypes.GetKey(n) ;
pUC = m_ADP.GetPureClass(val) ;
if (!pUC)
Fatal("No such user class as %s\n", *val) ;
if (pPage->m_resAccess & m_UserTypes.GetObj(n))
{
pMbr = pUC->GetMember(w) ;
if (pMbr)
dt = pMbr->Basetype() ;
else
{
rc = E_ARGUMENT ;
erep.Printf("User variable %s not a member of user class %s and yet this class of user can access the page", *w, pUC->txtType()) ;
}
}
}
break ;
case ''s'':
if (!m_tmpVarsSess.Exists(w))
{ rc = E_RANGE ; erep.Printf("%s is not in scope", *w) ; }
dt = m_tmpVarsSess[w] ;
break ;
case ''e'':
if (pFormdef)
{
if (!pFormdef->m_mapFlds.Exists(w))
erep.Printf("Variable %s is not incident in form %s (%p)", *w, *pFormdef->m_Formname, pFormdef) ;
else
{
pFld = pFormdef->m_mapFlds[w] ;
if (pFld)
{ dt = pFld->m_Fldspec.m_pType->Basetype() ; break ; }
}
}
if (pHost)
{
pMbr = pHost->GetMember(w) ;
if (pMbr)
dt = pMbr->Basetype() ;
else
{ rc = E_RANGE ; erep.Printf("%s is not a member of class %s", *w, pHost->txtType()) ; }
break ;
}
if (!pFormdef && pHost)
erep.Printf("Variable %s cannot be tested as there is neither a host form or class", *w) ;
break ;
case ''v'':
if (!pHost)
{ rc = E_ARGUMENT ; erep.Printf("All user variables must occur within the context of a host user class") ; break ; }
pMbr = pHost->GetMember(w) ;
if (!pMbr)
{ rc = E_RANGE ; erep.Printf("%s is not a member of class %s and nor is it a freely declared variable", *w, pHost->txtType()) ; }
else
dt = pMbr->Basetype() ;
break ;
}
err = erep ;
return dt ;
}