32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
#ifndef __JABYENGINE_IO_CLASS_HELPER_HPP__
|
|
#define __JABYENGINE_IO_CLASS_HELPER_HPP__
|
|
#include "bits.hpp"
|
|
|
|
#define io_class__2option_map(option0, option1, bit_num) \
|
|
constexpr auto& set_##option0() { \
|
|
this->raw_value = bit::clear(this->raw_value, bit_num); \
|
|
return *this;\
|
|
} \
|
|
\
|
|
constexpr auto& set_##option1() { \
|
|
this->raw_value = bit::set(this->raw_value, bit_num); \
|
|
return *this; \
|
|
}
|
|
|
|
#define io_class__2option_map_getter(type, option0, option1, name, bit_num) \
|
|
io_class__2option_map(option0, option1, bit_num) \
|
|
io_class__option_as(type, name, bit_num)
|
|
|
|
#define io_class__option_as(type, name, bit_num) \
|
|
constexpr type get_##name() const { \
|
|
return static_cast<type>(bit::is_set(this->raw_value, bit_num)); \
|
|
}
|
|
|
|
template<typename T>
|
|
static constexpr __always_inline void io_class__volatile_assign(T& dst, const T& src) {
|
|
typedef decltype(dst.raw_value) DST_VALUE;
|
|
|
|
const_cast<volatile DST_VALUE&>(dst.raw_value) = src.raw_value;
|
|
}
|
|
|
|
#endif //!__JABYENGINE_IO_CLASS_HELPER_HPP__
|