fixed david

This commit is contained in:
2024-02-06 12:36:27 +01:00
parent e46bc4e602
commit 160c02fc75
23 changed files with 360 additions and 359 deletions

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 11:38:34 by maldavid #+# #+# */
/* Updated: 2024/02/05 16:23:31 by maldavid ### ########.fr */
/* Updated: 2024/02/06 12:36:19 by vvaas ### ########.fr */
/* */
/******************************************************************************/
@@ -22,13 +22,13 @@ namespace irc
void split(const std::string& s, std::vector<std::string>& elems)
{
std::string token;
for(std::string::const_iterator it = s.begin(); it != s.end();)
for (std::string::const_iterator it = s.begin(); it != s.end();)
{
if(std::isspace(*it))
if (std::isspace(*it))
{
elems.push_back(token);
token.clear();
while(std::isspace(*it) && it != s.end())
while (std::isspace(*it) && it != s.end())
it++;
}
else
@@ -38,18 +38,18 @@ namespace irc
}
}
elems.push_back(token);
for(std::vector<std::string>::iterator vit = elems.begin(); vit != elems.end();)
for (std::vector<std::string>::iterator vit = elems.begin(); vit != elems.end();)
{
bool isempty = true;
for(std::string::const_iterator it = vit->begin(); it != vit->end(); ++it)
for (std::string::const_iterator it = vit->begin(); it != vit->end(); ++it)
{
if(!std::isspace(*it))
if (!std::isspace(*it))
{
isempty = false;
break;
}
}
if(isempty)
if (isempty)
vit = elems.erase(vit);
else
vit++;
@@ -67,23 +67,23 @@ namespace irc
Message::Message(unstd::SharedPtr<class Client> client, const std::string& msg) : _raw_msg(msg), _client(client)
{
std::vector<std::string> tokens = details::split(msg);
if(tokens.empty())
return;
if (tokens.empty())
return ;
_command = tokens[0];
_tokens = tokens;
bool reason = false;
for(std::vector<std::string>::iterator it = tokens.begin() + 1; it < tokens.end(); ++it)
for (std::vector<std::string>::iterator it = tokens.begin() + 1; it < tokens.end(); ++it)
{
if((*it)[0] == ':')
if ((*it)[0] == ':')
reason = true;
if(!reason)
if (!reason)
_args.push_back(*it);
else
{
if((*it)[0] == ':')
if ((*it)[0] == ':')
it->erase(it->begin());
_reason.append(*it);
if(it != tokens.end() - 1)
if (it != tokens.end() - 1)
_reason.push_back(' ');
}
}