message: update implementation

Add more of the Message class (and various helpers), which are to replace all
the `mu-msg-*` code.

Add more tests.
This commit is contained in:
Dirk-Jan C. Binnema
2022-03-26 16:19:08 +02:00
parent 55402622b9
commit 37988b5a26
12 changed files with 2056 additions and 412 deletions

View File

@ -69,8 +69,10 @@ Document::add(Field::Id id, const std::string& val)
void
Document::add(Field::Id id, const std::vector<std::string>& vals)
{
const auto field{field_from_id(id)};
if (vals.empty())
return;
const auto field{field_from_id(id)};
if (field.is_value())
xdoc_.add_value(field.value_no(), Mu::join(vals, SepaChar1));
@ -88,6 +90,9 @@ Document::string_vec_value(Field::Id field_id) const noexcept
void
Document::add(Field::Id id, const Contacts& contacts)
{
if (contacts.empty())
return;
const auto field{field_from_id(id)};
std::vector<std::string> cvec;