BitfieldHelper.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
24 //----------------------------------------------------------------------
25 #ifndef ICL_CORE_BITFIELD_HELPER_H_INCLUDED
26 #define ICL_CORE_BITFIELD_HELPER_H_INCLUDED
27 
29 
30 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
31 # include "icl_core/Deprecate.h"
32 #endif
33 
34 namespace icl_core {
35 
39 template <typename T>
40 void setBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
41 {
42  bitfield = T(int(bitfield) | bits);
43 }
44 
48 template <typename T>
49 void clearBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
50 {
51  bitfield = T(int(bitfield) & ~bits);
52 }
53 
57 template <typename T>
58 bool isBitSet(int bit, typename ConvertToRef<T>::ToConstRef bitfield)
59 {
60  return (bitfield & T(bit)) != 0;
61 }
62 
64 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
65 
70 template <typename T>
71 void SetBits(int bits, typename ConvertToRef<T>::ToRef bitfield) ICL_CORE_GCC_DEPRECATE_STYLE;
72 template <typename T>
73 ICL_CORE_VC_DEPRECATE_STYLE void SetBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
74 {
75  setBits(bits, bitfield);bitfield = T(int(bitfield) | bits);
76 }
77 
82 template <typename T>
83 void ClearBits(int bits, typename ConvertToRef<T>::ToRef bitfield) ICL_CORE_GCC_DEPRECATE_STYLE;
84 template <typename T>
85 ICL_CORE_VC_DEPRECATE_STYLE void ClearBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
86 {
87  clearBits(bits, bitfield);
88 }
89 
94 template <typename T>
95 bool IsBitSet(int bit, typename ConvertToRef<T>::ToConstRef bitfield) ICL_CORE_GCC_DEPRECATE_STYLE;
96 template <typename T>
97 ICL_CORE_VC_DEPRECATE_STYLE bool IsBitSet(int bit, typename ConvertToRef<T>::ToConstRef bitfield)
98 {
99  return isBitSet(bit, bitfield);
100 }
101 
102 #endif
103 
105 }
106 
107 #endif
Helper definitions for template programming.
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
Contains macros to deprecate classes, types, functions and variables.
void setBits(int bits, typename ConvertToRef< T >::ToRef bitfield)
bool isBitSet(int bit, typename ConvertToRef< T >::ToConstRef bitfield)
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54
void clearBits(int bits, typename ConvertToRef< T >::ToRef bitfield)


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58