水無瀬の部屋 > Programming > sample > tools > misc > binary.h |
---|
1: //*********************************************************
2: // プロジェクト: binary
3: // ファイル名: binary.h
4: //*********************************************************
5: #ifndef BINARY_HEAD_INCLUDED
6: #define BINARY_HEAD_INCLUDED
7:
8:
9: //*********************************************************
10: // コンパイル環境の指定
11: //*********************************************************
12: #ifndef PRIVATE_TOOLS_HEAD_INCLUDED // 冗長ガード
13: #include <header/_tools.h>
14: #ifndef PRIVATE_TOOLS_HEAD_INCLUDED // ガード名の検査
15: #error "? PRIVATE_TOOLS_HEAD_INCLUDED"
16: #endif // #ifndef PRIVATE_TOOLS_HEAD_INCLUDED
17: #endif // #ifndef PRIVATE_TOOLS_HEAD_INCLUDED
18:
19:
20: //*********************************************************
21: // マクロ の 定義
22: //*********************************************************
23: #define CONST_BINARY_0000 ( 0x0 )
24: #define CONST_BINARY_0001 ( 0x1 )
25: #define CONST_BINARY_0010 ( 0x2 )
26: #define CONST_BINARY_0011 ( 0x3 )
27: #define CONST_BINARY_0100 ( 0x4 )
28: #define CONST_BINARY_0101 ( 0x5 )
29: #define CONST_BINARY_0110 ( 0x6 )
30: #define CONST_BINARY_0111 ( 0x7 )
31: #define CONST_BINARY_1000 ( 0x8 )
32: #define CONST_BINARY_1001 ( 0x9 )
33: #define CONST_BINARY_1010 ( 0xA )
34: #define CONST_BINARY_1011 ( 0xB )
35: #define CONST_BINARY_1100 ( 0xC )
36: #define CONST_BINARY_1101 ( 0xD )
37: #define CONST_BINARY_1110 ( 0xE )
38: #define CONST_BINARY_1111 ( 0xF )
39:
40: #define BINARY_4BIT( a ) CONST_BINARY_ ## a
41: #define BINARY_8BIT( a, b ) ((unsigned char)( ((0x0F & (BINARY_4BIT( a ))) << 4) | (0x0F & (BINARY_4BIT( b ))) ))
42: #define BINARY_16BIT( a, b, c, d ) ((unsigned short)( ((0xFF & (BINARY_8BIT( a, b ))) << 8) | (0xFF & (BINARY_8BIT( c, d ))) ))
43: #define BINARY_32BIT( a, b, c, d, e, f, g, h ) ((unsigned long)( ((0xFFFF & (BINARY_16BIT( a, b, c, d ))) << 16) | (0xFFFF & (BINARY_16BIT( e, f, g, h ))) ))
44:
45:
46: #endif // #ifndef BINARY_HEAD_INCLUDED
47:
48:
49: //** end **
参照:
binary.cpp, crc16.cpp, crc32.cpp
水無瀬の部屋 > sample > tools > misc > binary.h |
---|
このページは cpp2web が出力しました。
水無瀬 優 postmaster@katsura-kotonoha.sakura.ne.jp
http://katsura-kotonoha.sakura.ne.jp/prog/code/tools/misc/binary_h.shtml