8#ifndef INCLUDED_BDLD_DATUM
9#define INCLUDED_BDLD_DATUM
670#include <bdlscm_version.h>
679#include <bdldfp_decimal.fwd.h>
680#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
709#include <bsl_algorithm.h>
710#include <bsl_climits.h>
711#include <bsl_cstring.h>
712#include <bsl_iosfwd.h>
713#include <bsl_limits.h>
714#include <bsl_string.h>
715#include <bsl_utility.h>
717#if !defined(BSLS_PLATFORM_CPU_32_BIT) && !defined(BSLS_PLATFORM_CPU_64_BIT)
718 #error 'bdld::Datum' supports 32- or 64-bit platforms only.
722#ifdef BSLS_PLATFORM_CMP_MSVC
723 #define BDLD_DATUM_FORCE_INLINE __forceinline
725 #define BDLD_DATUM_FORCE_INLINE inline
746template <
class t_WANT_TO_BE_DEPENDENT,
class t_ALREADY_DEPENDENT>
748 typedef t_WANT_TO_BE_DEPENDENT
type;
818#ifndef BDE_OMIT_INTERNAL_DEPRECATED
844#ifndef BDE_OMIT_INTERNAL_DEPRECATED
849#ifdef BSLS_PLATFORM_CPU_32_BIT
856 enum InternalDataType {
859 , e_INTERNAL_LONGEST_SHORTSTRING = 1
860 , e_INTERNAL_BOOLEAN = 2
861 , e_INTERNAL_SHORTSTRING = 3
862 , e_INTERNAL_STRING = 4
863 , e_INTERNAL_DATE = 5
864 , e_INTERNAL_TIME = 6
865 , e_INTERNAL_DATETIME = 7
866 , e_INTERNAL_DATETIME_INTERVAL = 8
867 , e_INTERNAL_INTEGER = 9
868 , e_INTERNAL_INTEGER64 = 10
869 , e_INTERNAL_USERDEFINED = 11
870 , e_INTERNAL_ARRAY = 12
871 , e_INTERNAL_STRING_REFERENCE = 13
872 , e_INTERNAL_ARRAY_REFERENCE = 14
873 , e_INTERNAL_EXTENDED = 15
874 , e_INTERNAL_DOUBLE = 16
882 k_NUM_INTERNAL_TYPES = 17
888 enum ExtendedInternalDataType {
889 e_EXTENDED_INTERNAL_MAP = 0
892 , e_EXTENDED_INTERNAL_OWNED_MAP = 1
895 , e_EXTENDED_INTERNAL_NAN2 = 2
897 , e_EXTENDED_INTERNAL_ERROR = 3
899 , e_EXTENDED_INTERNAL_ERROR_ALLOC = 4
905 , e_EXTENDED_INTERNAL_SREF_ALLOC = 5
907 , e_EXTENDED_INTERNAL_AREF_ALLOC = 6
909 , e_EXTENDED_INTERNAL_DATETIME_ALLOC = 7
911 , e_EXTENDED_INTERNAL_DATETIME_INTERVAL_ALLOC = 8
914 , e_EXTENDED_INTERNAL_INTEGER64_ALLOC = 9
916 , e_EXTENDED_INTERNAL_BINARY_ALLOC = 10
918 , e_EXTENDED_INTERNAL_DECIMAL64 = 11
920 , e_EXTENDED_INTERNAL_DECIMAL64_SPECIAL = 12
922 , e_EXTENDED_INTERNAL_DECIMAL64_ALLOC = 13
924 , e_EXTENDED_INTERNAL_NIL = 14
926 , e_EXTENDED_INTERNAL_INT_MAP = 15
934 k_NUM_EXTENDED_INTERNAL_TYPES = 16
940 static const unsigned short k_DOUBLE_MASK = 0x7ff0U;
947 static const int k_SHORTSTRING_SIZE = 6;
951 static const int k_TYPE_MASK_BITS = 16;
955 static const short k_DATETIME_OFFSET_FROM_EPOCH = 18262;
968#ifdef BSLS_PLATFORM_IS_LITTLE_ENDIAN
970 static const int k_EXPONENT_OFFSET = 6;
973 static const int k_EXPONENT_LSB = k_EXPONENT_OFFSET;
975 static const int k_EXPONENT_MSB = k_EXPONENT_OFFSET + 1;
977 static const int k_DATA_OFFSET = 0;
980 static const int k_SHORTSTRING_OFFSET = 0;
983 static const int k_SHORT_OFFSET = 4;
989 static const int k_MASK_OFFSET = 4;
993 static const int k_NEARDATE_OFFSET = 4;
997 static const int k_TIME_OFFSET = 0;
1001 static const int k_EXPONENT_OFFSET = 0;
1004 static const int k_EXPONENT_LSB = k_EXPONENT_OFFSET + 1;
1006 static const int k_EXPONENT_MSB = k_EXPONENT_OFFSET;
1008 static const int k_DATA_OFFSET = 4;
1011 static const int k_SHORTSTRING_OFFSET = 2;
1014 static const int k_SHORT_OFFSET = 2;
1020 static const int k_MASK_OFFSET = 0;
1024 static const int k_NEARDATE_OFFSET = 2;
1028 static const int k_TIME_OFFSET = 4;
1035 e_DECIMAL64_SPECIAL_NAN,
1036 e_DECIMAL64_SPECIAL_INFINITY,
1037 e_DECIMAL64_SPECIAL_NEGATIVE_INFINITY
1043 struct ShortString5 {
1045#ifdef BSLS_PLATFORM_IS_LITTLE_ENDIAN
1048 unsigned short d_exponent;
1050 unsigned short d_exponent;
1056 struct ShortString6 {
1058#ifdef BSLS_PLATFORM_IS_LITTLE_ENDIAN
1060 unsigned short d_exponent;
1062 unsigned short d_exponent;
1067 struct TypedAccess {
1138#ifdef BSLS_PLATFORM_IS_LITTLE_ENDIAN
1145 unsigned short d_ushort;
1147 unsigned short d_exponent;
1149 unsigned short d_exponent;
1152 unsigned short d_ushort;
1161 struct ExponentAccess {
1163#ifdef BSLS_PLATFORM_IS_LITTLE_ENDIAN
1164 unsigned int d_dummy;
1165 unsigned int d_value;
1167 unsigned int d_value;
1168 unsigned int d_dummy;
1179 ShortString5 d_string5;
1181 ShortString6 d_string6;
1186 ExponentAccess d_exp;
1197 static Datum createExtendedDataObject(ExtendedInternalDataType
type,
1199 static Datum createExtendedDataObject(ExtendedInternalDataType
type,
1209 ExtendedInternalDataType extendedInternalType()
const;
1214 DataType typeFromExtendedInternalType()
const;
1222 DatumArrayRef theLongArrayReference()
const;
1244 enum InternalDataType {
1245 e_INTERNAL_UNINITIALIZED = 0,
1251 e_INTERNAL_BOOLEAN = 3,
1253 e_INTERNAL_SHORTSTRING = 4,
1255 e_INTERNAL_STRING = 5,
1257 e_INTERNAL_DATE = 6,
1259 e_INTERNAL_TIME = 7,
1261 e_INTERNAL_DATETIME = 8,
1263 e_INTERNAL_DATETIME_INTERVAL = 9,
1265 e_INTERNAL_INTEGER = 10,
1267 e_INTERNAL_INTEGER64 = 11,
1269 e_INTERNAL_USERDEFINED = 12,
1271 e_INTERNAL_ARRAY = 13,
1273 e_INTERNAL_STRING_REFERENCE = 14,
1275 e_INTERNAL_ARRAY_REFERENCE = 15,
1277 e_INTERNAL_DOUBLE = 16,
1279 e_INTERNAL_MAP = 17,
1282 e_INTERNAL_OWNED_MAP = 18,
1285 e_INTERNAL_ERROR = 19,
1287 e_INTERNAL_ERROR_ALLOC = 20,
1289 e_INTERNAL_BINARY = 21,
1291 e_INTERNAL_BINARY_ALLOC = 22,
1293 e_INTERNAL_DECIMAL64 = 23,
1295 e_INTERNAL_INT_MAP = 24
1303 k_NUM_INTERNAL_TYPES = 25
1309 static const int k_TYPE_OFFSET = 14;
1313 static const int k_SHORTSTRING_SIZE = 13;
1318 static const int k_SMALLBINARY_SIZE_OFFSET = 13;
1323 static const int k_SMALLBINARY_SIZE = 13;
1333 struct TypedAccess {
1359 static Datum createDatum(InternalDataType
type,
void *data);
1363 static Datum createDatum(InternalDataType
type,
int data);
1370 void* theInlineStorage();
1373 const void* theInlineStorage()
const;
1392 bsl::size_t nBytes)
const;
1402 bsl::size_t alignment)
const;
1407 template <
class t_TYPE>
1408 t_TYPE *allocatedPtr()
const;
1412 InternalDataType internalType()
const;
1448 bsl::size_t theMapAllocNumBytes()
const;
1449 bsl::size_t theIntMapAllocNumBytes()
const;
1450 bsl::size_t theErrorAllocNumBytes()
const;
1451 bsl::size_t theBinaryAllocNumBytes()
const;
1452 bsl::size_t theInternalStringAllocNumBytes()
const;
1453 bsl::size_t theInternalArrayAllocNumBytes()
const;
1814 template <
class t_VISITOR>
1815 void apply(t_VISITOR& visitor)
const;
2005 bsl::ostream&
print(bsl::ostream& stream,
2007 int spacesPerLevel = 4)
const;
2009#ifndef BDE_OMIT_INTERNAL_DEPRECATED
2119template <
class t_HASH_ALGORITHM>
2489 const Datum *d_data_p;
2593 int spacesPerLevel = 4) const;
2658 void setKey(
int key);
2661 void setValue(
const Datum& value);
2669 const Datum& value()
const;
2684 bsl::ostream&
print(bsl::ostream& stream,
2686 int spacesPerLevel = 4)
const;
2832 bool isSorted() const;
2857 int spacesPerLevel = 4) const;
2922 void setValue(
const Datum& value);
2930 const Datum& value()
const;
2945 bsl::ostream&
print(bsl::ostream& stream,
2947 int spacesPerLevel = 4)
const;
3095 bool isSorted() const;
3099 bool ownsKeys() const;
3124 int spacesPerLevel = 4) const;
3165 template <
class t_TYPE>
3166 static t_TYPE load(
const void *source,
int offset);
3170 template <
class t_TYPE>
3171 static t_TYPE store(
void *destination,
int offset, t_TYPE value);
3174#ifdef BSLS_PLATFORM_CPU_32_BIT
3186#ifdef BSLS_PLATFORM_IS_LITTLE_ENDIAN
3187 static const int b00 = 0;
3188 static const int b32 = 4;
3189 static const int b48 = 6;
3191 static const int b00 = 4;
3192 static const int b32 = 2;
3193 static const int b48 = 0;
3235template <
class t_TYPE>
3237t_TYPE Datum_Helpers::load(
const void *source,
int offset)
3241 return *
static_cast<const t_TYPE *
>(
3242 static_cast<const void *
>(
3243 static_cast<const char *
>(source) + offset));
3246template <
class t_TYPE>
3248t_TYPE Datum_Helpers::store(
void *destination,
int offset, t_TYPE value)
3252 return *
static_cast<t_TYPE *
>(
3253 static_cast<void *
>(
3254 static_cast<char *
>(destination) + offset)) = value;
3257#ifdef BSLS_PLATFORM_CPU_32_BIT
3269 store<short>(&value, b48, store<short>(&value, b32, high16) < 0 ? -1 : 0);
3270 store<long> (&value, b00, low32);
3283 if ((load<short>(&value, b48) == 0 && load<short>(&value, b32) >= 0) ||
3284 (load<short>(&value, b48) == -1 && load<short>(&value, b32) < 0)) {
3285 *phigh16 = load<short>(&value, b32);
3286 *plow32 = load<long> (&value, b00);
3297 store<short>(&value, b48, 0);
3298 store<short>(&value, b32, high16);
3299 store<long>(&value, b00, low32);
3312 if (load<short>(&value, b48) == 0) {
3313 *phigh16 = load<short>(&value, b32);
3314 *plow32 = load<long>(&value, b00);
3328#ifdef BSLS_PLATFORM_CPU_32_BIT
3332Datum Datum::createExtendedDataObject(ExtendedInternalDataType type,
3336 result.d_exp.d_value = (k_DOUBLE_MASK | e_INTERNAL_EXTENDED)
3337 << k_TYPE_MASK_BITS | type;
3338 result.d_as.d_cvp =
data;
3343Datum Datum::createExtendedDataObject(ExtendedInternalDataType type,
3347 result.d_exp.d_value = (k_DOUBLE_MASK | e_INTERNAL_EXTENDED)
3348 << k_TYPE_MASK_BITS | type;
3349 result.d_as.d_int =
data;
3356Datum::ExtendedInternalDataType Datum::extendedInternalType()
const
3359 return static_cast<ExtendedInternalDataType
>(d_as.d_short);
3363Datum::DataType Datum::typeFromExtendedInternalType()
const
3367 static const DataType convert[] = {
3376 , Datum::e_DATETIME_INTERVAL
3378 , Datum::e_INTEGER64
3380 , Datum::e_DECIMAL64
3381 , Datum::e_DECIMAL64
3382 , Datum::e_DECIMAL64
3388 k_NUM_EXTENDED_INTERNAL_TYPES);
3390 const ExtendedInternalDataType type = extendedInternalType();
3393 static_cast<int>(k_NUM_EXTENDED_INTERNAL_TYPES));
3395 return convert[type];
3403 extendedInternalType() == e_EXTENDED_INTERNAL_INTEGER64_ALLOC);
3404 return Datum_Helpers::load<bsls::Types::Int64>(d_as.d_cvp, 0);
3408DatumArrayRef Datum::theLongArrayReference()
const
3410 return DatumArrayRef(
3411 Datum_Helpers::load<Datum *> (d_as.d_cvp, 0),
3412 Datum_Helpers::load<SizeType>(d_as.d_cvp,
sizeof(Datum *)));
3425 Datum_Helpers::load<char *> (d_as.d_cvp, 0),
3426 Datum_Helpers::load<SizeType>(d_as.d_cvp,
sizeof(
char *)));
3433 return Datum_Helpers32::loadSmallInt64(d_as.d_short, d_as.d_int);
3440Datum Datum::createDatum(InternalDataType type,
void *data)
3443 result.d_as.d_type = type;
3444 result.d_as.d_ptr =
data;
3449Datum Datum::createDatum(InternalDataType type,
int data)
3452 result.d_as.d_type = type;
3453 result.d_as.d_int64 =
data;
3461void* Datum::theInlineStorage()
3463 return d_data.buffer();
3467const void* Datum::theInlineStorage()
const
3469 return d_data.buffer();
3478void Datum::safeDeallocateBytes(
const AllocatorType& allocator,
3479 bsl::size_t nBytes)
const
3481 void *ptr = allocatedPtr<void>();
3484 AllocUtil::deallocateBytes(allocator, ptr, nBytes);
3489void Datum::safeDeallocateBytes(
const AllocatorType& allocator,
3491 bsl::size_t alignment)
const
3493 void *ptr = allocatedPtr<void>();
3496 AllocUtil::deallocateBytes(allocator, ptr, nBytes, alignment);
3500template <
class t_TYPE>
3502t_TYPE *Datum::allocatedPtr()
const
3504#ifdef BSLS_PLATFORM_CPU_32_BIT
3505 return static_cast<t_TYPE *
>(
const_cast<void*
>(d_as.d_cvp));
3507 return static_cast<t_TYPE *
>(d_as.d_ptr);
3511Datum::InternalDataType Datum::internalType()
const
3513#ifdef BSLS_PLATFORM_CPU_32_BIT
3514 if (0x7f == d_data[k_EXPONENT_MSB] &&
3515 0xf0 == (d_data[k_EXPONENT_LSB] & 0xf0)) {
3516 return static_cast<InternalDataType
>(d_data[k_EXPONENT_LSB] & 0x0f);
3518 return e_INTERNAL_DOUBLE;
3520 return static_cast<InternalDataType
>(d_as.d_type);
3525DatumArrayRef Datum::theArrayReference()
const
3527#ifdef BSLS_PLATFORM_CPU_32_BIT
3528 return DatumArrayRef(allocatedPtr<const Datum>(), d_as.d_ushort);
3530 return DatumArrayRef(allocatedPtr<const Datum>(), d_as.d_int32);
3535DatumArrayRef Datum::theInternalArray()
const
3537 const Datum *
data = allocatedPtr<const Datum>();
3539 const SizeType
size = *
reinterpret_cast<const SizeType *
>(
data);
3540 return DatumArrayRef(data + 1, size);
3542 return DatumArrayRef(0, 0);
3548#ifdef BSLS_PLATFORM_CPU_32_BIT
3549 const char *
data = allocatedPtr<const char>();
3551 Datum_Helpers::load<SizeType>(data, 0));
3561#ifdef BSLS_PLATFORM_CPU_32_BIT
3564 const char *str =
reinterpret_cast<const char *
>(theInlineStorage());
3565 const SizeType len = *str++;
3573#ifdef BSLS_PLATFORM_CPU_32_BIT
3581bsl::size_t Datum::theMapAllocNumBytes()
const
3586 const Datum_MapHeader *header = allocatedPtr<const Datum_MapHeader>();
3588 return header ? header->d_allocatedSize : 0;
3592bsl::size_t Datum::theIntMapAllocNumBytes()
const
3597 const Datum_IntMapHeader *hdr = allocatedPtr<const Datum_IntMapHeader>();
3599 return hdr ? (hdr->d_capacity + 1) *
sizeof(DatumIntMapEntry) : 0;
3603bsl::size_t Datum::theErrorAllocNumBytes()
const
3607#ifdef BSLS_PLATFORM_CPU_32_BIT
3613 e_EXTENDED_INTERNAL_ERROR_ALLOC == extendedInternalType());
3618 const char*
data = allocatedPtr<const char>();
3620 const bsl::size_t msgLen = Datum_Helpers::load<int>(data,
sizeof(
int));
3621 const bsl::size_t align =
sizeof(int);
3622 const bsl::size_t headLen = 2 *
sizeof(int);
3624 return headLen + ((msgLen + align - 1) & ~(align - 1));
3628bsl::size_t Datum::theBinaryAllocNumBytes()
const
3632#ifdef BSLS_PLATFORM_CPU_32_BIT
3634 e_EXTENDED_INTERNAL_BINARY_ALLOC == extendedInternalType());
3635 return *allocatedPtr<const SizeType>() +
sizeof(double);
3638 return d_as.d_int32;
3643bsl::size_t Datum::theInternalStringAllocNumBytes()
const
3648#ifdef BSLS_PLATFORM_CPU_32_BIT
3649 const char *
data = allocatedPtr<const char>();
3650 const bsl::size_t msgLen = Datum_Helpers::load<SizeType>(data, 0);
3651 const bsl::size_t align =
sizeof(SizeType);
3652 const bsl::size_t headLen =
sizeof(SizeType);
3654 return headLen + ((msgLen + align - 1) & ~(align - 1));
3657 return d_as.d_int32;
3662bsl::size_t Datum::theInternalArrayAllocNumBytes()
const
3667 const Datum *
data = allocatedPtr<const Datum>();
3669 const bsl::size_t length = *
reinterpret_cast<const SizeType*
>(
data);
3670 return (length + 1) *
sizeof(Datum);
3684#ifdef BSLS_PLATFORM_CPU_32_BIT
3688 if (bsl::numeric_limits<unsigned short>::max() >= length) {
3690 result.
d_as.d_exponent = k_DOUBLE_MASK | e_INTERNAL_ARRAY_REFERENCE;
3691 result.
d_as.d_ushort =
static_cast<unsigned short>(length);
3692 result.
d_as.d_cvp = array;
3696 void *mem = AllocUtil::allocateBytes(allocator,
3697 sizeof(array) +
sizeof(length));
3698 Datum_Helpers::store<const Datum *>(mem, 0, array);
3699 Datum_Helpers::store<SizeType> (mem,
sizeof(array), length);
3701 return createExtendedDataObject(e_EXTENDED_INTERNAL_AREF_ALLOC, mem);
3705 BSLS_ASSERT(length <= bsl::numeric_limits<unsigned int>::max());
3708 result.
d_as.d_type = e_INTERNAL_ARRAY_REFERENCE;
3709 result.
d_as.d_int32 =
static_cast<int>(length);
3710 result.
d_as.d_ptr =
reinterpret_cast<void*
>(
const_cast<Datum*
>(array));
3719 return createArrayReference(value.
data(), value.
length(), allocator);
3726#ifdef BSLS_PLATFORM_CPU_32_BIT
3727 result.d_exp.d_value = (k_DOUBLE_MASK | e_INTERNAL_BOOLEAN)
3728 << k_TYPE_MASK_BITS;
3729 result.
d_as.d_int = value;
3731 result.
d_as.d_type = e_INTERNAL_BOOLEAN;
3732 result.
d_as.d_int32 = value;
3741#ifdef BSLS_PLATFORM_CPU_32_BIT
3745 result.d_exp.d_value = (k_DOUBLE_MASK | e_INTERNAL_DATE)
3746 << k_TYPE_MASK_BITS;
3749 result.
d_as.d_type = e_INTERNAL_DATE;
3750 new (result.theInlineStorage())
bdlt::Date(value);
3760#ifdef BSLS_PLATFORM_CPU_32_BIT
3764 - k_DATETIME_OFFSET_FROM_EPOCH;
3765 short shortDateOffsetFromEpoch =
static_cast<short>(dateOffsetFromEpoch);
3767 if (
static_cast<int>(shortDateOffsetFromEpoch) == dateOffsetFromEpoch &&
3769 result.d_exp.d_value =
3770 (k_DOUBLE_MASK | e_INTERNAL_DATETIME) << k_TYPE_MASK_BITS
3771 | (0xffff & dateOffsetFromEpoch);
3775 void *mem = AllocUtil::newObject<bdlt::Datetime>(allocator, value);
3776 result = createExtendedDataObject(e_EXTENDED_INTERNAL_DATETIME_ALLOC,
3782 result.
d_as.d_type = e_INTERNAL_DATETIME;
3793#ifdef BSLS_PLATFORM_CPU_32_BIT
3798 Datum_Helpers32::storeSmallInt64(msValue,
3799 &result.
d_as.d_short,
3800 &result.
d_as.d_int)) {
3801 result.
d_as.d_exponent = k_DOUBLE_MASK | e_INTERNAL_DATETIME_INTERVAL;
3803 void *mem = AllocUtil::newObject<bdlt::DatetimeInterval>(allocator,
3805 result = createExtendedDataObject(
3806 e_EXTENDED_INTERNAL_DATETIME_INTERVAL_ALLOC,
3812 result.
d_as.d_type = e_INTERNAL_DATETIME_INTERVAL;
3813 result.
d_as.d_int32 = value.
days();
3823#ifdef BSLS_PLATFORM_CPU_32_BIT
3826 return createExtendedDataObject(e_EXTENDED_INTERNAL_NAN2, 0);
3828 result.d_double = value;
3831 result.
d_as.d_type = e_INTERNAL_DOUBLE;
3832 result.
d_as.d_double = value;
3840#ifdef BSLS_PLATFORM_CPU_32_BIT
3841 return createExtendedDataObject(e_EXTENDED_INTERNAL_ERROR, code);
3843 return createDatum(e_INTERNAL_ERROR, code);
3851#ifdef BSLS_PLATFORM_CPU_32_BIT
3852 result.d_exp.d_value = (k_DOUBLE_MASK | e_INTERNAL_INTEGER)
3853 << k_TYPE_MASK_BITS;
3854 result.
d_as.d_int = value;
3856 result.
d_as.d_type = e_INTERNAL_INTEGER;
3857 result.
d_as.d_int32 = value;
3867#ifdef BSLS_PLATFORM_CPU_32_BIT
3868 if (Datum_Helpers32::storeSmallInt64(value,
3869 &result.
d_as.d_short,
3870 &result.
d_as.d_int)) {
3871 result.
d_as.d_exponent = k_DOUBLE_MASK | e_INTERNAL_INTEGER64;
3873 void *mem = AllocUtil::newObject<bsls::Types::Int64>(allocator, value);
3874 result = createExtendedDataObject(e_EXTENDED_INTERNAL_INTEGER64_ALLOC,
3880 result.
d_as.d_type = e_INTERNAL_INTEGER64;
3881 result.
d_as.d_int64 = value;
3890#ifdef BSLS_PLATFORM_CPU_32_BIT
3894 result.
d_as.d_exponent = k_DOUBLE_MASK | Datum::e_INTERNAL_EXTENDED;
3895 result.
d_as.d_ushort = e_EXTENDED_INTERNAL_NIL;
3897 result.
d_as.d_type = e_INTERNAL_NIL;
3903Datum Datum::createStringRef(
const char *
string,
3909#ifdef BSLS_PLATFORM_CPU_32_BIT
3913 if (bsl::numeric_limits<unsigned short>::max() >= length) {
3915 result.d_exp.d_value = (k_DOUBLE_MASK | e_INTERNAL_STRING_REFERENCE)
3916 << k_TYPE_MASK_BITS | length;
3917 result.
d_as.d_cvp = string;
3921 void *mem = AllocUtil::allocateBytes(allocator,
3922 sizeof(length) +
sizeof(
string));
3923 Datum_Helpers::store<const char *>(mem, 0,
string);
3924 Datum_Helpers::store<SizeType> (mem,
sizeof(
string), length);
3926 return createExtendedDataObject(e_EXTENDED_INTERNAL_SREF_ALLOC, mem);
3930 BSLS_ASSERT(length <= bsl::numeric_limits<unsigned int>::max());
3933 result.
d_as.d_type = e_INTERNAL_STRING_REFERENCE;
3934 result.
d_as.d_int32 =
static_cast<int>(length);
3935 result.
d_as.d_ptr =
const_cast<char*
>(string);
3941Datum Datum::createStringRef(
const char *
string,
3946 return createStringRef(
string, bsl::strlen(
string), allocator);
3953 return createStringRef(value.
data(), value.
length(), allocator);
3960#ifdef BSLS_PLATFORM_CPU_32_BIT
3961 result.d_exp.d_value = (k_DOUBLE_MASK | e_INTERNAL_TIME)
3962 << k_TYPE_MASK_BITS;
3965 *
reinterpret_cast<bdlt::Time*
>(&rawTime) = value;
3966 const bool rc = Datum_Helpers32::storeInt48(rawTime,
3967 &result.
d_as.d_short,
3968 &result.
d_as.d_int);
3971 result.
d_as.d_type = e_INTERNAL_TIME;
3972 new (result.theInlineStorage())
bdlt::Time(value);
3978Datum Datum::createUdt(
void *data,
int type)
3983#ifdef BSLS_PLATFORM_CPU_32_BIT
3984 result.
d_as.d_exponent = k_DOUBLE_MASK | e_INTERNAL_USERDEFINED;
3985 result.
d_as.d_ushort =
static_cast<unsigned short>(type);
3986 result.
d_as.d_cvp = data;
3988 result.
d_as.d_type = e_INTERNAL_USERDEFINED;
3989 result.
d_as.d_int32 = type;
3990 result.
d_as.d_ptr = data;
4003#ifdef BSLS_PLATFORM_CPU_32_BIT
4004 result.
d_as.d_exponent = k_DOUBLE_MASK | e_INTERNAL_ARRAY;
4007 result.
d_as.d_type = e_INTERNAL_ARRAY;
4020#ifdef BSLS_PLATFORM_CPU_32_BIT
4021 return createExtendedDataObject(e_EXTENDED_INTERNAL_MAP, map.
size());
4023 return createDatum(e_INTERNAL_MAP, map.
size());
4034#ifdef BSLS_PLATFORM_CPU_32_BIT
4035 return createExtendedDataObject(e_EXTENDED_INTERNAL_INT_MAP, map.
size());
4037 return createDatum(e_INTERNAL_INT_MAP, map.
size());
4048#ifdef BSLS_PLATFORM_CPU_32_BIT
4049 return createExtendedDataObject(e_EXTENDED_INTERNAL_OWNED_MAP,
4052 return createDatum(e_INTERNAL_OWNED_MAP, map.
size());
4060 return copyString(value.
data(), value.
length(), allocator);
4070 AllocUtil::deallocateBytes(allocator, ptr, array.
capacity());
4083 AllocUtil::deallocateBytes(
4104void Datum::disposeUninitializedMap(
4119bool Datum::isArray()
const
4121 return (e_ARRAY == type());
4125bool Datum::isBinary()
const
4127 return (e_BINARY == type());
4131bool Datum::isBoolean()
const
4133 return (e_BOOLEAN == type());
4137bool Datum::isDate()
const
4139 return (e_DATE == type());
4143bool Datum::isDatetime()
const
4145 return (e_DATETIME == type());
4149bool Datum::isDatetimeInterval()
const
4151 return (e_DATETIME_INTERVAL == type());
4155bool Datum::isDecimal64()
const
4157 return (e_DECIMAL64 == type());
4161bool Datum::isDouble()
const
4163 return (e_DOUBLE == type());
4167bool Datum::isError()
const
4169 return (e_ERROR == type());
4173bool Datum::isExternalReference()
const
4175#ifdef BSLS_PLATFORM_CPU_32_BIT
4176 switch (internalType()) {
4177 case e_INTERNAL_STRING_REFERENCE:
4178 case e_INTERNAL_ARRAY_REFERENCE:
4179 case e_INTERNAL_USERDEFINED:
4181 case e_INTERNAL_EXTENDED:
4182 switch (extendedInternalType()) {
4183 case e_EXTENDED_INTERNAL_SREF_ALLOC:
4184 case e_EXTENDED_INTERNAL_AREF_ALLOC:
4193 switch (internalType()) {
4194 case e_INTERNAL_STRING_REFERENCE:
4195 case e_INTERNAL_ARRAY_REFERENCE:
4196 case e_INTERNAL_USERDEFINED:
4198 case e_INTERNAL_UNINITIALIZED:
4209bool Datum::isInteger()
const
4211 return (e_INTEGER == type());
4215bool Datum::isInteger64()
const
4217 return (e_INTEGER64 == type());
4221bool Datum::isIntMap()
const
4223 return (e_INT_MAP == type());
4227bool Datum::isMap()
const
4229 return (e_MAP == type());
4233bool Datum::isNull()
const
4235 return (e_NIL == type());
4239bool Datum::isString()
const
4241 return (e_STRING == type());
4245bool Datum::isTime()
const
4247 return (e_TIME == type());
4251bool Datum::isUdt()
const
4253 return (e_USERDEFINED == type());
4261 const InternalDataType type = internalType();
4262 if (e_INTERNAL_ARRAY == type) {
4263 return theInternalArray();
4266#ifdef BSLS_PLATFORM_CPU_32_BIT
4267 if (e_INTERNAL_EXTENDED == type) {
4268 return theLongArrayReference();
4272 return theArrayReference();
4280#ifdef BSLS_PLATFORM_CPU_32_BIT
4282 *allocatedPtr<const SizeType>());
4284 const InternalDataType type = internalType();
4286 case e_INTERNAL_BINARY:
4288 d_data.buffer()[k_SMALLBINARY_SIZE_OFFSET]);
4289 case e_INTERNAL_BINARY_ALLOC:
4292 BSLS_ASSERT(0 ==
"Bad binary internal-type (memory corruption?)");
4299bool Datum::theBoolean()
const
4303#ifdef BSLS_PLATFORM_CPU_32_BIT
4304 return static_cast<bool>(d_as.d_int);
4306 return d_as.d_int32;
4315#ifdef BSLS_PLATFORM_CPU_32_BIT
4316 return *
reinterpret_cast<const bdlt::Date *
>(&d_as.d_int);
4318 return *
reinterpret_cast<const bdlt::Date *
>(theInlineStorage());
4327#ifdef BSLS_PLATFORM_CPU_32_BIT
4328 const InternalDataType type = internalType();
4330 if (type == e_INTERNAL_DATETIME) {
4341 extendedInternalType() == e_EXTENDED_INTERNAL_DATETIME_ALLOC);
4342 return *allocatedPtr<const bdlt::Datetime>();
4344 return *
reinterpret_cast<const bdlt::Datetime *
>(theInlineStorage());
4353#ifdef BSLS_PLATFORM_CPU_32_BIT
4354 const InternalDataType type = internalType();
4356 if (type == e_INTERNAL_DATETIME_INTERVAL) {
4359 Datum_Helpers32::loadSmallInt64(d_as.d_short, d_as.d_int));
4365 extendedInternalType() == e_EXTENDED_INTERNAL_DATETIME_INTERVAL_ALLOC);
4366 return *allocatedPtr<const bdlt::DatetimeInterval>();
4378double Datum::theDouble()
const
4382#ifdef BSLS_PLATFORM_CPU_32_BIT
4384 0x7f != d_data[k_EXPONENT_MSB] ||
4385 0xf0 != (d_data[k_EXPONENT_LSB] & 0xf0) ||
4386 e_INTERNAL_INF == (d_data[k_EXPONENT_LSB] & 0x0f))) {
4390 return bsl::numeric_limits<double>::quiet_NaN();
4392 return d_as.d_double;
4401#ifdef BSLS_PLATFORM_CPU_32_BIT
4406 if (e_EXTENDED_INTERNAL_ERROR == extendedInternalType()) {
4410 const char *data = allocatedPtr<const char>();
4412 if (e_INTERNAL_ERROR == internalType()) {
4413 return DatumError(
static_cast<int>(d_as.d_int64));
4416 const char *data = allocatedPtr<const char>();
4420 Datum_Helpers::load<int>(data, 0),
4422 Datum_Helpers::load<int>(data,
sizeof(
int))));
4426int Datum::theInteger()
const
4430#ifdef BSLS_PLATFORM_CPU_32_BIT
4433 return d_as.d_int32;
4442#ifdef BSLS_PLATFORM_CPU_32_BIT
4443 const InternalDataType type = internalType();
4446 return theSmallInteger64();
4450 e_EXTENDED_INTERNAL_INTEGER64_ALLOC == extendedInternalType());
4451 return theLargeInteger64();
4453 return d_as.d_int64;
4462 const DatumMapEntry *map = allocatedPtr<const DatumMapEntry>();
4501 const InternalDataType type = internalType();
4503 case e_INTERNAL_SHORTSTRING:
4504 return theShortString();
4505 case e_INTERNAL_STRING:
4506 return theInternalString();
4507 case e_INTERNAL_STRING_REFERENCE:
4508 return theStringReference();
4509#ifdef BSLS_PLATFORM_CPU_32_BIT
4510 case e_INTERNAL_LONGEST_SHORTSTRING:
4511 return theLongestShortString();
4513 return theLongStringReference();
4516 BSLS_ASSERT(0 ==
"Bad string internal-type (memory corruption?)");
4528#ifdef BSLS_PLATFORM_CPU_32_BIT
4531 rawTime = Datum_Helpers32::loadInt48(d_as.d_short, d_as.d_int);
4532 return *
reinterpret_cast<bdlt::Time*
>(&rawTime);
4534 return *
reinterpret_cast<const bdlt::Time *
>(theInlineStorage());
4542#ifdef BSLS_PLATFORM_CPU_32_BIT
4543 return DatumUdt(allocatedPtr<void>(), d_as.d_ushort);
4545 return DatumUdt(allocatedPtr<void>(), d_as.d_int32);
4552#ifdef BSLS_PLATFORM_CPU_32_BIT
4553 static const DataType convert[] = {
4562 , e_DATETIME_INTERVAL
4573 const InternalDataType type = internalType();
4574 if (e_INTERNAL_EXTENDED == type) {
4575 return typeFromExtendedInternalType();
4577 return convert[type];
4579 static const DataType convert[] = {
4589 , e_DATETIME_INTERVAL
4607 const InternalDataType type = internalType();
4611 return convert[type];
4615template <
class t_VISITOR>
4616void Datum::apply(t_VISITOR& visitor)
const
4618#ifdef BSLS_PLATFORM_CPU_32_BIT
4619 switch (internalType()) {
4620 case e_INTERNAL_INF:
4621 visitor(bsl::numeric_limits<double>::infinity());
4623 case e_INTERNAL_BOOLEAN:
4624 visitor(theBoolean());
4626 case e_INTERNAL_SHORTSTRING:
4627 visitor(theShortString());
4629 case e_INTERNAL_LONGEST_SHORTSTRING:
4630 visitor(theLongestShortString());
4632 case e_INTERNAL_STRING:
4633 visitor(theInternalString());
4635 case e_INTERNAL_DATE:
4638 case e_INTERNAL_TIME:
4641 case e_INTERNAL_DATETIME:
4642 visitor(theDatetime());
4644 case e_INTERNAL_DATETIME_INTERVAL:
4645 visitor(theDatetimeInterval());
4647 case e_INTERNAL_INTEGER:
4648 visitor(theInteger());
4650 case e_INTERNAL_INTEGER64:
4651 visitor(theInteger64());
4653 case e_INTERNAL_USERDEFINED:
4656 case e_INTERNAL_ARRAY:
4657 visitor(theInternalArray());
4659 case e_INTERNAL_STRING_REFERENCE:
4660 visitor(theStringReference());
4662 case e_INTERNAL_ARRAY_REFERENCE:
4663 visitor(theArrayReference());
4665 case e_INTERNAL_EXTENDED:
4666 switch (extendedInternalType()) {
4667 case e_EXTENDED_INTERNAL_INT_MAP:
4668 visitor(theIntMap());
4670 case e_EXTENDED_INTERNAL_MAP:
4672 case e_EXTENDED_INTERNAL_OWNED_MAP:
4675 case e_EXTENDED_INTERNAL_NAN2:
4676 visitor(theDouble());
4678 case e_EXTENDED_INTERNAL_ERROR:
4680 case e_EXTENDED_INTERNAL_ERROR_ALLOC:
4681 visitor(theError());
4683 case e_EXTENDED_INTERNAL_SREF_ALLOC:
4684 visitor(theLongStringReference());
4686 case e_EXTENDED_INTERNAL_AREF_ALLOC:
4687 visitor(theLongArrayReference());
4689 case e_EXTENDED_INTERNAL_DATETIME_ALLOC:
4690 visitor(theDatetime());
4692 case e_EXTENDED_INTERNAL_DATETIME_INTERVAL_ALLOC:
4693 visitor(theDatetimeInterval());
4695 case e_EXTENDED_INTERNAL_INTEGER64_ALLOC:
4696 visitor(theInteger64());
4698 case e_EXTENDED_INTERNAL_BINARY_ALLOC:
4699 visitor(theBinary());
4701 case e_EXTENDED_INTERNAL_DECIMAL64:
4702 case e_EXTENDED_INTERNAL_DECIMAL64_SPECIAL:
4703 case e_EXTENDED_INTERNAL_DECIMAL64_ALLOC: {
4714 t_VISITOR>::type dec64MemFunPtr = &Datum::theDecimal64;
4715 visitor((this->*dec64MemFunPtr)());
4717 case e_EXTENDED_INTERNAL_NIL:
4722 0 ==
"Unknown extended-type (memory corruption?)");
4725 case e_INTERNAL_DOUBLE:
4732 switch (internalType()) {
4733 case e_INTERNAL_INF:
4734 visitor(bsl::numeric_limits<double>::infinity());
4736 case e_INTERNAL_NIL:
4739 case e_INTERNAL_BOOLEAN:
4740 visitor(theBoolean());
4742 case e_INTERNAL_SHORTSTRING:
4743 visitor(theShortString());
4745 case e_INTERNAL_STRING:
4746 visitor(theInternalString());
4748 case e_INTERNAL_DATE:
4751 case e_INTERNAL_TIME:
4754 case e_INTERNAL_DATETIME:
4755 visitor(theDatetime());
4757 case e_INTERNAL_DATETIME_INTERVAL:
4758 visitor(theDatetimeInterval());
4760 case e_INTERNAL_INTEGER:
4761 visitor(theInteger());
4763 case e_INTERNAL_INTEGER64:
4764 visitor(theInteger64());
4766 case e_INTERNAL_USERDEFINED:
4769 case e_INTERNAL_ARRAY:
4770 visitor(theInternalArray());
4772 case e_INTERNAL_STRING_REFERENCE:
4773 visitor(theStringReference());
4775 case e_INTERNAL_ARRAY_REFERENCE:
4776 visitor(theArrayReference());
4778 case e_INTERNAL_MAP:
4780 case e_INTERNAL_OWNED_MAP:
4783 case e_INTERNAL_ERROR:
4785 case e_INTERNAL_ERROR_ALLOC:
4786 visitor(theError());
4788 case e_INTERNAL_DOUBLE:
4789 visitor(d_as.d_double);
4791 case e_INTERNAL_BINARY:
4793 case e_INTERNAL_BINARY_ALLOC:
4794 visitor(theBinary());
4796 case e_INTERNAL_DECIMAL64: {
4807 t_VISITOR>::type dec64MemFunPtr = &Datum::theDecimal64;
4808 visitor((this->*dec64MemFunPtr)());
4810 case e_INTERNAL_INT_MAP:
4811 visitor(theIntMap());
4813 case e_INTERNAL_UNINITIALIZED:
4822#ifndef BDE_OMIT_INTERNAL_DEPRECATED
4824void Datum::createUninitializedMapOwningKeys(
4830 createUninitializedMap(result, capacity, keysCapacity, allocator);
4836 return adoptMap(mapping);
4840void Datum::disposeUninitializedMapOwningKeys(
4844 return disposeUninitializedMap(mapping, allocator);
4854DatumArrayRef::DatumArrayRef()
4874 return d_data_p[index];
4930 return d_data_p + d_length;
4968 return *(
end() - 1);
4974 return 0 == d_length;
5040 return d_data_p[index];
5089 return d_data_p + d_size;
5127 return *(
end() - 1);
5197, d_ownsKeys(ownsKeys)
5210 return d_data_p[index];
5259 return d_data_p + d_size;
5297 return *(
end() - 1);
5336, d_capacity(capacity)
5484, d_allocatedSize(allocatedSize)
5501 return d_allocatedSize;
5535 return !(lhs == rhs);
5541 return !(lhs == rhs);
5545bool bdld::operator==(
const DatumIntMapEntry& lhs,
const DatumIntMapEntry& rhs)
5547 return (lhs.key() == rhs.key()) && (lhs.value() == rhs.value());
5551bool bdld::operator!=(
const DatumIntMapEntry& lhs,
const DatumIntMapEntry& rhs)
5553 return !(lhs == rhs);
5559 return !(lhs == rhs);
5565 return (lhs.key() == rhs.key()) && (lhs.value() == rhs.value());
5571 return !(lhs == rhs);
5577 return !(lhs == rhs);
5583 return rhs.print(stream, 0, -1);
5586template <
class t_HASH_ALGORITHM>
5592 switch (input.
type()) {
5634 for (bsl::size_t i = 0; i < input.
theArray().length(); ++i) {
5640 for (bsl::size_t i = 0; i < input.
theMap().
size(); ++i) {
5661 const typename Datum_MakeDependent<Dec64MemFunPtr,
5662 t_HASH_ALGORITHM>::type
5663 dec64MemFunPtr = &Datum::theDecimal64;
5664 hashAppend(hashAlg, (input.*dec64MemFunPtr)());
5668 for (bsl::size_t i = 0; i < input.
theIntMap().
size(); ++i) {
5674 BSLS_ASSERT(0 ==
"Unknown type (memory corruption?)");
5680bsl::ostream&
bdld::operator<<(bsl::ostream& stream,
const DatumArrayRef& rhs)
5682 return rhs.print(stream, 0 , -1);
5686bsl::ostream&
bdld::operator<<(bsl::ostream& stream,
const DatumMapEntry& rhs)
5688 return rhs.print(stream, 0 , -1);
5693 const DatumIntMapEntry& rhs)
5695 return rhs.print(stream, 0 , -1);
5699bsl::ostream&
bdld::operator<<(bsl::ostream& stream,
const DatumIntMapRef& rhs)
5701 return rhs.print(stream, 0 , -1);
5705bsl::ostream&
bdld::operator<<(bsl::ostream& stream,
const DatumMapRef& rhs)
5707 return rhs.print(stream, 0 , -1);
Definition bdld_datum.h:2461
size_type length() const
Return a const pointer to the length of the array.
Definition bdld_datum.h:4886
const_iterator begin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4900
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
BSLMF_NESTED_TRAIT_DECLARATION(DatumArrayRef, bdlb::HasPrintMethod)
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bdld_datum.h:2481
size_type size() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4893
DatumArrayRef()
Create a DatumArrayRef object representing an empty array.
Definition bdld_datum.h:4854
bsl::size_t size_type
Definition bdld_datum.h:2468
const_iterator end() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4928
DatumArrayRef(const DatumArrayRef &other)=default
DatumArrayRef & operator=(const DatumArrayRef &rhs)=default
Assign to this object the value of the specified rhs object.
const_reverse_iterator rbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4914
bsl::ptrdiff_t difference_type
Definition bdld_datum.h:2469
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4921
element_type & reference
Definition bdld_datum.h:2474
pointer data() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4879
bsl::reverse_iterator< iterator > reverse_iterator
Definition bdld_datum.h:2480
const_reference operator[](size_type position) const
Definition bdld_datum.h:4871
Datum::SizeType SizeType
Definition bdld_datum.h:2485
const bdld::Datum element_type
Definition bdld_datum.h:2465
const_reverse_iterator rend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4942
element_type * pointer
Definition bdld_datum.h:2471
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return size() == 0.
Definition bdld_datum.h:4972
pointer iterator
Definition bdld_datum.h:2477
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4907
const_reference back() const
Definition bdld_datum.h:4965
BSLMF_NESTED_TRAIT_DECLARATION(DatumArrayRef, bsl::is_trivially_copyable)
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4935
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:4949
const element_type & const_reference
Definition bdld_datum.h:2475
bdld::Datum value_type
Definition bdld_datum.h:2466
const_reference front() const
Definition bdld_datum.h:4957
const element_type * const_pointer
Definition bdld_datum.h:2472
const_pointer const_iterator
Definition bdld_datum.h:2478
Definition bdld_datumbinaryref.h:157
const void * data() const
Return the pointer to the non-modifiable binary data.
Definition bdld_datumbinaryref.h:290
SizeType size() const
Return the size of the binary data.
Definition bdld_datumbinaryref.h:296
Definition bdld_datumerror.h:160
bslstl::StringRef message() const
Definition bdld_datumerror.h:321
int code() const
Return the error code.
Definition bdld_datumerror.h:315
Definition bdld_datum.h:2628
const Datum & value() const
Return the value for this entry.
Definition bdld_datum.h:5015
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
BSLMF_NESTED_TRAIT_DECLARATION(DatumIntMapEntry, bdlb::HasPrintMethod)
BSLMF_NESTED_TRAIT_DECLARATION(DatumIntMapEntry, bsl::is_trivially_copyable)
void setValue(const Datum &value)
Set the value for this entry to the specified value.
Definition bdld_datum.h:5002
DatumIntMapEntry()
Create a DatumIntMapEntry object.
Definition bdld_datum.h:4982
void setKey(int key)
Set the key for this entry to the specified key.
Definition bdld_datum.h:4996
~DatumIntMapEntry()=default
Destroy this object.
int key() const
Return the key for this entry.
Definition bdld_datum.h:5009
Definition bdld_datum.h:2723
const_iterator begin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5059
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5080
const element_type * const_pointer
Definition bdld_datum.h:2734
~DatumIntMapRef()=default
Destroy this object.
Datum::SizeType SizeType
Definition bdld_datum.h:2749
element_type * pointer
Definition bdld_datum.h:2733
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5066
element_type & reference
Definition bdld_datum.h:2736
const_pointer const_iterator
Definition bdld_datum.h:2740
bsl::reverse_iterator< iterator > reverse_iterator
Definition bdld_datum.h:2742
pointer data() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5045
bsl::ptrdiff_t difference_type
Definition bdld_datum.h:2731
const element_type & const_reference
Definition bdld_datum.h:2737
const_reference back() const
Definition bdld_datum.h:5124
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5094
bdld::DatumIntMapEntry value_type
Definition bdld_datum.h:2728
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return size() == 0.
Definition bdld_datum.h:5131
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5108
const_iterator end() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5087
const_reverse_iterator rbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5073
BSLMF_NESTED_TRAIT_DECLARATION(DatumIntMapRef, bsl::is_trivially_copyable)
bool isSorted() const
Return true if underlying map is sorted and false otherwise.
Definition bdld_datum.h:5137
const_reference operator[](size_type position) const
Definition bdld_datum.h:5037
size_type size() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5051
bsl::size_t size_type
Definition bdld_datum.h:2730
DatumIntMapRef(const DatumIntMapEntry *data, SizeType size, bool sorted)
Definition bdld_datum.h:5025
const bdld::DatumIntMapEntry element_type
Definition bdld_datum.h:2727
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bdld_datum.h:2743
pointer iterator
Definition bdld_datum.h:2739
BSLMF_NESTED_TRAIT_DECLARATION(DatumIntMapRef, bdlb::HasPrintMethod)
const_reference front() const
Definition bdld_datum.h:5116
const_reverse_iterator rend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5101
Definition bdld_datum.h:2892
DatumMapEntry()
Create a DatumMapEntry object.
Definition bdld_datum.h:5147
BSLMF_NESTED_TRAIT_DECLARATION(DatumMapEntry, bsl::is_trivially_copyable)
const Datum & value() const
Return the value for this entry.
Definition bdld_datum.h:5180
BSLMF_NESTED_TRAIT_DECLARATION(DatumMapEntry, bdlb::HasPrintMethod)
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
void setKey(const bslstl::StringRef &key)
Set the key for this entry to the specified key.
Definition bdld_datum.h:5161
const bslstl::StringRef & key() const
Return the key for this entry.
Definition bdld_datum.h:5174
void setValue(const Datum &value)
Set the value for this entry to the specified value.
Definition bdld_datum.h:5167
~DatumMapEntry()=default
Destroy this object.
Definition bdld_datum.h:2983
bsl::size_t size_type
Definition bdld_datum.h:2990
const_pointer const_iterator
Definition bdld_datum.h:3000
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bdld_datum.h:3003
element_type * pointer
Definition bdld_datum.h:2993
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return size() == 0.
Definition bdld_datum.h:5301
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5236
size_type size() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5221
DatumMapRef(const DatumMapEntry *data, SizeType size, bool sorted, bool ownsKeys)
Definition bdld_datum.h:5190
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5250
const element_type & const_reference
Definition bdld_datum.h:2997
pointer data() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5215
BSLMF_NESTED_TRAIT_DECLARATION(DatumMapRef, bdlb::HasPrintMethod)
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5278
const_reference front() const
Definition bdld_datum.h:5286
bdld::DatumMapEntry value_type
Definition bdld_datum.h:2988
bool ownsKeys() const
Definition bdld_datum.h:5313
bsl::ptrdiff_t difference_type
Definition bdld_datum.h:2991
bsl::reverse_iterator< iterator > reverse_iterator
Definition bdld_datum.h:3002
const_reverse_iterator rend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5271
pointer iterator
Definition bdld_datum.h:2999
const bdld::DatumMapEntry element_type
Definition bdld_datum.h:2987
element_type & reference
Definition bdld_datum.h:2996
Datum::SizeType SizeType
Definition bdld_datum.h:3009
const_iterator end() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5257
const_reverse_iterator rbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5243
bool isSorted() const
Return true if underlying map is sorted and false otherwise.
Definition bdld_datum.h:5307
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5264
const_iterator begin() const BSLS_KEYWORD_NOEXCEPT
Definition bdld_datum.h:5229
const element_type * const_pointer
Definition bdld_datum.h:2994
~DatumMapRef()=default
Destroy this object.
BSLMF_NESTED_TRAIT_DECLARATION(DatumMapRef, bsl::is_trivially_copyable)
const_reference back() const
Definition bdld_datum.h:5294
const_reference operator[](size_type position) const
Definition bdld_datum.h:5207
Definition bdld_datum.h:2137
DatumMutableArrayRef & operator=(const DatumMutableArrayRef &rhs)=default
SizeType capacity() const
Return the allocated capacity of the array.
Definition bdld_datum.h:5360
Datum::SizeType SizeType
Definition bdld_datum.h:2144
void * allocatedPtr() const
Return pointer to the memory allocated for the array.
Definition bdld_datum.h:5342
DatumMutableArrayRef()
Create a DatumMutableArrayRef object that refers to no array.
Definition bdld_datum.h:5324
SizeType * length() const
Return pointer to the length of the array.
Definition bdld_datum.h:5354
Datum * data() const
Return pointer to the first element of the held array.
Definition bdld_datum.h:5348
~DatumMutableArrayRef()=default
DatumMutableArrayRef(const DatumMutableArrayRef &original)=default
Definition bdld_datum.h:2302
void * allocatedPtr() const
Return pointer to the memory allocated for the map.
Definition bdld_datum.h:5390
bool * sorted() const
Definition bdld_datum.h:5408
~DatumMutableIntMapRef()=default
Datum::SizeType SizeType
Definition bdld_datum.h:2310
DatumMutableIntMapRef(const DatumMutableIntMapRef &original)=default
SizeType * size() const
Definition bdld_datum.h:5402
DatumMutableIntMapRef()
Create a DatumMutableIntMapRef object.
Definition bdld_datum.h:5371
DatumMutableIntMapRef & operator=(const DatumMutableIntMapRef &rhs)=default
DatumIntMapEntry * data() const
Return pointer to the first element in the (held) map.
Definition bdld_datum.h:5396
Definition bdld_datum.h:2376
DatumMutableMapOwningKeysRef()
Create a DatumMutableMapOwningKeysRef object.
Definition bdld_datum.h:5467
Datum::SizeType SizeType
Definition bdld_datum.h:2384
SizeType * size() const
Definition bdld_datum.h:5518
~DatumMutableMapOwningKeysRef()=default
Destroy this object.
DatumMapEntry * data() const
Return pointer to the first element in the held map.
Definition bdld_datum.h:5505
DatumMutableMapOwningKeysRef(const DatumMutableMapOwningKeysRef &original)=default
DatumMutableMapOwningKeysRef & operator=(const DatumMutableMapOwningKeysRef &rhs)=default
void * allocatedPtr() const
Return pointer to the memory allocated for the map.
Definition bdld_datum.h:5492
char * keys() const
Return pointer to the start of the buffer where keys are stored.
Definition bdld_datum.h:5511
bool * sorted() const
Definition bdld_datum.h:5524
SizeType allocatedSize() const
Return the number of bytes allocated for the map.
Definition bdld_datum.h:5499
Definition bdld_datum.h:2232
DatumMapEntry * data() const
Return pointer to the first element in the (held) map.
Definition bdld_datum.h:5444
Datum::SizeType SizeType
Definition bdld_datum.h:2240
SizeType * size() const
Definition bdld_datum.h:5450
DatumMutableMapRef & operator=(const DatumMutableMapRef &rhs)=default
DatumMutableMapRef()
Create a DatumMutableMapRef object.
Definition bdld_datum.h:5419
DatumMutableMapRef(const DatumMutableMapRef &original)=default
void * allocatedPtr() const
Return pointer to the memory allocated for the map.
Definition bdld_datum.h:5438
~DatumMutableMapRef()=default
bool * sorted() const
Definition bdld_datum.h:5456
Definition bdld_datumudt.h:144
void * data() const
Return the pointer to the user-defined object.
Definition bdld_datumudt.h:272
int type() const
Return the type of the user-defined object.
Definition bdld_datumudt.h:278
Definition bdld_datum.h:787
DatumArrayRef theArray() const
Definition bdld_datum.h:4257
bsls::AlignedBuffer< 16 > d_data
Definition bdld_datum.h:1349
bool isArray() const
Definition bdld_datum.h:4119
friend bool operator==(const Datum &lhs, const Datum &rhs)
static Datum adoptMapOwningKeys(const DatumMutableMapOwningKeysRef &mapping)
[DEPRECATED] Use adoptMap instead.
Definition bdld_datum.h:4834
static Datum createTime(const bdlt::Time &value)
Return, by value, a datum having the specified Time value.
Definition bdld_datum.h:3957
static void createUninitializedMap(DatumMutableMapOwningKeysRef *result, SizeType capacity, SizeType keysCapacity, const AllocatorType &allocator)
bdlt::Datetime theDatetime() const
Definition bdld_datum.h:4323
static Datum adoptIntMap(const DatumMutableIntMapRef &intMap)
Definition bdld_datum.h:4028
static Datum createStringRef(const char *string, SizeType length, const AllocatorType &allocator)
Definition bdld_datum.h:3903
@ k_NUM_TYPES
Definition bdld_datum.h:843
@ DLCT_NUM_TYPES
Definition bdld_datum.h:845
bool isError() const
Definition bdld_datum.h:4167
static Datum createNull()
Return, by value, a datum having no value.
Definition bdld_datum.h:3887
DatumMapRef theMap() const
Definition bdld_datum.h:4458
bsls::Types::size_type SizeType
Definition bdld_datum.h:1462
static void createUninitializedMap(DatumMutableMapRef *result, SizeType capacity, const AllocatorType &allocator)
bool isString() const
Definition bdld_datum.h:4239
static Datum createError(int code)
Definition bdld_datum.h:3838
bool isBoolean() const
Definition bdld_datum.h:4131
DatumBinaryRef theBinary() const
Definition bdld_datum.h:4276
static const char * dataTypeToAscii(DataType type)
static Datum copyString(const char *string, SizeType length, const AllocatorType &allocator)
friend bool operator!=(const Datum &lhs, const Datum &rhs)
DataType type() const
Definition bdld_datum.h:4550
static Datum createInteger64(bsls::Types::Int64 value, const AllocatorType &allocator)
Definition bdld_datum.h:3863
bdlt::DatetimeInterval theDatetimeInterval() const
Definition bdld_datum.h:4349
bslstl::StringRef theString() const
Definition bdld_datum.h:4497
bsl::allocator AllocatorType
Definition bdld_datum.h:795
static Datum createUdt(void *data, int type)
Definition bdld_datum.h:3978
TypedAccess d_as
Definition bdld_datum.h:1350
static void createUninitializedArray(DatumMutableArrayRef *result, SizeType capacity, const AllocatorType &allocator)
bool isInteger() const
Definition bdld_datum.h:4209
bool isMap() const
Definition bdld_datum.h:4227
bdlt::Time theTime() const
Definition bdld_datum.h:4524
BSLMF_NESTED_TRAIT_DECLARATION(Datum, bdlb::HasPrintMethod)
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Datum & operator=(const Datum &rhs)=default
static Datum createArrayReference(const Datum *array, SizeType length, const AllocatorType &allocator)
Definition bdld_datum.h:3678
DatumError theError() const
Definition bdld_datum.h:4397
static void destroy(const Datum &value, const AllocatorType &allocator)
bdldfp::Decimal64 theDecimal64() const
bool theBoolean() const
Definition bdld_datum.h:4299
static Datum createDecimal64(bdldfp::Decimal64 value, const AllocatorType &allocator)
BSLMF_NESTED_TRAIT_DECLARATION(Datum, bslmf::IsBitwiseMoveable)
static Datum createDouble(double value)
Definition bdld_datum.h:3820
static Datum createInteger(int value)
Return, by value, a datum having the specified int value.
Definition bdld_datum.h:3848
static Datum adoptArray(const DatumMutableArrayRef &array)
Definition bdld_datum.h:3996
bool isExternalReference() const
Definition bdld_datum.h:4173
Datum clone(const AllocatorType &allocator) const
BSLMF_NESTED_TRAIT_DECLARATION(Datum, bsl::is_trivially_copyable)
static Datum createDatetime(const bdlt::Datetime &value, const AllocatorType &allocator)
Definition bdld_datum.h:3756
bool isDouble() const
Definition bdld_datum.h:4161
BSLMF_NESTED_TRAIT_DECLARATION(Datum, bsl::is_trivially_default_constructible)
bdlt::Date theDate() const
Definition bdld_datum.h:4311
static void disposeUninitializedIntMap(const DatumMutableIntMapRef &intMap, const AllocatorType &allocator)
Definition bdld_datum.h:4075
static Datum copyBinary(const void *value, SizeType size, const AllocatorType &allocator)
static void disposeUninitializedMapOwningKeys(const DatumMutableMapOwningKeysRef &mapping, const AllocatorType &allocator)
[DEPRECATED] Use disposeUninitializedMap instead.
Definition bdld_datum.h:4840
DatumIntMapRef theIntMap() const
Definition bdld_datum.h:4478
static void createUninitializedIntMap(DatumMutableIntMapRef *result, SizeType capacity, const AllocatorType &allocator)
double theDouble() const
Definition bdld_datum.h:4378
static void createUninitializedMapOwningKeys(DatumMutableMapOwningKeysRef *result, SizeType capacity, SizeType keysCapacity, const AllocatorType &allocator)
[DEPRECATED] Use createUninitializedMap instead.
Definition bdld_datum.h:4824
bsls::Types::Int64 theInteger64() const
Definition bdld_datum.h:4438
static Datum createError(int code, const bslstl::StringRef &message, const AllocatorType &allocator)
bool isNull() const
Definition bdld_datum.h:4233
static Datum createDatetimeInterval(const bdlt::DatetimeInterval &value, const AllocatorType &allocator)
Definition bdld_datum.h:3789
bool isDecimal64() const
Definition bdld_datum.h:4155
bool isInteger64() const
Definition bdld_datum.h:4215
static void disposeUninitializedMap(const DatumMutableMapRef &map, const AllocatorType &allocator)
Definition bdld_datum.h:4091
bool isBinary() const
Definition bdld_datum.h:4125
friend bsl::ostream & operator<<(bsl::ostream &stream, const Datum &rhs)
void apply(t_VISITOR &visitor) const
Definition bdld_datum.h:4616
static Datum createDate(const bdlt::Date &value)
Return, by value, a datum having the specified Date value.
Definition bdld_datum.h:3738
DataType
Definition bdld_datum.h:799
@ DLCT_BOOLEAN
Definition bdld_datum.h:825
@ e_MAP
Definition bdld_datum.h:813
@ e_BINARY
Definition bdld_datum.h:814
@ DLCT_ERROR_VALUE
Definition bdld_datum.h:826
@ DLCT_DATETIME_INTERVAL
Definition bdld_datum.h:830
@ DLCT_DECIMAL64
Definition bdld_datum.h:836
@ DLCT_NIL
Definition bdld_datum.h:821
@ DLCT_DATETIME
Definition bdld_datum.h:829
@ DLCT_TIME
Definition bdld_datum.h:828
@ e_DATETIME_INTERVAL
Definition bdld_datum.h:809
@ e_ARRAY
Definition bdld_datum.h:812
@ e_TIME
Definition bdld_datum.h:807
@ DLCT_ARRAY
Definition bdld_datum.h:833
@ DLCT_INTEGER64
Definition bdld_datum.h:831
@ e_INTEGER
Definition bdld_datum.h:801
@ e_USERDEFINED
Definition bdld_datum.h:811
@ e_DATE
Definition bdld_datum.h:806
@ DLCT_BINARY
Definition bdld_datum.h:835
@ DLCT_USERDEFINED
Definition bdld_datum.h:832
@ DLCT_INTEGER
Definition bdld_datum.h:822
@ DLCT_REAL
Definition bdld_datum.h:823
@ e_ERROR_VALUE
Definition bdld_datum.h:820
@ DLCT_STRING
Definition bdld_datum.h:824
@ e_INT_MAP
Definition bdld_datum.h:816
@ DLCT_MAP
Definition bdld_datum.h:834
@ DLCT_DATE
Definition bdld_datum.h:827
@ e_DECIMAL64
Definition bdld_datum.h:815
@ e_BOOLEAN
Definition bdld_datum.h:804
@ e_DATETIME
Definition bdld_datum.h:808
@ e_REAL
Definition bdld_datum.h:819
@ e_INTEGER64
Definition bdld_datum.h:810
@ e_STRING
Definition bdld_datum.h:803
@ e_DOUBLE
Definition bdld_datum.h:802
@ e_NIL
Definition bdld_datum.h:800
@ e_ERROR
Definition bdld_datum.h:805
bool isDate() const
Definition bdld_datum.h:4137
bool isUdt() const
Definition bdld_datum.h:4251
DatumUdt theUdt() const
Definition bdld_datum.h:4539
static char * createUninitializedString(Datum *result, SizeType length, const AllocatorType &allocator)
static void disposeUninitializedArray(const DatumMutableArrayRef &array, const AllocatorType &allocator)
Definition bdld_datum.h:4064
bool isDatetimeInterval() const
Definition bdld_datum.h:4149
static Datum adoptMap(const DatumMutableMapRef &map)
Definition bdld_datum.h:4014
static Datum createBoolean(bool value)
Return, by value, a datum having the specified bool value.
Definition bdld_datum.h:3723
Datum(const Datum &original)=default
Create a datum having the value of the specified original.
bool isDatetime() const
Definition bdld_datum.h:4143
bool isIntMap() const
Definition bdld_datum.h:4221
bool isTime() const
Definition bdld_datum.h:4245
int theInteger() const
Definition bdld_datum.h:4426
Definition bdldfp_decimal.h:1834
Definition bdlt_date.h:294
Definition bdlt_datetimeinterval.h:201
int days() const
Definition bdlt_datetimeinterval.h:1105
void setTotalMilliseconds(bsls::Types::Int64 milliseconds)
Definition bdlt_datetimeinterval.h:919
bsls::Types::Int64 fractionalDayInMicroseconds() const
Definition bdlt_datetimeinterval.h:1111
int microseconds() const
Definition bdlt_datetimeinterval.h:1144
bsls::Types::Int64 totalMilliseconds() const
Definition bdlt_datetimeinterval.h:1185
Definition bdlt_datetime.h:331
Date date() const
Return the value of the "date" part of this object.
Definition bdlt_datetime.h:2164
int microsecond() const
Return the value of the microsecond attribute of this object.
Definition bdlt_datetime.h:2231
Time time() const
Return the value of the "time" part of this object.
Definition bdlt_datetime.h:2275
Definition bdlt_time.h:196
int addMilliseconds(int milliseconds)
Definition bslma_bslallocator.h:580
Definition bsls_alignedbuffer.h:261
Definition bslstl_stringref.h:372
const CHAR_TYPE * data() const
Definition bslstl_stringref.h:936
size_type length() const
Definition bslstl_stringref.h:958
bsl::ostream & operator<<(bsl::ostream &stream, const bdlat_AttributeInfo &attributeInfo)
BSLS_PLATFORM_COMPILER_ERROR
Definition bdld_datum.h:719
#define BDLD_DATUM_FORCE_INLINE
Definition bdld_datum.h:725
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ANNOTATION_FALLTHROUGH
Definition bsls_annotation.h:412
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:1856
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
void hashAppend(HASH_ALGORITHM &hashAlg, const baljsn::EncoderTestAddress &object)
Definition baljsn_encoder_testtypes.h:9236
bsl::size_t size(const TYPE &array)
Return the number of elements in the specified array.
Definition bdld_datum.h:730
bsl::ostream & operator<<(bsl::ostream &stream, const Datum &rhs)
void hashAppend(t_HASH_ALGORITHM &hashAlgorithm, const Datum &datum)
bool operator==(const Datum &lhs, const Datum &rhs)
bool operator!=(const Datum &lhs, const Datum &rhs)
Decimal_Type64 Decimal64
Definition bdldfp_decimal.h:715
Definition bdlb_printmethods.h:283
BSLS_KEYWORD_CONSTEXPR CONTAINER::value_type * data(CONTAINER &container)
Definition bslstl_iterator.h:1231
bsl::enable_if<(bsl::is_integral< TYPE >::value||bsl::is_pointer< TYPE >::value||bsl::is_enum< TYPE >::value)&&!bsl::is_same< TYPE, bool >::value >::type hashAppend(HASH_ALGORITHM &hashAlg, TYPE input)
Definition bslh_hash.h:638
Definition bslstl_algorithm.h:82
StringRefImp< char > StringRef
Definition bslstl_stringref.h:699
Definition bdlb_printmethods.h:306
Definition bdld_datum.h:3161
Definition bdld_datum.h:747
t_WANT_TO_BE_DEPENDENT type
Definition bdld_datum.h:748
static const Datetime & epoch()
Definition bdlt_epochutil.h:375
Definition bslmf_istriviallycopyable.h:329
Definition bslmf_istriviallydefaultconstructible.h:293
Namespace for utility functions on allocators.
Definition bslma_allocatorutil.h:405
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
This struct is empty and represents a nil type.
Definition bslmf_nil.h:131
std::size_t size_type
Definition bsls_types.h:124
long long Int64
Definition bsls_types.h:132