Solution46
LibUtility.h
[詳解]
1 //=============================================================================
2 /// @file
3 /// ユーティリティライブラリヘッダファイル
4 ///
5 /// ユーティリティライブラリヘッダファイルです。
6 ///
7 /// $Id: LibUtility.h 249 2019-03-21 18:16:30Z admin $
8 /// $Date: 2019-03-22 03:16:30 +0900 (2019/03/22 (金)) $
9 /// $Author: admin $
10 ///
11 /// @attention なし
12 
13 #pragma once
14 #pragma managed( push, off )
15 
16 //=============================================================================
17 // インクルードファイル
18 #include <LibCommonDef.h>
19 
20 //=============================================================================
21 // マクロ定義
22 #define NotifyFatalError() LibCommon::UtilNotifyFatalError(__FILEW__,__FUNCTIONW__,__LINE__) ///< 致命的エラー発生通知マクロ
23 #define NotifyDllMain(...) LibCommon::UtilNotifyDllMain(__VA_ARGS__) ///< DLLメイン関数実行通知マクロ
24 #define NotifyConstructor() LibCommon::UtilNotifyConstructor(__FUNCTIONW__) ///< コンストラクタ実行通知マクロ
25 #define NotifyDestructor() LibCommon::UtilNotifyDestructor(__FUNCTIONW__) ///< デストラクタ実行通知マクロ
26 
27 //=============================================================================
28 // 共通ライブラリ名前空間
29 namespace LibCommon {
30  //=========================================================================
31  // グローバル型定義
32  //-------------------------------------------------------------------------
33  /// ウィンドウ表示位置種別列挙体
34  ///
35  /// ウィンドウ表示位置種別列挙体です。
36  ///
37  /// @attention なし
38  ///
39  enum class EWindowPosition {
40  Left, ///< 左
41  Top, ///< 上
42  Right, ///< 右
43  Bottom, ///< 下
44  Full, ///< フルサイズ
45  Size ///< 列挙体サイズ
46  };
47 
48  //=========================================================================
49  // グローバル関数
50  //-------------------------------------------------------------------------
51  /// 致命的エラー発生通知関数
52  ///
53  /// 致命的エラー発生通知関数です。
54  ///
55  /// @param[in] pszFileName ファイル名
56  /// @param[in] pszFuncName 関数名
57  /// @param[in] uLineNumber 行番号
58  /// @return なし
59  /// @attention なし
60  ///
61  LIB_COMMON_API void UtilNotifyFatalError( wchar_t const* pszFileName, wchar_t const* pszFuncName, UINT uLineNumber ) noexcept;
62 
63  //-------------------------------------------------------------------------
64  /// DLLメイン関数実行通知関数
65  ///
66  /// DLLメイン関数実行通知関数です。
67  ///
68  /// @param[in] hInstance DLLモジュールハンドル
69  /// @param[in] dwReason 関数を呼び出す理由
70  /// @return なし
71  /// @attention なし
72  ///
73  LIB_COMMON_API void UtilNotifyDllMain( HINSTANCE hInstance, DWORD dwReason ) noexcept;
74 
75  //-------------------------------------------------------------------------
76  /// コンストラクタ実行通知関数
77  ///
78  /// コンストラクタ実行通知関数です。
79  ///
80  /// @param[in] pszFuncName 関数名
81  /// @return なし
82  /// @attention なし
83  ///
84  LIB_COMMON_API void UtilNotifyConstructor( wchar_t const* pszFuncName ) noexcept;
85 
86  //-------------------------------------------------------------------------
87  /// デストラクタ実行通知関数
88  ///
89  /// デストラクタ実行通知関数です。
90  ///
91  /// @param[in] pszFuncName 関数名
92  /// @return なし
93  /// @attention なし
94  ///
95  LIB_COMMON_API void UtilNotifyDestructor( wchar_t const* pszFuncName ) noexcept;
96 
97  //-------------------------------------------------------------------------
98  /// メッセージ表示関数
99  ///
100  /// メッセージ表示関数です。
101  ///
102  /// @param[in] pszMessage メッセージ文字列
103  /// @param[in] hWnd ウィンドウハンドル
104  /// @param[in] uType メッセージ種別
105  /// @return 実行結果
106  /// @attention なし
107  ///
108  LIB_COMMON_API int ShowMessage( wchar_t const* pszMessage, HWND hWnd = nullptr, UINT uType = ( MB_OK | MB_ICONEXCLAMATION ) ) noexcept;
109 
110  //-------------------------------------------------------------------------
111  /// デバッグ出力関数
112  ///
113  /// デバッグ出力関数です。
114  ///
115  /// @param[in] pszFormat 書式設定文字列
116  /// @param[in] ... 可変長引数リスト
117  /// @return なし
118  /// @attention なし
119  ///
120  LIB_COMMON_API void OutputDebugFormat( wchar_t const* pszFormat, ... ) noexcept;
121 
122  //-------------------------------------------------------------------------
123  /// 書式設定文字列展開関数
124  ///
125  /// 書式設定文字列展開関数です。
126  ///
127  /// @param[out] pszBuffer 文字列バッファポインタ
128  /// @param[in] uSize バッファサイズ
129  /// @param[in] pszFormat 書式設定文字列
130  /// @param[in] vaArgs 引数リスト
131  /// @return 実行結果
132  /// - true 成功
133  /// - false 失敗
134  /// @attention なし
135  ///
136  LIB_COMMON_API bool ExpandFormatArgs( wchar_t* pszBuffer, size_t uSize, wchar_t const* pszFormat, va_list vaArgs ) noexcept;
137 
138  //-------------------------------------------------------------------------
139  /// 実行ファイルパス取得関数
140  ///
141  /// 実行ファイルパス取得関数です。
142  ///
143  /// @param[in] pszBuffer 文字列バッファポインタ
144  /// @param[in] uSize バッファサイズ
145  /// @return 文字列ポインタ
146  /// @attention なし
147  ///
148  LIB_COMMON_API wchar_t const* GetExeFilePath( wchar_t* pszBuffer, size_t uSize ) noexcept;
149 
150  //-------------------------------------------------------------------------
151  /// 実行ファイルディレクトリパス取得関数
152  ///
153  /// 実行ファイルディレクトリパス取得関数です。
154  ///
155  /// @param[in] pszBuffer 文字列バッファポインタ
156  /// @param[in] uSize バッファサイズ
157  /// @return 文字列ポインタ
158  /// @attention なし
159  ///
160  LIB_COMMON_API wchar_t const* GetExeFileDir( wchar_t* pszBuffer, size_t uSize ) noexcept;
161 
162  //-------------------------------------------------------------------------
163  /// 実行ファイル名取得関数
164  ///
165  /// 実行ファイル名取得関数です。
166  ///
167  /// @param[in] pszBuffer 文字列バッファポインタ
168  /// @param[in] uSize バッファサイズ
169  /// @return 文字列ポインタ
170  /// @attention なし
171  ///
172  LIB_COMMON_API wchar_t const* GetExeFileName( wchar_t* pszBuffer, size_t uSize ) noexcept;
173 
174  //-------------------------------------------------------------------------
175  /// ディレクトリパス取得関数
176  ///
177  /// ディレクトリパス取得関数です。
178  ///
179  /// @param[in] pszBuffer 文字列バッファポインタ
180  /// @param[in] uSize バッファサイズ
181  /// @param[in] pszPath ファイルパス
182  /// @return 文字列ポインタ
183  /// @attention なし
184  ///
185  LIB_COMMON_API wchar_t const* GetDirPath( wchar_t* pszBuffer, size_t uSize, wchar_t const* pszPath ) noexcept;
186 
187  //-------------------------------------------------------------------------
188  /// ファイル名取得関数
189  ///
190  /// ファイル名取得関数です。
191  ///
192  /// @param[in] pszBuffer 文字列バッファポインタ
193  /// @param[in] uSize バッファサイズ
194  /// @param[in] pszPath ファイルパス
195  /// @return 文字列ポインタ
196  /// @attention なし
197  ///
198  LIB_COMMON_API wchar_t const* GetFileName( wchar_t* pszBuffer, size_t uSize, wchar_t const* pszPath ) noexcept;
199 
200  //-------------------------------------------------------------------------
201  /// モジュール名取得関数
202  ///
203  /// モジュール名取得関数です。
204  ///
205  /// @param[in] hInstance インスタンスハンドル
206  /// @param[in] pszBuffer 文字列バッファポインタ
207  /// @param[in] uSize バッファサイズ
208  /// @return 文字列ポインタ
209  /// @attention なし
210  ///
211  LIB_COMMON_API wchar_t const* GetModuleName( HINSTANCE hInstance, wchar_t* pszBuffer = nullptr, size_t uSize = 0 ) noexcept;
212 
213  //---------------------------------------------------------------------
214  /// 文字コード比較関数
215  ///
216  /// 文字コード比較関数です。
217  ///
218  /// @param[in] ch1 比較元文字コード
219  /// @param[in] ch2 比較先文字コード
220  /// @param[in] bIgnore 最小文字無視フラグ
221  /// @return 比較結果
222  /// - true 一致
223  /// - false 不一致
224  /// @attention なし
225  ///
226  LIB_COMMON_API bool CompareCharCode( wchar_t ch1, wchar_t ch2, bool bIgnore ) noexcept;
227 
228  //---------------------------------------------------------------------
229  /// 文字コード比較関数
230  ///
231  /// 文字コード比較関数です。
232  ///
233  /// @param[in] ch 比較元文字コード
234  /// @param[in] pszString 比較先文字列ポインタ
235  /// @param[in] bIgnore 最小文字無視フラグ
236  /// @return 比較結果
237  /// - true 一致
238  /// - false 不一致
239  /// @attention なし
240  ///
241  LIB_COMMON_API bool CompareCharCode( wchar_t ch, wchar_t const* pszString, bool bIgnore ) noexcept;
242 
243  //-------------------------------------------------------------------------
244  /// ウィンドウ表示位置設定関数
245  ///
246  /// ウィンドウ表示位置設定関数です。
247  ///
248  /// @param[in] hWnd ウィンドウハンドル
249  /// @param[in] ePos ウィンドウ表示位置種別
250  /// @return 実行結果
251  /// - true 成功
252  /// - false 失敗
253  /// @attention なし
254  ///
255  LIB_COMMON_API bool SetWindowPosition( HWND hWnd, EWindowPosition ePos ) noexcept;
256 
257  //-------------------------------------------------------------------------
258  /// プロセス検索関数
259  ///
260  /// プロセス検索関数です。
261  ///
262  /// @param[in] pszPath プロセス実行ファイルパス
263  /// @return プロセス識別子
264  /// @attention なし
265  ///
266  LIB_COMMON_API DWORD SearchProcess( wchar_t const* pszPath );
267 }
268 
269 #pragma managed( pop )
LIB_COMMON_API void UtilNotifyDllMain(HINSTANCE hInstance, DWORD dwReason) noexcept
DLLメイン関数実行通知関数
Definition: LibUtility.cpp:71
LIB_COMMON_API bool CompareCharCode(wchar_t ch1, wchar_t ch2, bool bIgnore) noexcept
文字コード比較関数
Definition: LibUtility.cpp:393
LIB_COMMON_API int ShowMessage(wchar_t const *pszMessage, HWND hWnd=nullptr, UINT uType=(MB_OK|MB_ICONEXCLAMATION)) noexcept
メッセージ表示関数
Definition: LibUtility.cpp:144
LIB_COMMON_API void UtilNotifyConstructor(wchar_t const *pszFuncName) noexcept
コンストラクタ実行通知関数
Definition: LibUtility.cpp:110
EWindowPosition
ウィンドウ表示位置種別列挙体
Definition: LibUtility.h:39
LIB_COMMON_API bool ExpandFormatArgs(wchar_t *pszBuffer, size_t uSize, wchar_t const *pszFormat, va_list vaArgs) noexcept
書式設定文字列展開関数
Definition: LibUtility.cpp:195
共通ライブラリ定義ヘッダファイル
共通ライブラリ名前空間
Definition: CArray.h:23
LIB_COMMON_API void UtilNotifyDestructor(wchar_t const *pszFuncName) noexcept
デストラクタ実行通知関数
Definition: LibUtility.cpp:127
LIB_COMMON_API wchar_t const * GetDirPath(wchar_t *pszBuffer, size_t uSize, wchar_t const *pszPath) noexcept
ディレクトリパス取得関数
Definition: LibUtility.cpp:296
LIB_COMMON_API wchar_t const * GetModuleName(HINSTANCE hInstance, wchar_t *pszBuffer=nullptr, size_t uSize=0) noexcept
モジュール名取得関数
Definition: LibUtility.cpp:366
LIB_COMMON_API void UtilNotifyFatalError(wchar_t const *pszFileName, wchar_t const *pszFuncName, UINT uLineNumber) noexcept
致命的エラー発生通知関数
Definition: LibUtility.cpp:28
LIB_COMMON_API void OutputDebugFormat(wchar_t const *pszFormat,...) noexcept
デバッグ出力関数
Definition: LibUtility.cpp:165
LIB_COMMON_API wchar_t const * GetExeFileName(wchar_t *pszBuffer, size_t uSize) noexcept
実行ファイル名取得関数
Definition: LibUtility.cpp:272
LIB_COMMON_API wchar_t const * GetExeFilePath(wchar_t *pszBuffer, size_t uSize) noexcept
実行ファイルパス取得関数
Definition: LibUtility.cpp:225
LIB_COMMON_API wchar_t const * GetExeFileDir(wchar_t *pszBuffer, size_t uSize) noexcept
実行ファイルディレクトリパス取得関数
Definition: LibUtility.cpp:248
LIB_COMMON_API DWORD SearchProcess(wchar_t const *pszPath)
プロセス検索関数
Definition: LibUtility.cpp:507
#define LIB_COMMON_API
ダイナミックライブラリインポート宣言
Definition: LibCommonDef.h:44
LIB_COMMON_API bool SetWindowPosition(HWND hWnd, EWindowPosition ePos) noexcept
ウィンドウ表示位置設定関数
Definition: LibUtility.cpp:452
LIB_COMMON_API wchar_t const * GetFileName(wchar_t *pszBuffer, size_t uSize, wchar_t const *pszPath) noexcept
ファイル名取得関数
Definition: LibUtility.cpp:331