BDE 4.14.0 Production release
|
Provide a type to represent binary data and its size.
This component implements a class, bdld::DatumBinaryRef
, that represents a pointer to a non-modifiable binary data (as a void *
) and an integral size value. Note, that bdld::DatumBinaryRef
is nether a value-semantic type, nor is it an in-core value-semantic type (see bsldoc_glossary ). The bdld::DatumBinaryRef
notion of value is expressed by its equality-operator - two bdld::DatumBinaryRef
compare equal if the binary data they refer to is identical (both by size and by content). Accessors inside Datum
class that need to return a binary data, return an instance of bdld::DatumBinaryRef
.
This section illustrates intended use of this component.
Suppose we have three functions. Data are obtained in the first one (with memory allocation), processed in the second one and released (with memory deallocation) in the third one. The following code illustrates how to use bdld::DatumBinaryRef
to pass information about memory storage between them.
First, we write all three functions:
Next, we call first one to obtain data:
Then we verify the results of second one's call:
Finally, we release allocated memory: