SlHelpers
SlKernCVS::Person Class Reference

Information about a person (such as username, e-mail, Role) More...

#include <Person.h>

Public Member Functions

 Person (Role r, std::string name, std::string email, unsigned count=0)
 Create a Person with Role r, name, email and count of changes. More...
 
const Rolerole () const
 Get Role of this Person.
 
const std::string & name () const
 Get name of this Person.
 
const std::string & email () const
 Get e-mail of this Person.
 
std::string userName () const
 Get user name (from e-mail)
 
auto count () const
 Get count of changes historically done by this Person. More...
 
std::string pretty (bool includeName=true) const
 Pretty format as "username <e-mail>". More...
 
template<typename T >
std::string pretty (const T &translate, bool includeName=true) const
 Pretty format as "username <e-mail>". More...
 
void setEmail (const std::string &email)
 Re-set e-mail to email. More...
 

Static Public Member Functions

static std::optional< PersonparsePerson (std::string_view src, Role role)
 Parse src into a Person. More...
 
static std::optional< Personparse (std::string_view src)
 Try to parse a line. More...
 

Detailed Description

Information about a person (such as username, e-mail, Role)

Constructor & Destructor Documentation

◆ Person()

SlKernCVS::Person::Person ( Role  r,
std::string  name,
std::string  email,
unsigned  count = 0 
)
inline

Create a Person with Role r, name, email and count of changes.

Parameters
rRole of this Person
nameName of this Person
emailE-mail of this Person
countCount of changes historically done by this Person (in $KSOURCE_GIT)

Member Function Documentation

◆ count()

auto SlKernCVS::Person::count ( ) const
inline

Get count of changes historically done by this Person.

Returns
Count of changes.

◆ parse()

static std::optional<Person> SlKernCVS::Person::parse ( std::string_view  src)
inlinestatic

Try to parse a line.

Parameters
srcLine to parse
Returns
A Person if successful, std::nullopt otherwise.

◆ parsePerson()

static std::optional<Person> SlKernCVS::Person::parsePerson ( std::string_view  src,
Role  role 
)
static

Parse src into a Person.

Parameters
srcLine to parse
roleRole to set to the new Person
Returns
Person, or nullopt in case of failure.

Parses lines like: M: First LastName email.nosp@m.@som.nosp@m.ewher.nosp@m.e.co.nosp@m.m M: email.nosp@m.@som.nosp@m.ewher.nosp@m.e.co.nosp@m.m

◆ pretty() [1/2]

std::string SlKernCVS::Person::pretty ( bool  includeName = true) const
inline

Pretty format as "username <e-mail>".

Parameters
includeNameIf output the username part
Returns
Either "username <e-mail>" when includeName is true or "e-mail" otherwise.

◆ pretty() [2/2]

template<typename T >
std::string SlKernCVS::Person::pretty ( const T &  translate,
bool  includeName = true 
) const
inline

Pretty format as "username <e-mail>".

Parameters
translateA translate callback for e-mail
includeNameIf output the username part
Returns
Either "username <e-mail>" when includeName is true or "e-mail" otherwise.

The e-mail is passed to translate() before passing to the output.

◆ setEmail()

void SlKernCVS::Person::setEmail ( const std::string &  email)
inline

Re-set e-mail to email.

Parameters
emailE-mail to store

The documentation for this class was generated from the following file: