23 #ifndef LSST_SPHGEOM_CODEC_H_ 24 #define LSST_SPHGEOM_CODEC_H_ 39 #if defined(__x86_64__) 41 auto ptr =
reinterpret_cast<uint8_t
const *
>(&item);
44 union { uint64_t u;
double d };
46 buffer.
push_back(static_cast<uint8_t>(value));
47 buffer.
push_back(static_cast<uint8_t>(value >> 8));
48 buffer.
push_back(static_cast<uint8_t>(value >> 16));
49 buffer.
push_back(static_cast<uint8_t>(value >> 24));
50 buffer.
push_back(static_cast<uint8_t>(value >> 32));
51 buffer.
push_back(static_cast<uint8_t>(value >> 40));
52 buffer.
push_back(static_cast<uint8_t>(value >> 48));
53 buffer.
push_back(static_cast<uint8_t>(value >> 56));
60 #if defined(__x86_64__) 62 return *
reinterpret_cast<double const *
>(buffer);
64 union { uint64_t u;
double d };
65 u =
static_cast<uint64_t
>(buffer[0]) +
66 (static_cast<uint64_t>(buffer[1]) << 8) +
67 (static_cast<uint64_t>(buffer[2]) << 16) +
68 (static_cast<uint64_t>(buffer[3]) << 24) +
69 (static_cast<uint64_t>(buffer[4]) << 32) +
70 (static_cast<uint64_t>(buffer[5]) << 40) +
71 (static_cast<uint64_t>(buffer[6]) << 48) +
72 (static_cast<uint64_t>(buffer[7]) << 56);
79 #endif // LSST_SPHGEOM_CODEC_H_
A base class for image defects.
double decodeDouble(uint8_t const *buffer)
decode extracts an IEEE double from the 8 byte little-endian byte sequence in buffer.
void encodeDouble(double item, std::vector< uint8_t > &buffer)
encode appends an IEEE double in little-endian byte order to the end of buffer.