Esempio n. 1
0
RCODE CSPDB::RegisterField(HFDB hFlaim, FLMUNICODE *pFieldName, FLMUINT flmType, FLMUINT* pFieldId)
{
	RCODE				rc = FERR_OK;
	FlmRecord			*pRec = NULL;
	void				*pvField = 0;

	pRec = new FlmRecord();
	if (pRec != NULL)
	{
		rc = pRec->insertLast(0, FLM_FIELD_TAG, FLM_TEXT_TYPE, &pvField);
		if (RC_OK(rc))
		{
			rc = pRec->setUnicode(pvField, (FLMUNICODE*)pFieldName);
			if (RC_OK(rc))
			{
				rc = pRec->insert(pvField, INSERT_LAST_CHILD, FLM_TYPE_TAG, FLM_TEXT_TYPE, &pvField);
				if (RC_OK(rc))
				{
					if (flmType != FLM_UNDEFINED_TYPE)
					{
						rc = pRec->setUnicode(pvField, (FLMUNICODE*)cs_flaim_type_name[flmType]);
						if (RC_OK(rc))
						{
							rc = FlmRecordAdd(hFlaim, FLM_DICT_CONTAINER, pFieldId, pRec, 0);
							if (RC_OK(rc))
							{
								rc = m_NameTable.addTag((FLMUNICODE*)pFieldName, 0, *pFieldId, 0, 0, TRUE);
							}
						}
					}
					else
					{
						rc = FERR_BAD_FIELD_TYPE;
					}
				}
			}
		}
		pRec->Release();
	}
	else
	{
		rc = FERR_MEM;
	}

	return (rc);
} // CSPDB::registerField()
Esempio n. 2
0
RCODE CSPDB::AddIndex(HFDB hFlaim, FLMUNICODE *pFieldName, FLMUINT fieldId)
{
	RCODE			rc = FERR_OK;
	FlmRecord		*pRec = NULL;
	void			*pvIndex;
	void			*pvField = 0;
	void			*pvKey = 0;
	FLMUNICODE*		pIndexName;
	int				nameLen;
	int				buffLen;
	FLMUINT			indexId = 0;
	
 	pRec = new FlmRecord();
 	if (pRec != NULL)
 	{
 		// Add the index.
 		rc = pRec->insertLast(0, FLM_INDEX_TAG, FLM_TEXT_TYPE, &pvIndex);
 		if (RC_OK(rc))
 		{
			// Create the index name.
			nameLen = f_unilen(pFieldName);
			buffLen = nameLen + sizeof(nameSuffex) + 1;
			pIndexName = new FLMUNICODE[buffLen];
			if (pIndexName)
			{
				f_unicpy(pIndexName, pFieldName);
				f_unicpy(pIndexName + nameLen, (FLMUNICODE*)nameSuffex);
				rc = pRec->setUnicode(pvIndex, (FLMUNICODE*)pIndexName);
				if (RC_OK(rc))
				{
					// Add the key.
					rc = pRec->insert(pvIndex, INSERT_LAST_CHILD, FLM_KEY_TAG, FLM_TEXT_TYPE, &pvKey);
					if (RC_OK(rc))
					{
						// Add the collection
						rc = pRec->insert(pvKey, INSERT_LAST_CHILD, FLM_FIELD_TAG, FLM_NUMBER_TYPE, &pvField);
						if (RC_OK(rc))
						{
							rc = pRec->setINT(pvField, CS_Id_CollectionId);
						}
						// Add the field.
						rc = pRec->insert(pvKey, INSERT_FIRST_CHILD, FLM_FIELD_TAG, FLM_NUMBER_TYPE, &pvField);
						if (RC_OK(rc))
						{
							rc = pRec->setINT(pvField, fieldId);
							if (RC_OK(rc))
							{
								rc = FlmRecordAdd(hFlaim, FLM_DICT_CONTAINER, &indexId, pRec, 0);
								if (RC_OK(rc))
								{
									rc = m_NameTable.addTag((FLMUNICODE*)pIndexName, 0, indexId, 0, 0, TRUE);
								}
							}
						}
						else
						{
							rc = FERR_BAD_FIELD_TYPE;
						}
					}
				}
				delete [] pIndexName;
			}
 		}
 	  	pRec->Release();
 	}
 	else
 	{
 		rc = FERR_MEM;
 	}

	return (rc);
} // CSPDB::AddIndex()