TSDuck v3.38-3699
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
tsEnumUtils.h File Reference

Some utilities on enumeration types. More...

Classes

struct  ts::EnableBitMaskOperators< T >
 This traits is used to enable bitmask operators on an enumeration type. More...
 
struct  ts::underlying_type< T >
 The meta-type ts::underlying_type is a generalization of std::underlying_type which works on integer types as well. More...
 

Namespaces

namespace  ts
 TSDuck namespace, containing all TSDuck classes and functions.
 

Macros

#define TS_ENABLE_BITMASK_OPERATORS(T)
 This macro enables bitmask operators on an enumeration type.
 

Functions

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr bool operator! (ENUM a)
 Boolean "not" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator& (ENUM a, ENUM b)
 Bitmask "and" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator&= (ENUM &a, ENUM b)
 Bitmask "assign and" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator<< (ENUM a, size_t b)
 Bitmask "left shift" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator<<= (ENUM &a, size_t b)
 Bitmask "assign left shift" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator>> (ENUM a, size_t b)
 Bitmask "right shift" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator>>= (ENUM &a, size_t b)
 Bitmask "assign right shift" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator^ (ENUM a, ENUM b)
 Bitmask "xor" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator^= (ENUM &a, ENUM b)
 Bitmask "assign xor" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator| (ENUM a, ENUM b)
 Bitmask "or" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator|= (ENUM &a, ENUM b)
 Bitmask "assign or" operator on enumeration types.
 
template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator~ (ENUM a)
 Bitmask "not" unary operator on enumeration types.
 

Detailed Description

Some utilities on enumeration types.

Macro Definition Documentation

◆ TS_ENABLE_BITMASK_OPERATORS

#define TS_ENABLE_BITMASK_OPERATORS (   T)

This macro enables bitmask operators on an enumeration type.

Parameters
TAn enumeration type or enumeration class.

Example:

enum E {A = 0x01, B = 0x02, C = 0x04};
E e = A | B | C;
e ^= B | C;
#define TS_ENABLE_BITMASK_OPERATORS(T)
This macro enables bitmask operators on an enumeration type.
Definition tsEnumUtils.h:67

Function Documentation

◆ operator~()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator~ ( ENUM  a)
inlineconstexpr

Bitmask "not" unary operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in]aOperand.
Returns
Bitwise "not" a

◆ operator!()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr bool operator! ( ENUM  a)
inlineconstexpr

Boolean "not" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in]aEnumeration value. Typically an expression uing bitmask "and" or "or" operators on ENUM.
Returns
True if a is zero (no flag set).

◆ operator|()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator| ( ENUM  a,
ENUM  b 
)
inlineconstexpr

Bitmask "or" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in]aFirst operand.
[in]bSecond operand.
Returns
Bitwise a "or" b

◆ operator&()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator& ( ENUM  a,
ENUM  b 
)
inlineconstexpr

Bitmask "and" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in]aFirst operand.
[in]bSecond operand.
Returns
Bitwise a "and" b

◆ operator^()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator^ ( ENUM  a,
ENUM  b 
)
inlineconstexpr

Bitmask "xor" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in]aFirst operand.
[in]bSecond operand.
Returns
Bitwise a "xor" b

◆ operator|=()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator|= ( ENUM &  a,
ENUM  b 
)
inline

Bitmask "assign or" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in,out]aVariable to update.
[in]bSecond operand.
Returns
A reference to a.

◆ operator&=()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator&= ( ENUM &  a,
ENUM  b 
)
inline

Bitmask "assign and" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in,out]aVariable to update.
[in]bSecond operand.
Returns
A reference to a.

◆ operator^=()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator^= ( ENUM &  a,
ENUM  b 
)
inline

Bitmask "assign xor" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in,out]aVariable to update.
[in]bSecond operand.
Returns
A reference to a.

◆ operator<<()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator<< ( ENUM  a,
size_t  b 
)
inlineconstexpr

Bitmask "left shift" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in]aEnum value to shift.
[in]bNumber of bits to shift.
Returns
Bitwise a, shifted left b bits.

◆ operator>>()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
constexpr ENUM operator>> ( ENUM  a,
size_t  b 
)
inlineconstexpr

Bitmask "right shift" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in]aEnum value to shift.
[in]bNumber of bits to shift.
Returns
Bitwise a, shifted right b bits.

◆ operator<<=()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator<<= ( ENUM &  a,
size_t  b 
)
inline

Bitmask "assign left shift" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in,out]aEnum variable to shift.
[in]bNumber of bits to shift.
Returns
A reference to a.

◆ operator>>=()

template<typename ENUM , typename std::enable_if< std::is_enum< ENUM >::value &&ts::EnableBitMaskOperators< ENUM >::value >::type * = nullptr>
ENUM & operator>>= ( ENUM &  a,
size_t  b 
)
inline

Bitmask "assign right shift" operator on enumeration types.

Template Parameters
ENUMAn enumeration type or enumeration class.
Parameters
[in,out]aEnum variable to shift.
[in]bNumber of bits to shift.
Returns
A reference to a.