From 2548ead4f4b740e96c093f07692a50e2bc776f89 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 14 Jul 2011 23:13:46 +0200 Subject: Aesthetic changes to PostgreSQL BIT test --- pgsql/types/traits.hxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pgsql/types/traits.hxx b/pgsql/types/traits.hxx index 20d0445..be45aa8 100644 --- a/pgsql/types/traits.hxx +++ b/pgsql/types/traits.hxx @@ -55,6 +55,10 @@ namespace odb } }; + // The first 4 bytes of the image is a signed int specifying the + // number of significant bits contained by the BIT. The following + // bytes contain the bit data. + // template <> class value_traits { @@ -71,7 +75,11 @@ namespace odb { if (!is_null) { - unsigned char const* d = i + 4; + assert ( + details::endian_traits::ntoh ( + *reinterpret_cast (i)) == 4); + + const unsigned char* d (i + 4); v.a = *d >> 4 & 1; v.b = (*d >> 5) & 1; @@ -146,8 +154,8 @@ namespace odb if (n > b.capacity ()) b.capacity (n); - // PostgreSQL requires all trailing bits of a varbit image - // be zero. + // PostgreSQL requires all trailing bits of a VARBIT image + // to be zero. // std::memset (b.data (), 0, b.capacity ()); -- cgit v1.1