9#ifndef __MEDIATOR_USER_CLASSES_H__
10#define __MEDIATOR_USER_CLASSES_H__
17#include "helpers/stringlist.h"
61 bool Equals(
const std::string& s)
const
102 return std::find_if(std::begin(
_users), std::end(
_users),
103 [name](
const User& u)
120 userNames.push_back(user.Name());
122 std::sort(std::begin(userNames), std::end(userNames));
135 User* foundUser =
nullptr;
138 if (foundIter != std::end(
_users))
140 foundUser = &(*foundIter);
157 "Must specify a user name to add it to the user list.");
175 if (foundIter != std::end(
_users))
Implementation of the argumentnull_error exception.
Represents a user with a name.
bool Equals(const std::string &s) const
Compare a string to this User.
User()
Default constructor.
User(std::string name)
Constructor.
std::string Name()
The name of the user (read-only).
bool Equals(const User &user) const
Compare another User name to this User name.
Represents a list of users.
void RemoveUser(std::string name)
Remove the specified user name as a user. Operation ignored if user is not in the list.
User * FindUser(std::string name)
Retrieve the User instance for the specified user name. The found user may be altered so it must poin...
void AddUser(std::string name)
Add the specified user name as a user. Operation ignored if user is already in the list.
std::vector< User > _users
The list of users.
StringList UserNames()
The user names contained in this list (read-only). The list is always sorted.
std::vector< User >::iterator _SearchForUser(const std::string &name)
Get an iterator pointing to the user with the specified name. Returns std::end(_users) if the user wa...
Exception for arguments that are null.
std::vector< std::string > StringList
Typedef for a vector of std::string.
The namespace containing all Design Pattern Examples implemented in C++.