Go to the documentation of this file.
5 #ifndef UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED
6 #define UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED
23 template <
unsigned BitLen_, Signedness Signedness, CastMode CastMode>
26 struct ErrorNoSuchInteger;
30 enum { BitLen = BitLen_ };
31 enum { MinBitLen = BitLen };
32 enum { MaxBitLen = BitLen };
33 enum { IsPrimitive = 1 };
35 typedef typename Select<(BitLen <= 8), typename Select<IsSigned, int8_t, uint8_t>::Result,
36 typename Select<(BitLen <= 16), typename Select<IsSigned, int16_t, uint16_t>::Result,
37 typename Select<(BitLen <= 32), typename Select<IsSigned, int32_t, uint32_t>::Result,
38 typename Select<(BitLen <= 64), typename Select<IsSigned, int64_t, uint64_t>::Result,
39 ErrorNoSuchInteger>::Result>::Result>::Result>::Result
StorageType;
53 return StorageType((uintmax_t(1) <<
static_cast<unsigned>(BitLen)) - 1U);
57 return StorageType((uintmax_t(1) << (
static_cast<unsigned>(BitLen) - 1U)) - 1);
71 return StorageType((IsSigned == 0) ? 0xFFFFFFFFFFFFFFFFULL : 0x7FFFFFFFFFFFFFFFLL);
84 else if (value <=
min())
122 return codec.
encode<BitLen>(value);
128 return codec.
decode<BitLen>(out_value);
137 template <CastMode CastMode>
141 enum { IsSigned = 0 };
143 enum { MinBitLen = 1 };
144 enum { MaxBitLen = 1 };
145 enum { IsPrimitive = 1 };
160 return codec.
encode<BitLen>(value);
165 return codec.
decode<BitLen>(out_value);
171 template <CastMode CastMode>
174 template <Signedness Signedness, CastMode CastMode>
178 template <
typename T>
184 template <
unsigned BitLen, Signedness Signedness, CastMode CastMode>
191 template <
unsigned BitLen, Signedness Signedness, CastMode CastMode>
198 template <
typename Stream>
203 typename Select<RawType::IsSigned, int, unsigned>::Result >::Result TempType;
204 s << TempType(value);
210 #endif // UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED
TailArrayOptimizationMode
IntegerSpec< BitLen, Signedness, CastMode > RawType
static UnsignedStorageType mask()
static void truncate(StorageType &value)
static int encode(StorageType value, ScalarCodec &codec, TailArrayOptimizationMode)
static int encode(StorageType value, ScalarCodec &codec, TailArrayOptimizationMode)
Select<(BitLen<=8), typename Select< IsSigned, int8_t, uint8_t >::Result, typename Select<(BitLen<=16), typename Select< IsSigned, int16_t, uint16_t >::Result, typename Select<(BitLen<=32), typename Select< IsSigned, int32_t, uint32_t >::Result, typename Select<(BitLen<=64), typename Select< IsSigned, int64_t, uint64_t >::Result, ErrorNoSuchInteger >::Result >::Result >::Result >::Result StorageType
struct UAVCAN_EXPORT StaticAssert
ROSCPP_DECL bool validate(const std::string &name, std::string &error)
static UnsignedStorageType mask()
static void extendDataTypeSignature(DataTypeSignature &)
const UAVCAN_EXPORT T & max(const T &a, const T &b)
struct UAVCAN_EXPORT Select
const UAVCAN_EXPORT T & min(const T &a, const T &b)
static UnsignedStorageType mask()
static int decode(StorageType &out_value, ScalarCodec &codec, TailArrayOptimizationMode)
static void stream(Stream &s, const StorageType value, int)
Select<(BitLen==64), LimitsImpl64, LimitsImplGeneric >::Result Limits
static int decode(StorageType &out_value, ScalarCodec &codec, TailArrayOptimizationMode)
class UAVCAN_EXPORT YamlStreamer
static void saturate(StorageType &value)
IntegerSpec< BitLen, SignednessUnsigned, CastMode >::StorageType UnsignedStorageType
int encode(const T value)
RawType::StorageType StorageType
static UnsignedStorageType mask()
static void extendDataTypeSignature(DataTypeSignature &)