8#ifndef DESIGNLAB_CMDIO_UTIL_H_
9#define DESIGNLAB_CMDIO_UTIL_H_
25#define DESIGNLAB_USE_COLOR_OUTPUT
90template <
typename... Args>
93 const std::string formatted_str =
94 std::format(str, std::forward<Args>(args)...);
95 Output(formatted_str, detail);
101template <
typename... Args>
110template <
typename... Args>
111inline void InfoOutputF(
const std::format_string<Args...> str, Args&&... args) {
118template <
typename... Args>
127template <
typename... Args>
136template <
typename... Args>
147template <
typename... Args>
150 const std::string formatted_str =
151 std::format(str, std::forward<Args>(args)...);
183void OutputTitle(
const std::string& title_name,
bool output_copy_right =
false);
188void WaitAnyKey(
const std::string& str =
"Waiting for input.");
197int InputInt(
int min,
int max,
int default_num,
198 const std::string& str =
"Please enter an integer.");
205bool InputYesNo(
const std::string& str =
"Are you sure?");
215 const std::string& str =
216 "Enter a directory name. (Japanese is not recommended).");
void OutputF(OutputDetail detail, const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数, format した文字列を出力する. SetOutputLimit() で設定した出力の許可範囲内であれば出力される.
void ErrorOutput(const std::string &str)
コマンドラインに文字を出力する関数. Error 用の出力.
std::string InputDirName(const std::string &str="Enter a directory name. (Japanese is not recommended).")
ディレクトリ名を入力させる関数. 出力される文字列は,必ず OutputDetail::kSystem で出力される. ディレクトリ名には次の文字は使えない....
void WarningOutputF(const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数. Warning 用の出力. format した文字列を出力する.
void SpacedOutput(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. 前と後ろに改行を挿入する.
void DebugOutput(const std::string &str)
コマンドラインに文字を出力する関数. Debug 用の出力.
void OutputHorizontalLine(const std::string &line_visual, OutputDetail detail)
コマンドラインに水平線を出力する関数.
void OutputCenter(const std::string &str, OutputDetail detail)
中央に文字を出力する関数. 文字列が長すぎる場合は普通に左詰めで出力される.
void SystemOutputF(const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数. System 用の出力. format した文字列を出力する.
void WarningOutput(const std::string &str)
コマンドラインに文字を出力する関数. Warning 用の出力.
void InfoOutputF(const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数. Info 用の出力. format した文字列を出力する.
void WaitAnyKey(const std::string &str="Waiting for input.")
入力待ちをする関数. 出力される文字列は, 必ず OutputDetail::kSystem で出力される.
void DebugOutputF(const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数. Debug 用の出力. format した文字列を出力する.
void SystemOutput(const std::string &str)
コマンドラインに文字を出力する関数. System 用の出力.
void ErrorOutputF(const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数. Error 用の出力. format した文字列を出力する.
void OutputRight(const std::string &str, OutputDetail detail)
右端に文字を出力する関数. 文字列が長すぎる場合は普通に左詰めで出力される.
int InputInt(int min, int max, int default_num, const std::string &str="Please enter an integer.")
整数を入力させる関数. 出力される文字列は, 必ず OutputDetail::kSystem で出力される.
void InfoOutput(const std::string &str)
コマンドラインに文字を出力する関数. Info 用の出力.
void OutputNewLine(int num, OutputDetail detail)
コマンドラインで改行をする関数.
void OutputTitle(const std::string &title_name, bool output_copy_right=false)
コマンドラインにこのソフトのタイトルを出力する関数. 出力される文字列は,必ず OutputDetail::kSystem で出力される.
void SpacedOutputF(OutputDetail detail, const std::format_string< Args... > str, Args &&... args)
コマンドラインに文字を出力する関数, format した文字列を出力する. SetOutputLimit 関数で設定した出力の許可範囲内であれば出力される.
void DoOutput(bool do_output)
そもそも出力をするかを設定する関数. false に設定しても システムメッセージは出力される.
void Output(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. SetOutputLimit 関数で設定した出力の許可範囲内であれば出力される.
constexpr int kHorizontalLineLength
水平線の長さ.
void SetOutputLimit(OutputDetail limit)
出力するメッセージをどこまで許可するかを設定する関数. この関数を呼び出してから出ないと,他の関数を使えない. 例えば kError に設定すると, kError 未満の出力( kInfo とか...
bool InputYesNo(const std::string &str="Are you sure?")
yesかnoを入力させる関数.返り値で yes なら true, no なら false を返す. 出力される文字列は,必ず OutputDetail::kSystem で出力される.
OutputDetail
コマンドラインに文字を出力する際に,その詳細を指定するための列挙体.
@ kSystem
システムメッセージ,常に出力する.
@ kDebug
デバッグ時のみ出力,一番優先度が低い.
@ kWarning
警告メッセージ,エラーではないが注意が必要なメッセージ.