lib: update mu-contact-{fields,contact,flags,priority}

Improve cohesion and tests.
This commit is contained in:
Dirk-Jan C. Binnema
2022-03-04 00:02:52 +02:00
parent 45499efef8
commit c3ae3da0de
7 changed files with 184 additions and 52 deletions

View File

@ -26,10 +26,11 @@
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include "mu-message-fields.hh"
struct _InternetAddressList;
namespace Mu {
@ -125,6 +126,27 @@ struct MessageContact {
return cached_hash;
}
/**
* Get the MessageField for this contact-type, if any.
*
* @return the message-field or nullopt.
*/
constexpr std::optional<MessageField> const field() {
switch(type){
case Type::From:
return message_field(MessageField::Id::From);
case Type::To:
return message_field(MessageField::Id::To);
case Type::Cc:
return message_field(MessageField::Id::Cc);
case Type::Bcc:
return message_field(MessageField::Id::Bcc);
default:
return std::nullopt;
}
}
/*
* data members
*/