8#ifndef INCLUDED_BSLX_GENERICOUTSTREAM
9#define INCLUDED_BSLX_GENERICOUTSTREAM
333#include <bslscm_version.h>
342#include <bsl_cstddef.h>
343#include <bsl_string.h>
344#include <bsl_vector.h>
362template <
class STREAMBUF>
379 k_SIZEOF_FLOAT64 = 8,
384 STREAMBUF *d_streamBuf;
386 int d_versionSelector;
791 operator const void *()
const;
809template <
class STREAMBUF,
class TYPE>
822template <
class STREAMBUF>
830template <
class STREAMBUF>
834: d_streamBuf(streamBuf)
835, d_versionSelector(versionSelector)
841template <
class STREAMBUF>
848template <
class STREAMBUF>
854 if (0 == d_streamBuf->pubsync()) {
861template <
class STREAMBUF>
868template <
class STREAMBUF>
876 putInt32(length | (1 << 31));
884template <
class STREAMBUF>
889 return putUint8(version);
894template <
class STREAMBUF>
906#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
907 const char *rawBytes =
reinterpret_cast<char *
>(&value);
908 char bytes[k_SIZEOF_INT64];
910 bytes[0] = rawBytes[7];
911 bytes[1] = rawBytes[6];
912 bytes[2] = rawBytes[5];
913 bytes[3] = rawBytes[4];
914 bytes[4] = rawBytes[3];
915 bytes[5] = rawBytes[2];
916 bytes[6] = rawBytes[1];
917 bytes[7] = rawBytes[0];
920 reinterpret_cast<char *
>(&value) +
sizeof value - k_SIZEOF_INT64;
923 if (k_SIZEOF_INT64 == d_streamBuf->sputn(bytes, k_SIZEOF_INT64)) {
930template <
class STREAMBUF>
938template <
class STREAMBUF>
950#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
951 const char *rawBytes =
reinterpret_cast<char *
>(&value);
952 char bytes[k_SIZEOF_INT56];
954 bytes[0] = rawBytes[6];
955 bytes[1] = rawBytes[5];
956 bytes[2] = rawBytes[4];
957 bytes[3] = rawBytes[3];
958 bytes[4] = rawBytes[2];
959 bytes[5] = rawBytes[1];
960 bytes[6] = rawBytes[0];
963 reinterpret_cast<char *
>(&value) +
sizeof value - k_SIZEOF_INT56;
966 if (k_SIZEOF_INT56 == d_streamBuf->sputn(bytes, k_SIZEOF_INT56)) {
973template <
class STREAMBUF>
981template <
class STREAMBUF>
993#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
994 const char *rawBytes =
reinterpret_cast<char *
>(&value);
995 char bytes[k_SIZEOF_INT48];
997 bytes[0] = rawBytes[5];
998 bytes[1] = rawBytes[4];
999 bytes[2] = rawBytes[3];
1000 bytes[3] = rawBytes[2];
1001 bytes[4] = rawBytes[1];
1002 bytes[5] = rawBytes[0];
1005 reinterpret_cast<char *
>(&value) +
sizeof value - k_SIZEOF_INT48;
1008 if (k_SIZEOF_INT48 == d_streamBuf->sputn(bytes, k_SIZEOF_INT48)) {
1015template <
class STREAMBUF>
1023template <
class STREAMBUF>
1035#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
1036 const char *rawBytes =
reinterpret_cast<char *
>(&value);
1037 char bytes[k_SIZEOF_INT40];
1039 bytes[0] = rawBytes[4];
1040 bytes[1] = rawBytes[3];
1041 bytes[2] = rawBytes[2];
1042 bytes[3] = rawBytes[1];
1043 bytes[4] = rawBytes[0];
1046 reinterpret_cast<char *
>(&value) +
sizeof value - k_SIZEOF_INT40;
1049 if (k_SIZEOF_INT40 == d_streamBuf->sputn(bytes, k_SIZEOF_INT40)) {
1056template <
class STREAMBUF>
1064template <
class STREAMBUF>
1076#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
1077 const char *rawBytes =
reinterpret_cast<char *
>(&value);
1078 char bytes[k_SIZEOF_INT32];
1080 bytes[0] = rawBytes[3];
1081 bytes[1] = rawBytes[2];
1082 bytes[2] = rawBytes[1];
1083 bytes[3] = rawBytes[0];
1086 reinterpret_cast<char *
>(&value) +
sizeof value - k_SIZEOF_INT32;
1089 if (k_SIZEOF_INT32 == d_streamBuf->sputn(bytes, k_SIZEOF_INT32)) {
1096template <
class STREAMBUF>
1101 return putInt32(
static_cast<int>(value));
1104template <
class STREAMBUF>
1116#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
1117 const char *rawBytes =
reinterpret_cast<char *
>(&value);
1118 char bytes[k_SIZEOF_INT24];
1120 bytes[0] = rawBytes[2];
1121 bytes[1] = rawBytes[1];
1122 bytes[2] = rawBytes[0];
1125 reinterpret_cast<char *
>(&value) +
sizeof value - k_SIZEOF_INT24;
1128 if (k_SIZEOF_INT24 == d_streamBuf->sputn(bytes, k_SIZEOF_INT24)) {
1135template <
class STREAMBUF>
1140 return putInt24(
static_cast<int>(value));
1143template <
class STREAMBUF>
1155#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
1156 const char *rawBytes =
reinterpret_cast<char *
>(&value);
1157 char bytes[k_SIZEOF_INT16];
1159 bytes[0] = rawBytes[1];
1160 bytes[1] = rawBytes[0];
1163 reinterpret_cast<char *
>(&value) +
sizeof value - k_SIZEOF_INT16;
1166 if (k_SIZEOF_INT16 == d_streamBuf->sputn(bytes, k_SIZEOF_INT16)) {
1173template <
class STREAMBUF>
1178 return putInt16(
static_cast<int>(value));
1181template <
class STREAMBUF>
1193 if (STREAMBUF::traits_type::eof() !=
1194 d_streamBuf->sputc(
static_cast<char>(value))) {
1201template <
class STREAMBUF>
1206 return putInt8(
static_cast<int>(value));
1211template <
class STREAMBUF>
1223#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
1224 const char *rawBytes =
reinterpret_cast<char *
>(&value);
1225 char bytes[k_SIZEOF_FLOAT64];
1227 bytes[0] = rawBytes[
sizeof value - 1];
1228 bytes[1] = rawBytes[
sizeof value - 2];
1229 bytes[2] = rawBytes[
sizeof value - 3];
1230 bytes[3] = rawBytes[
sizeof value - 4];
1231 bytes[4] = rawBytes[
sizeof value - 5];
1232 bytes[5] = rawBytes[
sizeof value - 6];
1233 bytes[6] = rawBytes[
sizeof value - 7];
1234 bytes[7] = rawBytes[
sizeof value - 8];
1236 const char *bytes =
reinterpret_cast<char *
>(&value);
1239 if (k_SIZEOF_FLOAT64 == d_streamBuf->sputn(bytes, k_SIZEOF_FLOAT64)) {
1246template <
class STREAMBUF>
1258#if BSLS_PLATFORM_IS_LITTLE_ENDIAN
1259 const char *rawBytes =
reinterpret_cast<char *
>(&value);
1260 char bytes[k_SIZEOF_FLOAT32];
1262 bytes[0] = rawBytes[
sizeof value - 1];
1263 bytes[1] = rawBytes[
sizeof value - 2];
1264 bytes[2] = rawBytes[
sizeof value - 3];
1265 bytes[3] = rawBytes[
sizeof value - 4];
1267 const char *bytes =
reinterpret_cast<char *
>(&value);
1270 if (k_SIZEOF_FLOAT32 == d_streamBuf->sputn(bytes, k_SIZEOF_FLOAT32)) {
1279template <
class STREAMBUF>
1284 putLength(
static_cast<int>(value.
length()));
1285 return putArrayUint8(value.
data(),
static_cast<int>(value.
length()));
1290template <
class STREAMBUF>
1304 for (; values != end; ++values) {
1311template <
class STREAMBUF>
1326 for (; values != end; ++values) {
1333template <
class STREAMBUF>
1347 for (; values != end; ++values) {
1354template <
class STREAMBUF>
1369 for (; values != end; ++values) {
1376template <
class STREAMBUF>
1390 for (; values != end; ++values) {
1397template <
class STREAMBUF>
1412 for (; values != end; ++values) {
1419template <
class STREAMBUF>
1433 for (; values != end; ++values) {
1440template <
class STREAMBUF>
1455 for (; values != end; ++values) {
1462template <
class STREAMBUF>
1474 const int *end = values + numValues;
1475 for (; values != end; ++values) {
1482template <
class STREAMBUF>
1495 const unsigned int *end = values + numValues;
1496 for (; values != end; ++values) {
1503template <
class STREAMBUF>
1515 const int *end = values + numValues;
1516 for (; values != end; ++values) {
1523template <
class STREAMBUF>
1536 const unsigned int *end = values + numValues;
1537 for (; values != end; ++values) {
1544template <
class STREAMBUF>
1556 const short *end = values + numValues;
1557 for (; values != end; ++values) {
1564template <
class STREAMBUF>
1577 const unsigned short *end = values + numValues;
1578 for (; values != end; ++values) {
1585template <
class STREAMBUF>
1600 if (numValues == d_streamBuf->sputn(values, numValues)) {
1607template <
class STREAMBUF>
1623 if (numValues == d_streamBuf->sputn(
reinterpret_cast<const char *
>(values),
1631template <
class STREAMBUF>
1646 if (numValues == d_streamBuf->sputn(values, numValues)) {
1653template <
class STREAMBUF>
1669 if (numValues == d_streamBuf->sputn(
reinterpret_cast<const char *
>(values),
1679template <
class STREAMBUF>
1692 const double *end = values + numValues;
1693 for (; values != end; ++values) {
1694 putFloat64(*values);
1700template <
class STREAMBUF>
1713 const float *end = values + numValues;
1714 for (; values != end; ++values) {
1715 putFloat32(*values);
1722template <
class STREAMBUF>
1726 return isValid() ? this : 0;
1729template <
class STREAMBUF>
1733 return d_versionSelector;
1736template <
class STREAMBUF>
1744template <
class STREAMBUF,
class TYPE>
Definition bslstl_string.h:1281
size_type length() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:6601
CHAR_TYPE * data() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:6477
Definition bslx_genericoutstream.h:363
GenericOutStream & putFloat32(float value)
Definition bslx_genericoutstream.h:1249
GenericOutStream & putInt32(int value)
Definition bslx_genericoutstream.h:1067
GenericOutStream & putInt56(bsls::Types::Int64 value)
Definition bslx_genericoutstream.h:941
GenericOutStream & putLength(int length)
Definition bslx_genericoutstream.h:871
GenericOutStream & putUint56(bsls::Types::Uint64 value)
Definition bslx_genericoutstream.h:976
GenericOutStream & putArrayInt64(const bsls::Types::Int64 *values, int numValues)
Definition bslx_genericoutstream.h:1292
GenericOutStream & putArrayInt16(const short *values, int numValues)
Definition bslx_genericoutstream.h:1546
GenericOutStream & putUint40(bsls::Types::Uint64 value)
Definition bslx_genericoutstream.h:1059
int bdexVersionSelector() const
Definition bslx_genericoutstream.h:1731
GenericOutStream & putArrayUint48(const bsls::Types::Uint64 *values, int numValues)
Definition bslx_genericoutstream.h:1399
GenericOutStream & putArrayUint32(const unsigned int *values, int numValues)
Definition bslx_genericoutstream.h:1484
GenericOutStream & putUint64(bsls::Types::Uint64 value)
Definition bslx_genericoutstream.h:933
GenericOutStream & putArrayUint40(const bsls::Types::Uint64 *values, int numValues)
Definition bslx_genericoutstream.h:1442
GenericOutStream & putInt64(bsls::Types::Int64 value)
Definition bslx_genericoutstream.h:897
GenericOutStream & putArrayInt48(const bsls::Types::Int64 *values, int numValues)
Definition bslx_genericoutstream.h:1378
GenericOutStream & putVersion(int version)
Definition bslx_genericoutstream.h:887
GenericOutStream & putUint16(unsigned int value)
Definition bslx_genericoutstream.h:1176
GenericOutStream & putArrayInt24(const int *values, int numValues)
Definition bslx_genericoutstream.h:1505
GenericOutStream & putInt16(int value)
Definition bslx_genericoutstream.h:1146
GenericOutStream & putArrayUint56(const bsls::Types::Uint64 *values, int numValues)
Definition bslx_genericoutstream.h:1356
GenericOutStream & putString(const bsl::string &value)
Definition bslx_genericoutstream.h:1282
GenericOutStream & putInt24(int value)
Definition bslx_genericoutstream.h:1107
GenericOutStream & putInt8(int value)
Definition bslx_genericoutstream.h:1184
GenericOutStream & putInt40(bsls::Types::Int64 value)
Definition bslx_genericoutstream.h:1026
GenericOutStream & putUint24(unsigned int value)
Definition bslx_genericoutstream.h:1138
GenericOutStream & putArrayInt32(const int *values, int numValues)
Definition bslx_genericoutstream.h:1464
bool isValid() const
Definition bslx_genericoutstream.h:1738
GenericOutStream & putArrayFloat64(const double *values, int numValues)
Definition bslx_genericoutstream.h:1681
GenericOutStream & putInt48(bsls::Types::Int64 value)
Definition bslx_genericoutstream.h:984
GenericOutStream & putArrayUint16(const unsigned short *values, int numValues)
Definition bslx_genericoutstream.h:1566
void invalidate()
Definition bslx_genericoutstream.h:863
GenericOutStream & putArrayUint64(const bsls::Types::Uint64 *values, int numValues)
Definition bslx_genericoutstream.h:1313
GenericOutStream & putArrayUint24(const unsigned int *values, int numValues)
Definition bslx_genericoutstream.h:1525
GenericOutStream & putFloat64(double value)
Definition bslx_genericoutstream.h:1214
~GenericOutStream()
Destroy this object.
Definition bslx_genericoutstream.h:843
GenericOutStream & flush()
Definition bslx_genericoutstream.h:850
GenericOutStream & putUint48(bsls::Types::Uint64 value)
Definition bslx_genericoutstream.h:1018
GenericOutStream & putArrayFloat32(const float *values, int numValues)
Definition bslx_genericoutstream.h:1702
GenericOutStream & putArrayInt8(const char *values, int numValues)
Definition bslx_genericoutstream.h:1588
GenericOutStream & putUint32(unsigned int value)
Definition bslx_genericoutstream.h:1099
GenericOutStream & putUint8(unsigned int value)
Definition bslx_genericoutstream.h:1204
GenericOutStream & putArrayInt56(const bsls::Types::Int64 *values, int numValues)
Definition bslx_genericoutstream.h:1335
GenericOutStream & putArrayInt40(const bsls::Types::Int64 *values, int numValues)
Definition bslx_genericoutstream.h:1421
GenericOutStream & putArrayUint8(const char *values, int numValues)
Definition bslx_genericoutstream.h:1634
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
STREAM & bdexStreamOut(STREAM &stream, const TYPE &value)
Definition bslx_outstreamfunctions.h:992
Definition bslx_byteinstream.h:377
bsl::ostream & operator<<(bsl::ostream &stream, const ByteInStream &object)
unsigned long long Uint64
Definition bsls_types.h:137
long long Int64
Definition bsls_types.h:132