Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. #ifndef _CPPOPS_H
  2. #define _CPPOPS_H
  3.  
  4. #define DefCPPOps_Mask(datatype)\
  5. \
  6. static inline datatype operator|=(datatype &lhs, datatype rhs)\
  7. {\
  8.   lhs = (datatype)(((int)lhs) | ((int)rhs));\
  9.   return lhs;\
  10. }\
  11. \
  12. static inline datatype operator&=(datatype &lhs, datatype rhs)\
  13. {\
  14.   lhs = (datatype)(((int)lhs) & ((int)rhs));\
  15.   return lhs;\
  16. }\
  17. \
  18. static inline datatype operator|(datatype lhs, datatype rhs)\
  19. {\
  20.   return (datatype)(((int)lhs) | ((int)rhs));\
  21. }\
  22. \
  23. static inline datatype operator&(datatype lhs, datatype rhs)\
  24. {\
  25.   return (datatype)(((int)lhs) & ((int)rhs));\
  26. }\
  27. \
  28. static inline datatype operator~(datatype rhs)\
  29. {\
  30.   return (datatype)(~((int)rhs));\
  31. }\
  32.  
  33. #define DefCPPOps_Enum(datatype)\
  34. \
  35. static inline datatype operator++(datatype &rhs, int)\
  36. {\
  37.   datatype old = rhs;\
  38.   rhs = (datatype)((int)rhs + 1);\
  39.   return old;\
  40. }\
  41. \
  42. static inline datatype operator--(datatype &rhs, int)\
  43. {\
  44.   datatype old = rhs;\
  45.   rhs = (datatype)((int)rhs - 1);\
  46.   return old;\
  47. }\
  48. \
  49. static inline datatype operator+(datatype lhs, int rhs)\
  50. {\
  51.   return (datatype)((int)lhs + rhs);\
  52. }\
  53. \
  54. static inline datatype operator-(datatype lhs, int rhs)\
  55. {\
  56.   return (datatype)((int)lhs - rhs);\
  57. }\
  58.  
  59. #endif /* _CPPOPS_H */
  60.