Adds a member to the data class Note: This function will terminate execution if the member could not be allocated.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbClass::InitMember | (hzString&,hdbDatatype*,hdbPopCtl,) |
Declared in file: hzDatabase.h
Defined in file : hdbClass.cpp
Function Logic:
Function body:
hzEcode hdbClass::InitMember (hzString& mbrName)hdbDatatype* pType, hdbPopCtl popCtl,
{
// Adds a member to the data class
//
// Arguments: 1) mbrName Member name
// 2) type The external data type
// 3) popCtl Population restraints
//
// Returns: E_ARGUMENT If no member name is supplied
// E_DUPLICATE If a member of the supplied name already exists
// E_NOINIT If the InitStart() function has not yet been called
// E_SEQUENCE If the InitDone() function has been called
// E_OK If the member is successfully added
//
// Note: This function will terminate execution if the member could not be allocated.
_hzfunc("hdbClass::InitMember(1)") ;
const hdbClass* pSub ; // Sub-class if applicable
hdbMember* pMbr ; // The column
hzString S ; // Temp string
hzEcode rc ; // Return code
// if (m_eClassInit < 1 || m_eClassInit > 2)
if (m_eClassInit != HDB_CLASS_INIT_PROG)
return hzerr(E_INITFAIL, "Init state %d Called out of sequence (must be after InitStart() and before InitDone()", m_eClassInit) ;
// No Application Delta Profile?
if (!m_pADP)
return hzerr(E_NOINIT, "No Host ADP Found") ;
// No member name supplied?
if (!mbrName)
return hzerr(E_ARGUMENT, "No member name supplied") ;
// No member data type supplied?
if (!pType)
return hzerr(E_ARGUMENT, "No member data type supplies for %s", *mbrName) ;
// Data class member already exists?
if (GetMember(mbrName))
return hzerr(E_INITDUP, "Member (%s) already defined", *mbrName) ;
pMbr = new hdbMember() ;
if (!pMbr)
return hzerr(E_MEMORY, "Member allocation") ;
// Set up member
rc = pMbr->Init(this, pType, mbrName, m_arrMembers.Count(), popCtl) ;
if (rc != E_OK)
return hzerr(rc, "Please examine arguments for column [%s]", *mbrName) ;
m_mapMembers.Insert(mbrName, pMbr) ;
// Assign member ID
m_pADP->RegisterMember(pMbr) ;
// Put the member in the map and of columns
m_mapMembers.Insert(mbrName, pMbr) ;
m_arrMembers.Add(pMbr) ;
threadLog("Added member %s (of %d) to class %s\n", *mbrName, MbrCount(), txtType()) ;
// If member is a sub-class then put this in the m_mapSubs and all its subs
if (pMbr->IsClass())
{
pSub = (const hdbClass*) pMbr->Datatype() ;
m_pADP->NoteSub(strType(), pSub) ;
}
if (pMbr->Basetype() == BASETYPE_BINARY || pMbr->Basetype() == BASETYPE_TXTDOC)
m_nBinaries++ ;
if (pMbr->Multiple())
m_nArrays++ ;
m_eClassInit = HDB_CLASS_INIT_PROG ;
return E_OK ;
}