CSPStoreObject *CSPStore::CreateObject(FLMUNICODE *pName, FLMUNICODE *pId, FLMUNICODE *pType, FLMBOOL *pNewObject, FLMINT flmId) { FlmRecord *pRec = NULL; CSPStoreObject *pObject = NULL; // Make sure the object does not exist. pRec = FindObject(pId); if (pRec) { //if (openExisting) { FLMUINT drn = pRec->getID(); pRec->clear(); pRec->setID(drn); pObject = new CSPStoreObject(this, pName, pId, pType, pRec); *pNewObject = 0; } //else //{ // pRec->Release(); // pRec = NULL; // return (pObject); //} } else { pObject = new CSPStoreObject(this, pName, pId, pType, flmId); *pNewObject = 1; } return (pObject); } // CSPStore::CreateObject()
/******************************************************************** Desc: *********************************************************************/ RCODE gigaMakeNewRecord( FlmRecord ** ppRecord) { RCODE rc = NE_FLM_OK; FlmRecord * pRecord = NULL; void * pvField; if( *ppRecord && !(*ppRecord)->isReadOnly()) { f_assert( (*ppRecord)->getRefCount() == 1); pRecord = *ppRecord; *ppRecord = NULL; pRecord->clear(); } else { if( (pRecord = f_new FlmRecord) == NULL) { rc = RC_SET( NE_FLM_MEM); goto Exit; } } if( RC_BAD( rc = pRecord->insertLast( 0, PERSON_TAG, FLM_TEXT_TYPE, NULL))) { goto Exit; } if( RC_BAD( rc = pRecord->insertLast( 1, FIRST_NAME_TAG, FLM_TEXT_TYPE, &pvField))) { goto Exit; } if( RC_BAD( rc = pRecord->setNative( pvField, *gv_ppszCurrGiven))) { goto Exit; } if( RC_BAD( rc = pRecord->insertLast( 1, LAST_NAME_TAG, FLM_TEXT_TYPE, &pvField))) { goto Exit; } if( RC_BAD( rc = pRecord->setNative( pvField, *gv_ppszCurrFamily))) { goto Exit; } if( RC_BAD( rc = pRecord->insertLast( 1, AGE_TAG, FLM_NUMBER_TYPE, &pvField))) { goto Exit; } if( RC_BAD( rc = pRecord->setUINT( pvField, f_getRandomUINT32( 1, 100)))) { goto Exit; } if( *ppRecord) { (*ppRecord)->Release(); } *ppRecord = pRecord; pRecord = NULL; gv_ppszCurrGiven++; if( *gv_ppszCurrGiven == NULL) { gv_ppszCurrGiven = &gv_pszGivenNames [0]; gv_ppszCurrFamily++; if (*gv_ppszCurrFamily == NULL) { gv_ppszCurrFamily = &gv_pszFamilyNames[0]; } } Exit: if( pRecord) { pRecord->Release(); } return( rc); }