--- nono/lib/config.h 2026/04/29 17:05:26 1.1.1.9 +++ nono/lib/config.h 2026/04/29 17:05:44 1.1.1.11 @@ -42,6 +42,7 @@ class ConfigItem FromConfig, // VM 設定ファイルで更新 FromOption, // コマンドライン引数で更新 FromPerf, // --perf オプション(を展開したもの)で更新 + FromRunning, // 実行中に更新 }; public: @@ -98,17 +99,22 @@ class ConfigItem // where を取得する const std::string& GetWhere() const { return where; } + // この項目で "Invalid argument" のエラーメッセージ文字列を返す。 + std::string ErrMsg() const; + // この項目で指定のメッセージのエラーメッセージ文字列を返す。 + std::string ErrMsg(const char *fmt, ...) const __printflike(2, 3); + std::string ErrMsg(const std::string& msg) const; + // この項目で "invalid argument" を warnx() で出力する void Err() const; - // この項目での指定のエラーメッセージを warnx() で出力する - void Err(const std::string& msg) const; void Err(const char *fmt, ...) const __printflike(2, 3); + void Err(const std::string& msg) const; private: - static void PrintErr(ConfigItem::from_t from, const std::string& where, - const std::string& key, const std::string& value, - const std::string& msg); + static std::string ErrFrom(ConfigItem::from_t from, + const std::string& where, + const std::string& key, const std::string& value); // key が変数名、value が値。 // value はここでは文字列でありそれ以上の構造は持たないが、 @@ -171,6 +177,9 @@ class Config // コマンドライン引数の内容で上書きする bool Update(const std::string& line, const std::string& optname); + // 実行中に動的に変更する + bool UpdateRunning(const std::string& line); + // 内容を表示する void Show(bool all) const; @@ -204,8 +213,8 @@ class Config ConfigItem *FindItem(const std::string& key); // 更新1行分の共通処理 - bool UpdateLine(const std::string& line, ConfigItem::from_t, - const std::string& from); + bool UpdateLine(const std::string& line, ConfigItem::from_t from, + const std::string& where); // キーの正規名を返す const std::string& GetCanonKey(const std::string& key) const;