Outline
Purpose
Provide a mechanism for easily creating bdld::Datum
objects.
Classes
- See also
Description
This component defines a concrete mechanism, DatumMaker
that allows bdld::Datum
objects to be created with minimal syntax.
Usage
This section illustrates intended use of this component.
Example 1: Testing of a function
Suppose we want to test a function, numCount
, that returns the number of numeric elements in a bdld::Datum
array.
First we implement the function:
{
int count = 0;
if (aRef[i].isInteger() ||
aRef[i].isInteger64() ||
aRef[i].isDouble()) {
++count;
}
}
}
Definition bdld_datum.h:2461
size_type length() const
Return a const pointer to the length of the array.
Definition bdld_datum.h:4886
Datum::SizeType SizeType
Definition bdld_datum.h:2485
Definition bdld_datum.h:787
DatumArrayRef theArray() const
Definition bdld_datum.h:4257
static Datum createInteger(int value)
Return, by value, a datum having the specified int value.
Definition bdld_datum.h:3848
Then, within the test driver for numCount
, we define a bdld::DatumMaker
, and use it to initialize an array to test numCount
:
Definition bdld_datummaker.h:158
Here, we create the array we want to use as an argument to numCount
:
m(),
m.a(
m(true),
m(false)),
m(42.0),
m(false),
m(0),
m(true),
m.m(
"firstName", "Bart",
"lastName", "Simpson",
"age", 10
),
m("foobar")
);
Definition bdld_datumerror.h:160
Definition bdlt_date.h:294
Definition bdlt_datetimeinterval.h:201
Definition bdlt_datetime.h:331
Definition bdlt_time.h:196
long long Int64
Definition bsls_types.h:132
Next we call the function with the array-Datum
as its first argument:
Finally we verify the return value:
int theInteger() const
Definition bdld_datum.h:4426