Implement attachment_target_c::dump_info()

This commit is contained in:
Moritz Bunkus 2012-08-27 12:34:11 +02:00
parent d6bb51646b
commit 1509b4a549
2 changed files with 32 additions and 4 deletions

View File

@ -61,11 +61,27 @@ attachment_target_c::validate() {
void
attachment_target_c::dump_info()
const {
// TODO: dump_info()
assert(false);
mxinfo(boost::format(" attachment target:\n"
" file_name: %1%\n")
% m_file_name);
" file_name: %1%\n"
" command: %2% (%3%)\n"
" options: %4%\n"
" selector_type: %5% (%6%)\n"
" selector_num_arg: %7%\n"
" selector_string_arg: %8%\n")
% m_file_name
% m_command
% ( ac_add == m_command ? "add"
: ac_delete == m_command ? "delete"
: ac_replace == m_command ? "replace"
: "unknown")
% m_options
% m_selector_type
% ( st_id == m_selector_type ? "ID"
: st_uid == m_selector_type ? "UID"
: st_name == m_selector_type ? "name"
: st_mime_type == m_selector_type ? "MIME type"
: "unknown")
% m_selector_num_arg % m_selector_string_arg);
}
bool

View File

@ -100,4 +100,16 @@ operator ==(attachment_target_c::options_t const &a,
&& (a.m_mime_type == b.m_mime_type);
}
inline std::ostream &
operator <<(std::ostream &out,
attachment_target_c::options_t const &opt) {
auto format = [](std::string const &name, std::pair<std::string, bool> const &value) -> std::string {
return value.second ? name + ":yes(" + value.first + ")" : name + ":no";
};
out << "{" << format("name", opt.m_name) << " " << format("description", opt.m_description) << " " << format("MIME type", opt.m_mime_type) << "}";
return out;
}
#endif // MTX_PROPEDIT_ATTACHMENT_TARGET_H