17 static constexpr
const std::string_view roleNames[] = {
38 SignedOffBy, FirstRole = SignedOffBy,
42 AckedBy, LastRole = AckedBy,
49 static_assert(Last == std::size(roleNames));
61 constexpr
auto index()
const {
return static_cast<std::size_t
>(m_role); }
83 m_role(std::move(r)), m_name(std::move(
name)), m_email(std::move(
email)),
89 const std::string &
name()
const {
return m_name; }
91 const std::string &
email()
const {
return m_email; }
93 std::string
userName()
const {
return m_email.substr(0, m_email.find(
"@")); }
99 auto count()
const {
return m_count; }
106 std::string
pretty(
bool includeName =
true)
const {
107 if (includeName && !
name().empty())
120 template <
typename T>
121 std::string
pretty(
const T &translate,
bool includeName =
true)
const {
122 if (includeName && !
name().empty())
123 return name() +
" <" + translate(
email()) +
">";
124 return translate(
email());
150 static std::optional<Person>
parse(std::string_view src)
152 for (std::size_t i = Role::FirstRole; i <= Role::LastRole; ++i) {
RoleType role() const
Get the actual RoleType.
Definition: Person.h:58
auto count() const
Get count of changes historically done by this Person.
Definition: Person.h:99
Role(RoleType role)
Construct new Role with role set.
Definition: Person.h:55
static std::optional< Person > parsePerson(std::string_view src, Role role)
Parse src into a Person.
constexpr auto index() const
Convert Role to number/index.
Definition: Person.h:61
static std::optional< Person > parse(std::string_view src)
Try to parse a line.
Definition: Person.h:150
Role(size_t index)
Construct new Role with role set by the index.
Definition: Person.h:53
const Role & role() const
Get Role of this Person.
Definition: Person.h:87
const std::string & email() const
Get e-mail of this Person.
Definition: Person.h:91
Role of a Person.
Definition: Person.h:15
const std::string & name() const
Get name of this Person.
Definition: Person.h:89
std::string userName() const
Get user name (from e-mail)
Definition: Person.h:93
constexpr const auto & toString() const
Convert Role to string.
Definition: Person.h:63
Definition: Branches.h:15
Person(Role r, std::string name, std::string email, unsigned count=0)
Create a Person with Role r, name, email and count of changes.
Definition: Person.h:82
Information about a person (such as username, e-mail, Role)
Definition: Person.h:71
std::string pretty(const T &translate, bool includeName=true) const
Pretty format as "username <e-mail>".
Definition: Person.h:121
std::string pretty(bool includeName=true) const
Pretty format as "username <e-mail>".
Definition: Person.h:106
void setEmail(const std::string &email)
Re-set e-mail to email.
Definition: Person.h:131
RoleType
Actual roles.
Definition: Person.h:36