10#include "helpers/formatstring.h"
25 std::string
_ListToString(
const std::vector<std::string>& items)
27 std::ostringstream output;
28 for (
size_t index = 0; index < items.size(); ++index)
34 output << items[index];
95 std::cout << std::endl;
96 std::cout <<
"Mediator Exercise" << std::endl;
105 std::cout <<
" Operation 1: Show all groups" << std::endl;
112 std::cout <<
" Operation 2: Show all users" << std::endl;
119 std::cout <<
" Operation 3: Determine if a user is a member of a specific group." << std::endl;
120 std::string userName =
"Arthur";
121 std::string groupName =
"admins";
123 userName.c_str(), groupName.c_str());
130 std::cout <<
" Operation 4: Show all users in a specific group." << std::endl;
140 std::cout <<
" Operation 5: Show all groups containing a specific user." << std::endl;
150 std::cout <<
" Operation 6: Remove a user from a group." << std::endl;
152 groupName =
"Power Users";
155 userName.c_str(), groupName.c_str()) << std::endl;
164 std::cout <<
" Operation 7: Add a user to a group." << std::endl;
167 userName.c_str(), groupName.c_str())
178 std::cout <<
" Operation 8: Remove a user from all groups." << std::endl;
188 std::cout <<
" Removing..." << std::endl;
198 std::cout <<
" Operation 9: Remove a user (also removes the user from all groups)." << std::endl;
206 for (std::string name : groupNames)
215 std::cout <<
" Done." << std::endl;
std::vector< std::string > StringList
Typedef for a vector of std::string.
The namespace containing all Design Pattern Examples implemented in C++.
void Mediator_Exercise()
Example of using the Mediator design pattern.
std::string formatstring(const char *fmt,...)
Use the given string and arguments to return a buffer containing the formatted string....