Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

CTResource::Add

Add a new resource to a table.

Declaration

void CTResource::Add(pVOID data, VRLEN size);

Description

The resource data is any collection of data that you wish to store as a Resource. It can be a character string, a structure, or any variable type. size indicate the number of bytes occupied by data.

Adds a new resource to a table. When adding a Resource to a table, a special variable-length record is written to the table, containing the information from the Resource Data Block. This is done even if a data file uses fixed-length records. Every Resource is identified by a unique combination of a Resource Type and a Resource Number. The Resource Number can optionally be assigned by c-tree Plus during the call to CTResource::Add(). In addition, each Resource can be identified by a Resource Name. The Resource Name is not guaranteed to be unique.

The Resource Type must be a value greater than 65536. 0 through 65536 are reserved for FairCom use. If the Resource Number is a value of CTDB_ASSIGN_RESOURCE_NUMBER (0xffffffff), c-tree Plus assigns this Resource the next available Resource Number for this Resource Type in the specified data file. The assigned number can be retrieved by calling ctdbGetResourceNumber before the resource handle is released. The Resource Name is optional. Names starting with "FC!" or "RD!", are reserved for FairCom use.

Return

None

Example


void AddMyResource(const CTTable& hTable, ULONG type, const CTString& name, pVOID data, VRLEN size)

{

CTResource* hRes = new CTResource(hTable, type, CTDB_ASSIGN_RESOURCE_NUMBER, name);


try

{

hRes->Add(data, size)

printf("Resource added with number %u\n", hRes->GetNumber());

}

catch (CTException &err)

{

printf("Error %d - %s\n", err.GetErrorCode(), err.GetErrorMsg());

}

delete hRes;

}

See Also

CTResource::Delete(), CTResource::Update(), CTResource::First(), CTResource::Next(), CTResource::Find(), CTResource::GetType(), CTResource::SetType(), CTResource::GetNumber(), CTResource::SetNumber(), CTResource::GetName(), CTResource::SetName(), CTResource::GetDataLength(), CTResource::GetData(), CTResource::SetData(), CTResource::Unlock(), CTResource::IsLocked()

TOCIndex