How to choose a descriptor

How to choose a descriptor

Taken from Netqin

Image:Descriptor_flowchart.jpg

Do you need to modify the content of the description
Yes no
Whether the memory of the descriptor has been allocated Whether the memory of the descriptor has been allocated
Yes no Yes no
TPtr Can the line size be less than 256 bytes TPtrC Can the line size be less than 256 bytes
  Yes no   Yes no
  TBuf HBufC:
Use TPtr when you need to change the content
HBufC* buf=HBufC::New(1024);
TPtr temp(buf->Des());
temp.Format(_L("test"));
  TBufC HBufC

If the descriptor contains binary content, an 8-bit descriptor should be used.
If the descriptor contains wide characters, a 16-bit descriptor should be used.
Otherwise, a descriptor without a specified bit should be used.

Guess you like

Origin blog.csdn.net/windcao/article/details/1686337