142 lines
4.1 KiB
C++
142 lines
4.1 KiB
C++
/* Generated SBE (Simple Binary Encoding) message codec */
|
|
#ifndef _ILINKBINARY_EXECMODE_H_
|
|
#define _ILINKBINARY_EXECMODE_H_
|
|
|
|
#if defined(SBE_HAVE_CMATH)
|
|
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
|
# include <cmath>
|
|
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
|
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
|
#else
|
|
/* math.h needed for NAN */
|
|
# include <math.h>
|
|
# define SBE_FLOAT_NAN NAN
|
|
# define SBE_DOUBLE_NAN NAN
|
|
#endif
|
|
|
|
#if __cplusplus >= 201103L
|
|
# define SBE_CONSTEXPR constexpr
|
|
# define SBE_NOEXCEPT noexcept
|
|
#else
|
|
# define SBE_CONSTEXPR
|
|
# define SBE_NOEXCEPT
|
|
#endif
|
|
|
|
#if __cplusplus >= 201402L
|
|
# define SBE_CONSTEXPR_14 constexpr
|
|
#else
|
|
# define SBE_CONSTEXPR_14
|
|
#endif
|
|
|
|
#if __cplusplus >= 201703L
|
|
# include <string_view>
|
|
# define SBE_NODISCARD [[nodiscard]]
|
|
#else
|
|
# define SBE_NODISCARD
|
|
#endif
|
|
|
|
#if !defined(__STDC_LIMIT_MACROS)
|
|
# define __STDC_LIMIT_MACROS 1
|
|
#endif
|
|
|
|
#include <cstdint>
|
|
#include <cstring>
|
|
#include <iomanip>
|
|
#include <limits>
|
|
#include <ostream>
|
|
#include <stdexcept>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#if defined(WIN32) || defined(_WIN32)
|
|
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
|
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
|
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
|
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
|
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
|
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
|
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
|
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
|
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
|
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
|
#else
|
|
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
|
#endif
|
|
|
|
#if defined(SBE_NO_BOUNDS_CHECK)
|
|
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
|
#elif defined(_MSC_VER)
|
|
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
|
#else
|
|
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
|
#endif
|
|
|
|
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
|
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
|
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
|
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
|
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
|
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
|
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
|
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
|
|
|
|
|
namespace iLinkBinary {
|
|
|
|
class ExecMode
|
|
{
|
|
public:
|
|
enum Value
|
|
{
|
|
Aggressive = (char)65,
|
|
Passive = (char)80,
|
|
NULL_VALUE = (char)0
|
|
};
|
|
|
|
static ExecMode::Value get(const char value)
|
|
{
|
|
switch (value)
|
|
{
|
|
case 65: return Aggressive;
|
|
case 80: return Passive;
|
|
case 0: return NULL_VALUE;
|
|
}
|
|
|
|
throw std::runtime_error("unknown value for enum ExecMode [E103]");
|
|
}
|
|
|
|
static const char* c_str(const ExecMode::Value value)
|
|
{
|
|
switch (value)
|
|
{
|
|
case Aggressive: return "Aggressive";
|
|
case Passive: return "Passive";
|
|
case NULL_VALUE: return "NULL_VALUE";
|
|
}
|
|
|
|
throw std::runtime_error("unknown value for enum ExecMode [E103]:");
|
|
}
|
|
|
|
template<typename CharT, typename Traits>
|
|
friend std::basic_ostream<CharT, Traits>& operator << (
|
|
std::basic_ostream<CharT, Traits>& os, ExecMode::Value m)
|
|
{
|
|
return os << ExecMode::c_str(m);
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|