入力データにビットごとにアクセスするクラス
Revision 0:0ee1a4a231ac, committed 2016-08-04
- Comitter:
- moneneholic
- Date:
- Thu Aug 04 00:45:20 2016 +0000
- Commit message:
- FirstVer
Changed in this revision
BitAccess.cpp | Show annotated file Show diff for this revision Revisions of this file |
BitAccess.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BitAccess.cpp Thu Aug 04 00:45:20 2016 +0000 @@ -0,0 +1,62 @@ +#include "BitAccess.h" + +BitAccess::BitAccess(){ + b0 = 0; + b1 = 0; + b2 = 0; + b3 = 0; + b4 = 0; + b5 = 0; + b6 = 0; + b7 = 0; +} + +void BitAccess::setByte(char data){ + if(data & 1 << 0){ + b0 = 1; + }else{ + b0 = 0; + } + + if(data & 1 << 1){ + b1 = 1; + }else{ + b1 = 0; + } + + if(data & 1 << 2){ + b2 = 1; + }else{ + b2 = 0; + } + + if(data & 1 << 3){ + b3 = 1; + }else{ + b3 = 0; + } + + if(data & 1 << 4){ + b4 = 1; + }else{ + b4 = 0; + } + + if(data & 1 << 5){ + b5 = 1; + }else{ + b5 = 0; + } + + if(data & 1 << 6){ + b6 = 1; + }else{ + b6 = 0; + } + + if(data & 1 << 7){ + b7 = 1; + }else{ + b7 = 0; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BitAccess.h Thu Aug 04 00:45:20 2016 +0000 @@ -0,0 +1,18 @@ +/*共用体を使用せず変数にビット単位でアクセスするためのライブラリ*/ + +class BitAccess +{ +public: + BitAccess(); + void setByte(char data); + bool b0; + bool b1; + bool b2; + bool b3; + bool b4; + bool b5; + bool b6; + bool b7; +private: + unsigned char Byte; +}; \ No newline at end of file