Quick Links: |
Provide a mechanism for easily creating bdld::Datum
objects.
More...
Namespaces | |
namespace | bdld |
bdld::Datum
objects. bdld::DatumMaker | a mechanism for easily creating bdld::Datum objects |
DatumMaker
that allows bdld::Datum
objects to be created with minimal syntax. numCount
, that returns the number of numeric elements in a bdld::Datum
array. bdld::Datum numCount(const bdld::Datum arrray) { bdld::DatumArrayRef aRef = arrray.theArray(); int count = 0; for (bdld::DatumArrayRef::SizeType i = 0; i < aRef.length(); ++i) { if (aRef[i].isInteger() || aRef[i].isInteger64() || aRef[i].isDouble()) { ++count; } } return bdld::Datum::createInteger(count); }
numCount
, we define a bdld::DatumMaker
, and use it to initialize an array to test numCount
: bdld::DatumMaker m(&sa);
numCount
: bdld::Datum array = m.a( m(), m(bdld::DatumError(-1)), m.a( m(true), m(false)), m(42.0), m(false), m(0), m(true), m(bsls::Types::Int64(424242)), m.m( "firstName", "Bart", "lastName", "Simpson", "age", 10 ), m(bdlt::Date(2016, 10, 14)), m(bdlt::Time(13, 00, 00, 000)), m(bdlt::Datetime(2016, 10, 14, 13, 01, 30, 87)), m(bdlt::DatetimeInterval(280, 13, 41, 12, 321)), m("foobar") );
bdld::Datum retVal = numCount(array);
assert(retVal.theInteger() == 3);