Provide a type to represent binary data and its size.
More...
Namespaces |
namespace | bdld |
Detailed Description
- Outline
-
-
- Purpose:
- Provide a type to represent binary data and its size.
-
- Classes:
-
- See also:
- Component bdld_datum, Component bdld_datumerror, Component bdld_datumudt
-
- Description:
- 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
.
-
- Usage:
- This section illustrates intended use of this component.
-
- Example 1: Basic DatumBinaryRef usage:
- 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:
assert(10 == processData(binaryData));
Finally, we release allocated memory: