PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bitwise_enum.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  PBitwiseEnum< BaseEnum, MaxValue, BaseInt >
 This class defines a set of operators for a bit wise enumeration. More...
 

Macros

#define P_BITWISE_ENUM_INTERNAL_OP1(op)   (static_cast<IntType>(m_enum) op static_cast<IntType>(rhs))
 
#define P_BITWISE_ENUM_INTERNAL_OP2(op)   static_cast<Enumeration>(P_BITWISE_ENUM_INTERNAL_OP1(op))
 
#define P_DECLARE_BITWISE_ENUM_1(_0, _1)   _0=0,_1=1
 
#define P_DECLARE_BITWISE_ENUM_2(_0, _1, _2)   P_DECLARE_BITWISE_ENUM_1(_0,_1),_2=2
 
#define P_DECLARE_BITWISE_ENUM_3(_0, _1, _2, _3)   P_DECLARE_BITWISE_ENUM_2(_0,_1,_2),_3=4
 
#define P_DECLARE_BITWISE_ENUM_4(_0, _1, _2, _3, _4)   P_DECLARE_BITWISE_ENUM_3(_0,_1,_2,_3),_4=8
 
#define P_DECLARE_BITWISE_ENUM_5(_0, _1, _2, _3, _4, _5)   P_DECLARE_BITWISE_ENUM_4(_0,_1,_2,_3,_4),_5=16
 
#define P_DECLARE_BITWISE_ENUM_6(_0, _1, _2, _3, _4, _5, _6)   P_DECLARE_BITWISE_ENUM_5(_0,_1,_2,_3,_4,_5),_6=32
 
#define P_DECLARE_BITWISE_ENUM_7(_0, _1, _2, _3, _4, _5, _6, _7)   P_DECLARE_BITWISE_ENUM_6(_0,_1,_2,_3,_4,_5,_6),_7=64
 
#define P_DECLARE_BITWISE_ENUM_8(_0, _1, _2, _3, _4, _5, _6, _7, _8)   P_DECLARE_BITWISE_ENUM_7(_0,_1,_2,_3,_4,_5,_6,_7),_8=128
 
#define P_DECLARE_BITWISE_ENUM_9(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9)   P_DECLARE_BITWISE_ENUM_8(_0,_1,_2,_3,_4,_5,_6,_7,_8),_9=256
 
#define P_DECLARE_BITWISE_ENUM_10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10)   P_DECLARE_BITWISE_ENUM_9(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9),_10=512
 
#define P_DECLARE_BITWISE_ENUM_11(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11)   P_DECLARE_BITWISE_ENUM_10(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10),_11=1024
 
#define P_DECLARE_BITWISE_ENUM_12(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12)   P_DECLARE_BITWISE_ENUM_11(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11),_11=2048
 
#define P_DECLARE_BITWISE_NAMES_1(_0, _1)   #_0,#_1
 
#define P_DECLARE_BITWISE_NAMES_2(_0, _1, _2)   P_DECLARE_BITWISE_NAMES_1(_0,_1),#_2
 
#define P_DECLARE_BITWISE_NAMES_3(_0, _1, _2, _3)   P_DECLARE_BITWISE_NAMES_2(_0,_1,_2),#_3
 
#define P_DECLARE_BITWISE_NAMES_4(_0, _1, _2, _3, _4)   P_DECLARE_BITWISE_NAMES_3(_0,_1,_2,_3),#_4
 
#define P_DECLARE_BITWISE_NAMES_5(_0, _1, _2, _3, _4, _5)   P_DECLARE_BITWISE_NAMES_4(_0,_1,_2,_3,_4),#_5
 
#define P_DECLARE_BITWISE_NAMES_6(_0, _1, _2, _3, _4, _5, _6)   P_DECLARE_BITWISE_NAMES_5(_0,_1,_2,_3,_4,_5),#_6
 
#define P_DECLARE_BITWISE_NAMES_7(_0, _1, _2, _3, _4, _5, _6, _7)   P_DECLARE_BITWISE_NAMES_6(_0,_1,_2,_3,_4,_5,_6),#_7
 
#define P_DECLARE_BITWISE_NAMES_8(_0, _1, _2, _3, _4, _5, _6, _7, _8)   P_DECLARE_BITWISE_NAMES_7(_0,_1,_2,_3,_4,_5,_6,_7),#_8
 
#define P_DECLARE_BITWISE_NAMES_9(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9)   P_DECLARE_BITWISE_NAMES_8(_0,_1,_2,_3,_4,_5,_6,_7,_8),#_9
 
#define P_DECLARE_BITWISE_NAMES_10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10)   P_DECLARE_BITWISE_NAMES_9(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9),#_10
 
#define P_DECLARE_BITWISE_NAMES_11(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11)   P_DECLARE_BITWISE_NAMES_10(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10),#_11
 
#define P_DECLARE_BITWISE_NAMES_12(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12)   P_DECLARE_BITWISE_NAMES_11(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11),#_12
 
#define P_DECLARE_BITWISE_ENUM_FRIENDS(name)
 
#define P_DECLARE_BITWISE_ENUM_END(name, count)
 
#define P_DECLARE_BITWISE_ENUM(name, count, values)
 This macro can be used to declare a bit wise enumeration, using the PBitWiseEnum template class. More...
 
#define P_DECLARE_BITWISE_ENUM_EX(name, count, values,...)
 This macro can be used to declare a bit wise enumeration, using the PBitWiseEnum template class. More...
 

Macro Definition Documentation

#define P_DECLARE_BITWISE_ENUM (   name,
  count,
  values 
)
Value:
enum name##_Bits { P_DECLARE_BITWISE_ENUM_##count values }; \
#define P_DECLARE_BITWISE_ENUM_END(name, count)
Definition: bitwise_enum.h:180

This macro can be used to declare a bit wise enumeration, using the PBitWiseEnum template class.

Example: P_DECLARE_BITWISE_ENUM(MyBitWiseEnum, 3, (ZeroValue, FirstBit, SecondBit, ThirdBit));

Which will decclare the values for an enum MyBitWiseEnum_Bits of ZeroValue = 0, FirstBit = 1, SecondBit = 2, ThirdBit = 4. And the PBitWiseEnum template class will have a typedef to name.

#define P_DECLARE_BITWISE_ENUM_1 (   _0,
  _1 
)    _0=0,_1=1
#define P_DECLARE_BITWISE_ENUM_10 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10 
)    P_DECLARE_BITWISE_ENUM_9(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9),_10=512
#define P_DECLARE_BITWISE_ENUM_11 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  _11 
)    P_DECLARE_BITWISE_ENUM_10(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10),_11=1024
#define P_DECLARE_BITWISE_ENUM_12 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  _11,
  _12 
)    P_DECLARE_BITWISE_ENUM_11(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11),_11=2048
#define P_DECLARE_BITWISE_ENUM_2 (   _0,
  _1,
  _2 
)    P_DECLARE_BITWISE_ENUM_1(_0,_1),_2=2
#define P_DECLARE_BITWISE_ENUM_3 (   _0,
  _1,
  _2,
  _3 
)    P_DECLARE_BITWISE_ENUM_2(_0,_1,_2),_3=4
#define P_DECLARE_BITWISE_ENUM_4 (   _0,
  _1,
  _2,
  _3,
  _4 
)    P_DECLARE_BITWISE_ENUM_3(_0,_1,_2,_3),_4=8
#define P_DECLARE_BITWISE_ENUM_5 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5 
)    P_DECLARE_BITWISE_ENUM_4(_0,_1,_2,_3,_4),_5=16
#define P_DECLARE_BITWISE_ENUM_6 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6 
)    P_DECLARE_BITWISE_ENUM_5(_0,_1,_2,_3,_4,_5),_6=32
#define P_DECLARE_BITWISE_ENUM_7 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7 
)    P_DECLARE_BITWISE_ENUM_6(_0,_1,_2,_3,_4,_5,_6),_7=64
#define P_DECLARE_BITWISE_ENUM_8 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8 
)    P_DECLARE_BITWISE_ENUM_7(_0,_1,_2,_3,_4,_5,_6,_7),_8=128
#define P_DECLARE_BITWISE_ENUM_9 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9 
)    P_DECLARE_BITWISE_ENUM_8(_0,_1,_2,_3,_4,_5,_6,_7,_8),_9=256
#define P_DECLARE_BITWISE_ENUM_END (   name,
  count 
)
Value:
typedef PBitwiseEnum<name##_Bits, (name##_Bits)(1<<(count-1))> name
#define P_DECLARE_BITWISE_ENUM_FRIENDS(name)
Definition: bitwise_enum.h:172
This class defines a set of operators for a bit wise enumeration.
Definition: bitwise_enum.h:39
#define P_DECLARE_BITWISE_ENUM_EX (   name,
  count,
  values,
  ... 
)
Value:
enum name##_Bits { P_DECLARE_BITWISE_ENUM_##count values , ##__VA_ARGS__ }; \
#define P_DECLARE_BITWISE_ENUM_END(name, count)
Definition: bitwise_enum.h:180

This macro can be used to declare a bit wise enumeration, using the PBitWiseEnum template class.

This si similar to P_DECLARE_BITWISE_ENUM but allows extra value to be added to the enum for bit combinations, for example: P_DECLARE_BITWISE_ENUM_EX(MyBitWiseEnum, 3, (ZeroValue, FirstBit, SecondBit, ThirdBit), LowBits = FirstBit|SecondBit, AllBits = FirstBit|SecondBit|ThirdBit);

#define P_DECLARE_BITWISE_ENUM_FRIENDS (   name)
Value:
__inline friend name##_Bits operator+(name##_Bits lhs, name##_Bits rhs) \
{ return static_cast<name##_Bits>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } \
__inline friend name##_Bits operator|(name##_Bits lhs, name##_Bits rhs) \
{ return static_cast<name##_Bits>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } \
__inline friend name##_Bits operator-(name##_Bits lhs, name##_Bits rhs) \
{ return static_cast<name##_Bits>(static_cast<unsigned>(lhs) & ~static_cast<unsigned>(rhs)); }
#define P_DECLARE_BITWISE_NAMES_1 (   _0,
  _1 
)    #_0,#_1
#define P_DECLARE_BITWISE_NAMES_10 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10 
)    P_DECLARE_BITWISE_NAMES_9(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9),#_10
#define P_DECLARE_BITWISE_NAMES_11 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  _11 
)    P_DECLARE_BITWISE_NAMES_10(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10),#_11
#define P_DECLARE_BITWISE_NAMES_12 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  _11,
  _12 
)    P_DECLARE_BITWISE_NAMES_11(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11),#_12
#define P_DECLARE_BITWISE_NAMES_2 (   _0,
  _1,
  _2 
)    P_DECLARE_BITWISE_NAMES_1(_0,_1),#_2
#define P_DECLARE_BITWISE_NAMES_3 (   _0,
  _1,
  _2,
  _3 
)    P_DECLARE_BITWISE_NAMES_2(_0,_1,_2),#_3
#define P_DECLARE_BITWISE_NAMES_4 (   _0,
  _1,
  _2,
  _3,
  _4 
)    P_DECLARE_BITWISE_NAMES_3(_0,_1,_2,_3),#_4
#define P_DECLARE_BITWISE_NAMES_5 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5 
)    P_DECLARE_BITWISE_NAMES_4(_0,_1,_2,_3,_4),#_5
#define P_DECLARE_BITWISE_NAMES_6 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6 
)    P_DECLARE_BITWISE_NAMES_5(_0,_1,_2,_3,_4,_5),#_6
#define P_DECLARE_BITWISE_NAMES_7 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7 
)    P_DECLARE_BITWISE_NAMES_6(_0,_1,_2,_3,_4,_5,_6),#_7
#define P_DECLARE_BITWISE_NAMES_8 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8 
)    P_DECLARE_BITWISE_NAMES_7(_0,_1,_2,_3,_4,_5,_6,_7),#_8
#define P_DECLARE_BITWISE_NAMES_9 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9 
)    P_DECLARE_BITWISE_NAMES_8(_0,_1,_2,_3,_4,_5,_6,_7,_8),#_9