12 #ifndef __BYTE_OPERATION_HEADER
13 #define __BYTE_OPERATION_HEADER
17 typedef uint8_t byte_op_size_type;
20 inline void clear_byte(T & t, detail::byte_op_size_type
const & pos) {
21 uint8_t *
p = (uint8_t *) & t;
25 inline uint8_t
read_byte(T
const & t, detail::byte_op_size_type
const & pos) {
26 uint8_t *
p = (uint8_t *) & t;
30 inline void write_byte(T & t, detail::byte_op_size_type
const & pos, uint8_t
const & in) {
31 uint8_t *
p = (uint8_t *) & t;
36 inline bool read_bit(T
const & unit, uint8_t
const & pos) {
37 return (unit & (T(1) << pos));
40 inline void set_bit(T & unit, uint8_t
const & pos) {
41 unit |= (T(1) << pos);
44 inline void clear_bit(T & unit, uint8_t
const & pos) {
45 unit &= ~(T(1) << pos);
48 inline void write_bit(T & unit, uint8_t
const & pos,
bool state =
true) {
52 inline void flip_bit(T & unit, uint8_t
const & pos) {
53 unit ^= (T(1) << pos);
56 #endif //__BYTE_OPERATION_HEADER
void clear_byte(T &t, detail::byte_op_size_type const &pos)
Definition: byte_operation.hpp:20
uint8_t read_byte(T const &t, detail::byte_op_size_type const &pos)
Definition: byte_operation.hpp:25
void clear_bit(T &unit, uint8_t const &pos)
Definition: byte_operation.hpp:44
void write_bit(T &unit, uint8_t const &pos, bool state=true)
Definition: byte_operation.hpp:48
void write_byte(T &t, detail::byte_op_size_type const &pos, uint8_t const &in)
Definition: byte_operation.hpp:30
void flip_bit(T &unit, uint8_t const &pos)
Definition: byte_operation.hpp:52
void set_bit(T &unit, uint8_t const &pos)
Definition: byte_operation.hpp:40
bool read_bit(T const &unit, uint8_t const &pos)
Definition: byte_operation.hpp:36