Space-efficient discriminated union holding a scalar or aggregate of Datum values.
Declared in <bdld_datum.h>
class Datum;
This class implements a mechanism that provides a space-efficient discriminated union that holds the value of ether scalar type or an aggregate of Datum objects. The size of Datum is 8 bytes (same as a double) on 32-bit platforms and 16 bytes on 64-bit platforms. Separate representation are needed on 32 and 64 bit platforms because of the differing size of a pointer (a 64-bit pointer cannot reasonably be held in a 32-bit footprint).
Representation on a 32-bit Platforms: Values are stored inside an 8-byte unsigned char array (d_data). Any double value (including NaN and infinity values) can be stored inside Datum. When storing a value of a type other than double, the bits in d_data that correspond to the exponent part of a double value are set to 1, with the 4 bits in the fraction part used to indicate the type of value stored.
Representation on 64-bit platforms: Values are stored inside a 16 byte unsigned char array (d_data) to store values. The type information is stored in the upper 2 bytes of the character array. Remaining 14 bytes are used to store the actual value or the pointer to the external memory that holds the value.
For details on the internal representations that are used for various types on 32 and 64 bit platforms, please see the implementation notes in bdld_datum.cpp.
Datum objects are bitwise copyable and have trivial initialization, assignment and destruction. Only one of the copies of the same Datum object can be passed to destroy. The rest of those copies then become invalid and it is undefined behavior to deep-copy or destroy them. Although, these copies can be used on the left hand side of assignment.
| Name | Description |
|---|---|
AllocatorType | This typedef is an alias for AllocatorType. |
SizeType | Unsigned integral type for capacities, key sizes, and string lengths. |
| Name | Description |
|---|---|
Unnamed enum | Number of distinct externally exposed datum types. |
DataType | Enumeration used to discriminate among the different externally- exposed types of values that can be stored inside bdld::Datum. |
| Name | Description |
|---|---|
apply | Invoke visitor on the value currently held by this object. |
clone | Return a deep copy of this datum using the specified allocator. |
isArray | Return true if this object represents an array of Datums and false otherwise. |
isBinary | Return true if this object represents a binary value and false otherwise. |
isBoolean | Return true if this object represents a boolean value and false otherwise. |
isDate | Return true if this object represents a bdlt::Date value and false otherwise. |
isDatetime | Return true if this object represents a bdlt::Datetime value and false otherwise. |
isDatetimeInterval | Return true if this object represents a bdlt::DatetimeInterval value and false otherwise. |
isDecimal64 | Return true if this object represents a bdlfpd::Decimal64 value and false otherwise. |
isDouble | Return true if this object represents a double value and false otherwise. |
isError | Return true if this object represents a DatumError value and false otherwise. |
isExternalReference | Return whether this object refers to externally managed data. |
isIntMap | Return true if this object represents a map of datums that are keyed by 32-bit int values and false otherwise. |
isInteger | Return true if this object represents an integer value and false otherwise. |
isInteger64 | Return true if this object represents a Int64 value and false otherwise. |
isMap | Return true if this object represents a map of datums that are keyed by string values and false otherwise. |
isNull | Return true if this object represents no value and false otherwise. |
isString | Return true if this object represents a string value and false otherwise. |
isTime | Return true if this object represents a bdlt::Time value and false otherwise. |
isUdt | Return true if this object represents a DatumUdt value and false otherwise. |
print | Format this object to the specified output stream. |
theArray | Return the array value held by this object. |
theBinary | Return the binary reference held by this object. |
theBoolean | Return the boolean value represented by this object. The behavior is undefined unless this object actually represents a bool value. |
theDate | Return the date value represented by this object as a bdlt::Date object. The behavior is undefined unless this object actually represents a date value. |
theDatetime | Return the datetime value held by this object. |
theDatetimeInterval | Return the datetime-interval value held by this object. |
theDecimal64 | Return the Decimal64 value held by this object. |
theDouble | Return the double value held by this object. |
theError | Return the error value represented by this object as a DatumError value. The behavior is undefined unless this object actually represents an error value. |
theIntMap | Return the int-map value held by this object. |
theInteger | Return the integer value represented by this object. The behavior is undefined unless this object actually represents an integer value. |
theInteger64 | Return the 64-bit integer value held by this object. |
theMap | Return the map value represented by this object as a DatumMapRef object. The behavior is undefined unless this object actually represents a map of datums. |
theString | Return the string value held by this object. |
theTime | Return the time value represented by this object as a bdlt::Time object. The behavior is undefined unless this object actually represents a time value. |
theUdt | Return the user-defined type reference held by this object. |
type | Return the type of value represented by this object as one of the enumeration values defined in DataType. |
operator BloombergLP::bslmf::NestedTraitDeclaration<Datum, HasPrintMethod> | Declare nested type traits for this type. |
| Name | Description |
|---|---|
adoptArray | Return a datum that takes ownership of the specified array. |
adoptIntMap | Return a datum that takes ownership of the specified intMap. |
adoptMap | adoptMap overloads |
adoptMapOwningKeys | DEPRECATED: Use adoptMap instead. |
copyBinary | Return a datum owning a copy of the specified binary value. |
copyString | copyString overloads |
createArrayReference | createArrayReference overloads |
createBoolean | Return a datum holding the specified boolean value. |
createDate | Return a datum holding the specified date value. |
createDatetime | Return a datum holding the specified datetime value. |
createDatetimeInterval | Return a datum holding the specified datetime-interval value. |
createDecimal64 | Return a datum holding the specified Decimal64 value. |
createDouble | Return a datum holding the specified double value. |
createError | createError overloads |
createInteger | Return a datum holding the specified integer value. |
createInteger64 | Return a datum holding the specified 64-bit integer value. |
createNull | Return, by value, a datum having no value. |
createStringRef | createStringRef overloads |
createTime | Return a datum holding the specified time value. |
createUdt | Return a datum holding a user-defined type reference. |
createUninitializedArray | Create an uninitialized datum array and load a reference into result. |
createUninitializedBinary | Create an uninitialized binary buffer and load a datum referring to it. |
createUninitializedIntMap | Create an uninitialized datum int-map and load a reference into result. |
createUninitializedMap | createUninitializedMap overloads |
createUninitializedMapOwningKeys | DEPRECATED: Use createUninitializedMap instead. |
createUninitializedString | Create an uninitialized string buffer and load a datum referring to it. |
dataTypeToAscii | Return the ASCII name corresponding to the specified type. |
destroy | Destroy value and deallocate any memory it owns via allocator. |
disposeUninitializedArray | Deallocate the storage of an uninitialized array without destroying elements. |
disposeUninitializedIntMap | Deallocate the storage of an uninitialized int-map without destroying entries. |
disposeUninitializedMap | disposeUninitializedMap overloads |
disposeUninitializedMapOwningKeys | DEPRECATED: Use disposeUninitializedMap instead. |
| Name | Description |
|---|---|
d_as [variant member] | Typed access to the datum representation. |
d_data [variant member] | Raw storage for the datum representation. |
| Name | Description |
|---|---|
BloombergLP::bdld::operator<< | Write the specified rhs datum to the specified output stream. |
BloombergLP::bdld::operator!= | Return whether lhs and rhs represent different values. |
BloombergLP::bdld::operator== | Return whether lhs and rhs represent the same value. |