8#ifndef DESIGNLAB_CMDIO_UTIL_H_
9#define DESIGNLAB_CMDIO_UTIL_H_
26#define DESIGNLAB_USE_COLOR_OUTPUT
65 static void DoOutput(
bool do_output);
116 template <
typename... Args>
119 const std::string formatted_str = std::format(str, std::forward<Args>(args)...);
120 Output(formatted_str, detail);
129 template <
typename... Args>
132 const std::string formatted_str = std::format(str, std::forward<Args>(args)...);
172 static void OutputTitle(
const std::string& title_name,
bool output_copy_right =
false);
178 static void WaitAnyKey(
const std::string& str =
"Waiting for input.");
187 static int InputInt(
int min,
int max,
int default_num,
const std::string& str =
"Please enter an integer.");
194 static bool InputYesNo(
const std::string& str =
"Are you sure?");
203 static std::string
InputDirName(
const std::string& str =
"Enter a directory name. (Japanese is not recommended).");
206 static constexpr int kHorizontalLineLength = 100;
212 static bool do_output;
215 static bool is_initialized;
標準入出力の std::cout,std::cinを使った コマンドライン入出力を行うシングルトンクラス.
CmdIOUtil(CmdIOUtil &&)=delete
ムーブコンストラクタを禁止.
static void SystemOutput(const std::string &str)
コマンドラインに文字を出力する関数.System用の出力.
static std::string InputDirName(const std::string &str="Enter a directory name. (Japanese is not recommended).")
ディレクトリ名を入力させる関数. 出力される文字列は,必ず OutputDetail::kSystem で出力される. ディレクトリ名には次の文字は使えない. \ / : * ?...
static void SpacedOutput(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. 前と後ろに改行を挿入する.
static void ErrorOutput(const std::string &str)
コマンドラインに文字を出力する関数.Error用の出力.
static void Output(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. SetOutputLimit() で設定した出力の許可範囲内であれば出力される. 必ず SetOutputLimit() を呼び出してから使うこと.
static void WaitAnyKey(const std::string &str="Waiting for input.")
入力待ちをする関数. 出力される文字列は,必ず OutputDetail::kSystem で出力される.
static int InputInt(int min, int max, int default_num, const std::string &str="Please enter an integer.")
整数を入力させる関数. 出力される文字列は,必ず OutputDetail::kSystem で出力される.
static void OutputNewLine(int num, OutputDetail detail)
コマンドラインで改行をする関数.
static void OutputTitle(const std::string &title_name, bool output_copy_right=false)
コマンドラインにこのソフトのタイトルを出力する関数. 出力される文字列は,必ず OutputDetail::kSystem で出力される.
static void DoOutput(bool do_output)
そもそも出力をするかを設定する関数. false に設定しても システムメッセージは出力される.
static void OutputHorizontalLine(const std::string &line_visual, OutputDetail detail)
コマンドラインに水平線を出力する関数.
static bool InputYesNo(const std::string &str="Are you sure?")
yesかnoを入力させる関数.返り値で yes なら true,noなら falseを返す. 出力される文字列は,必ず OutputDetail::kSystem で出力される.
CmdIOUtil()=delete
インスタンス化させない.
static void OutputCenter(const std::string &str, OutputDetail detail)
中央に文字を出力する関数. 文字列が長すぎる場合は普通に左詰めで出力される.
static void InfoOutput(const std::string &str)
コマンドラインに文字を出力する関数.Info用の出力.
static void FormatOutput(OutputDetail detail, const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数. SetOutputLimit() で設定した出力の許可範囲内であれば出力される. 必ず SetOutputLimit() を呼び出してから使うこと.
static void OutputRight(const std::string &str, OutputDetail detail)
右端に文字を出力する関数. 文字列が長すぎる場合は普通に左詰めで出力される.
static void SetOutputLimit(OutputDetail limit)
出力するメッセージをどこまで許可するかを設定する関数. この関数を呼び出してから出ないと,他の関数を使えない. 例えば kError に設定すると,kError 未満の出力( kInfo とか ...
static void DebugOutput(const std::string &str)
コマンドラインに文字を出力する関数.Debug用の出力.
CmdIOUtil & operator=(const CmdIOUtil &)=delete
コピー代入演算子を禁止.
CmdIOUtil(const CmdIOUtil &)=delete
コピーコンストラクタを禁止.
static void SpacedFormatOutput(OutputDetail detail, const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数. SetOutputLimit() で設定した出力の許可範囲内であれば出力される. 必ず SetOutputLimit() を呼び出してから使うこと.
static void WarningOutput(const std::string &str)
コマンドラインに文字を出力する関数.Warning用の出力.
OutputDetail
コマンドラインに文字を出力する際に,その詳細を指定するための列挙体.
@ kSystem
システムメッセージ,常に出力する.
@ kDebug
デバッグ時のみ出力,一番優先度が低い.
@ kWarning
警告メッセージ,エラーではないが注意が必要なメッセージ.