TNB Library
TnbBitFlag.h
[詳解]
1#pragma once
11#include "TnbStr.h"
12#include "TnbStaticMap.h"
13
14
15
16//TNB Library
17namespace TNB
18{
19
20
21
35{
36public:
37
42 CAbstructBitFlag(DWORD flag = 0) : m_flag(flag)
43 {
44 }
45
50 operator DWORD(void) const
51 {
52 return m_flag;
53 }
54
62 bool IsValid(DWORD fg) const
63 {
64 return ((m_flag & fg) == fg);
65 }
66
73 bool IsValidByBitNo(DWORD bn) const
74 {
75 return (m_flag & _BIT(bn)) != 0;
76 }
77
82 void Valid(DWORD fg)
83 {
84 m_flag |= fg;
85 }
86
91 void Invalid(DWORD fg)
92 {
93 m_flag &= ~fg;
94 }
95
101 CStr ToString(void) const
102 {
103 CStr s;
104 DWORD flag = m_flag;
105 DWORD bf;
106 CStr name;
107 INDEX index = 0;
108 while ( Table(bf, name, index) )
109 {
110 if ( (flag & bf) == bf )
111 {
112 s += _T("(") + name + _T(")");
113 flag &= ~bf;
114 }
115 index++;
116 }
117 return s;
118 }
119
120protected:
121
130 virtual bool Table(DWORD& _bf, CStr& _name, INDEX index) const = 0;
131
132private:
133 DWORD m_flag;
134
135};
136
137
138
148{
149 DEFSUPER(CAbstructBitFlag);
150public:
151
156 CWindowStyleBitFlag(DWORD flag = 0) : _super(flag)
157 {
158 }
159
160protected:
161
170 virtual bool Table(DWORD& _bf, CStr& _name, INDEX index) const
171 {
172 const static CStaticMapT<DWORD ,LPCTSTR> maps[] =
173 {
174 #ifndef _TnbDOXYGEN
175 #define _X(XX) {XX, _T(#XX)}
176 _X(WS_POPUP),
177 _X(WS_CHILD),
178 _X(WS_MINIMIZE),
179 _X(WS_VISIBLE),
180 _X(WS_DISABLED),
181 _X(WS_CLIPSIBLINGS),
182 _X(WS_CLIPCHILDREN),
183 _X(WS_MAXIMIZE),
184 _X(WS_CAPTION),
185 _X(WS_BORDER),
186 _X(WS_DLGFRAME),
187 _X(WS_VSCROLL),
188 _X(WS_HSCROLL),
189 _X(WS_SYSMENU),
190 _X(WS_THICKFRAME),
191 _X(WS_MINIMIZEBOX),
192 _X(WS_MAXIMIZEBOX),
193 #undef _X
194 #endif //_TnbDOXYGEN
195 };
196 LPCTSTR lpsz = NULL;
197 if ( CStaticMapT<DWORD, LPCTSTR>::Get(_bf, lpsz, index, maps) )
198 {
199 _name = lpsz;
200 return true;
201 }
202 return false;
203 }
204};
205
206
207
208}; //TNB
#define _BIT(X)
BIT演算
Definition: TnbDef.h:307
静的簡易マップ管理関係のヘッダ
文字列管理関係のヘッダ
BITフラグ管理抽象クラス
Definition: TnbBitFlag.h:35
void Valid(DWORD fg)
[設定] 有効.
Definition: TnbBitFlag.h:82
CAbstructBitFlag(DWORD flag=0)
コンストラクタ.
Definition: TnbBitFlag.h:42
void Invalid(DWORD fg)
[設定] 無効.
Definition: TnbBitFlag.h:91
virtual bool Table(DWORD &_bf, CStr &_name, INDEX index) const =0
[取得] テーブル取得.
CStr ToString(void) const
[取得] 文字列化.
Definition: TnbBitFlag.h:101
bool IsValidByBitNo(DWORD bn) const
[確認] 確認.
Definition: TnbBitFlag.h:73
bool IsValid(DWORD fg) const
[確認] 確認.
Definition: TnbBitFlag.h:62
静的簡易マップクラス.
Definition: TnbStaticMap.h:52
Windowスタイル管理クラス
Definition: TnbBitFlag.h:148
virtual bool Table(DWORD &_bf, CStr &_name, INDEX index) const
[取得] テーブル取得.
Definition: TnbBitFlag.h:170
CWindowStyleBitFlag(DWORD flag=0)
コンストラクタ.
Definition: TnbBitFlag.h:156
TNB Library
Definition: TnbDoxyTitle.txt:2