Solution46
CDebug.h
[詳解]
1 //=============================================================================
2 /// @file
3 /// デバッグクラスヘッダファイル
4 ///
5 /// デバッグクラスヘッダファイルです。
6 ///
7 /// $Id: CDebug.h 245 2019-03-20 15:03:41Z admin $
8 /// $Date: 2019-03-21 00:03:41 +0900 (2019/03/21 (木)) $
9 /// $Author: admin $
10 ///
11 /// @attention なし
12 
13 #pragma once
14 #pragma managed( push, off )
15 
16 //=============================================================================
17 // インクルードファイル
18 #include <CStreamOut.h>
19 
20 //=============================================================================
21 // マクロ定義
22 #define DebugInstance() LibCommon::CDebug::GetInstance() ///< インスタンス取得マクロ
23 #define DebugChar(...) DebugInstance().OutputChar(__VA_ARGS__) ///< 1文字出力マクロ
24 #define DebugString(...) DebugInstance().OutputString(__VA_ARGS__) ///< 文字列出力マクロ
25 #define DebugFormat(...) DebugInstance().OutputFormat(__VA_ARGS__) ///< 書式設定文字列出力マクロ
26 #define DebugNewLine() DebugInstance().OutputNewLine() ///< 改行出力マクロ
27 #define DebugLineString(...) DebugInstance().OutputLineString(__VA_ARGS__) ///< 文字列行出力マクロ
28 #define DebugLineFormat(...) DebugInstance().OutputLineFormat(__VA_ARGS__) ///< 書式設定文字列行出力マクロ
29 #define DebugExLineFormat(...) DebugInstance().ExOutputLineFormat(__VA_ARGS__) ///< 拡張書式設定文字列行出力マクロ
30 #define DebugNoIndent(...) DebugInstance().ExOutputLineFormat(true,false,__VA_ARGS__) ///< インデントなし書式設定文字列行出力マクロ
31 #define DebugLine(...) DebugInstance().ExOutputLineFormat(false,false,__VA_ARGS__) ///< ヘッダインデントなし書式設定文字列行出力マクロ
32 #define DebugFunction() DebugLineFormat(L"%s()",__FUNCTIONW__) ///< 関数マクロ
33 #define DebugIndent() DebugInstance().Indent() ///< インデントマクロ
34 #define DebugUnindent() DebugInstance().Unindent() ///< アンインデントマクロ
35 #define DebugBlockIn(...) DebugLineFormat(__VA_ARGS__);DebugIndent() ///< ブロック開始マクロ
36 #define DebugBlockOut(...) DebugUnindent();DebugLineFormat(__VA_ARGS__) ///< ブロック終了マクロ
37 #define DebugHeader() DebugBlockIn (L"%s() {", __FUNCTIONW__) ///< 関数ヘッダマクロ
38 #define DebugFooter() DebugBlockOut(L"} // %s()",__FUNCTIONW__) ///< 関数フッタマクロ
39 
40 //=============================================================================
41 // 共通ライブラリ名前空間
42 namespace LibCommon {
43  //=========================================================================
44  /// デバッグクラス
45  ///
46  /// デバッグクラスです。
47  ///
48  /// @attention シングルトンクラスです。
49  ///
50  class LIB_COMMON_API CDebug final: public CStreamOut {
51  //=====================================================================
52  // 構築子と解体子
53  protected:
54  //---------------------------------------------------------------------
55  /// コンストラクタ
56  ///
57  /// コンストラクタです。
58  ///
59  /// @param なし
60  /// @return なし
61  /// @attention なし
62  ///
63  explicit CDebug() noexcept;
64 
65  //---------------------------------------------------------------------
66  /// デストラクタ
67  ///
68  /// デストラクタです。
69  ///
70  /// @param なし
71  /// @return なし
72  /// @attention なし
73  ///
74  virtual ~CDebug() noexcept;
75 
76  //=====================================================================
77  // 公開関数
78  public:
79  //---------------------------------------------------------------------
80  /// 文字列出力関数
81  ///
82  /// 文字列出力関数です。
83  ///
84  /// @param[in] pszString 文字列ポインタ
85  /// @return 実行結果
86  /// - true 成功
87  /// - false 失敗
88  /// @attention オーバーライド関数です。
89  ///
90  virtual bool OutputString( wchar_t const* pszString ) noexcept override;
91 
92  //=====================================================================
93  // インライン静的公開関数
94  public:
95  //---------------------------------------------------------------------
96  /// インスタンス取得関数
97  ///
98  /// インスタンス取得関数です。
99  ///
100  /// @param なし
101  /// @return インスタンス参照
102  /// @attention なし
103  ///
104  inline static CDebug& GetInstance() noexcept { return s_cInstance; }
105 
106  //=====================================================================
107  // 静的限定公開定数
108  protected:
109  static int const BUFFER_SIZE = ( 2048 - 1 ); ///< 文字列バッファサイズ
110 
111  //=====================================================================
112  // 限定公開変数
113  protected:
114  wchar_t m_szString[ BUFFER_SIZE + 1 ]; ///< 文字列バッファ
115 
116  //=====================================================================
117  // 静的限定公開変数
118  protected:
119  static CDebug s_cInstance; ///< 静的インスタンス
120 
121  //=====================================================================
122  // 削除関数
123  private:
124  CDebug( CDebug const& ) = delete;
125  CDebug& operator=( CDebug const& ) = delete;
126  };
127 }
128 
129 #pragma managed( pop )
static CDebug & GetInstance() noexcept
インスタンス取得関数
Definition: CDebug.h:104
ストリーム出力クラスヘッダファイル
デバッグクラス
Definition: CDebug.h:50
共通ライブラリ名前空間
Definition: CArray.h:23
ストリーム出力クラス
Definition: CStreamOut.h:30
static CDebug s_cInstance
静的インスタンス
Definition: CDebug.h:119
#define LIB_COMMON_API
ダイナミックライブラリインポート宣言
Definition: LibCommonDef.h:44