mirror of https://github.com/djcb/mu.git
contact: implement to_string
Make it easy to get a string for a sequence of contacts.
This commit is contained in:
parent
97c1725461
commit
187c3da408
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "mu-contact.hh"
|
#include "mu-contact.hh"
|
||||||
#include "mu-message.hh"
|
#include "mu-message.hh"
|
||||||
|
#include "utils/mu-utils.hh"
|
||||||
|
|
||||||
#include <gmime/gmime.h>
|
#include <gmime/gmime.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
@ -85,6 +86,21 @@ Mu::make_contacts(const std::string& addrs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string
|
||||||
|
Mu::to_string(const Mu::Contacts& contacts)
|
||||||
|
{
|
||||||
|
std::string res;
|
||||||
|
|
||||||
|
seq_for_each(contacts, [&](auto&& contact) {
|
||||||
|
if (res.empty())
|
||||||
|
res = contact.display_name();
|
||||||
|
else
|
||||||
|
res += ", " + contact.display_name();
|
||||||
|
});
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
Mu::lowercase_hash(const std::string& s)
|
Mu::lowercase_hash(const std::string& s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,6 +164,17 @@ make_contacts(/*const*/ struct _InternetAddressList* addr_lst,
|
||||||
Contacts
|
Contacts
|
||||||
make_contacts(const std::string& addrs,
|
make_contacts(const std::string& addrs,
|
||||||
Field::Id field_id, int64_t message_date);
|
Field::Id field_id, int64_t message_date);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get contacts as a comma-separated list.
|
||||||
|
*
|
||||||
|
* @param contacts contacs
|
||||||
|
*
|
||||||
|
* @return string with contacts.
|
||||||
|
*/
|
||||||
|
std::string to_string(const Contacts& contacts);
|
||||||
|
|
||||||
} // namespace Mu
|
} // namespace Mu
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue