Attributes in service records can be one of fixed number of types. The API encapsulates each attribute type in a class, each of which is derived from CSdpAttrValue
. The type is easily deducible from the name: e.g. CSdpAttrValueUint
encapsulates an unsigned integer type attribute.
Complex attribute values are stored as lists of other elements; nested lists are allowed. The list classes are:
CSdpAttrValueDEA
: a Data element alternative, a data element whose data field is
a sequence of data elements from which one data element is to be selected.
CSdpAttrValueDES
: a Data element sequence, a data element whose data field
is a sequence of data elements.
Both of these implement the MSdpElementBuilder
interface, which supplies functions of the form Build
typeL()
to add elements of the specified type to the list.
The following example builds a protocol list attribute (attribute ID 4), which is a list containing two nested lists. Note:
MSdpElementBuilder
functions are called cumulatively as part of a single statement.
The start of a list is indicated by a call to MSdpElementBuilder::StartListL()
and ended by MSdpElementBuilder::EndListL()
.
// Create list; NULL indicates that the list is not itself in another list
CSdpAttrValueDES* attrValProt = CSdpAttrValueDES::NewDESL(NULL);
CleanupStack::PushL(attrValProt);
attrValProt
->StartListL()
->BuildDESL()
->StartListL()
->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
->EndListL()
->BuildDESL()
->StartListL()
->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
->BuildUintL(TServAttrInt<TUint8>>(1)) // DLCI = 1
->EndListL()
->EndListL();