Skip to content

Commit d83374f

Browse files
committed
[C++]: for #506 made all accesses of fields use memcpy instead of casts so that alignment isn't an issue. For #530 used a union to do byte swap on float and double accesses for single values and arrays.
1 parent 2b2ee00 commit d83374f

File tree

2 files changed

+169
-45
lines changed

2 files changed

+169
-45
lines changed

sbe-tool/src/main/cpp/sbe/sbe.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
#include <cstdint>
2727
#include <limits>
2828

29-
namespace sbe {
29+
namespace sbe
30+
{
3031

3132
/*
3233
* Define some byte ordering macros
@@ -73,7 +74,22 @@ namespace sbe {
7374
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
7475
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
7576

76-
namespace MetaAttribute {
77+
typedef union sbe_float_as_uint_u
78+
{
79+
float fp_value;
80+
std::uint32_t uint_value;
81+
}
82+
sbe_float_as_uint_t;
83+
84+
typedef union sbe_double_as_uint_u
85+
{
86+
double fp_value;
87+
std::uint64_t uint_value;
88+
}
89+
sbe_double_as_uint_t;
90+
91+
namespace MetaAttribute
92+
{
7793

7894
enum Attribute
7995
{
@@ -84,7 +100,6 @@ enum Attribute
84100
};
85101

86102
}
87-
88103
}
89104

90105
#endif

0 commit comments

Comments
 (0)