diff --git a/lib/message/mu-priority.hh b/lib/message/mu-priority.hh index af76eceb..a4bded34 100644 --- a/lib/message/mu-priority.hh +++ b/lib/message/mu-priority.hh @@ -61,7 +61,7 @@ to_char(Priority prio) } /** - * Get the priority for some character; unknown onws + * Get the priority for some character; unknown ones * become Normal. * * @param c some character @@ -80,6 +80,28 @@ priority_from_char(char c) } } +/** + * Get the priority from their (internal) name, i.e., low/normal/high + * or shortcut. + * + * @param pname + * + * @return the priority or none + */ +static inline Option +priority_from_name(std::string_view pname) +{ + if (pname == "low" || pname == "l") + return Priority::Low; + else if (pname == "high" || pname == "h") + return Priority::High; + else if (pname == "normal" || pname == "n") + return Priority::Normal; + else + return Nothing; +} + + /** * Get the name for a given priority * @@ -108,10 +130,13 @@ constexpr const char* priority_name_c_str(Priority prio) { switch (prio) { - case Priority::Low: return "low"; - case Priority::High: return "high"; + case Priority::Low: + return "low"; + case Priority::High: + return "high"; case Priority::Normal: - default: return "normal"; + default: + return "normal"; } }