hon hon hon baguette

This commit is contained in:
Kbz-8
2024-01-25 17:04:42 +01:00
parent 92847d7c19
commit 3953cb8d0a
9 changed files with 138 additions and 22 deletions

39
srcs/unstd/string.cpp Normal file
View File

@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* string.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/25 15:19:30 by maldavid #+# #+# */
/* Updated: 2024/01/25 15:20:20 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include <unstd/string.hpp>
namespace unstd
{
std::vector<std::string> split(const std::string& s, char delim)
{
std::vector<std::string> elems;
std::string token;
for(std::string::const_iterator it = s.begin(); it != s.end();)
{
if(*it == delim)
{
elems.push_back(token);
token.clear();
while(*it == delim && it != s.end())
it++;
}
else
{
token.push_back(*it);
it++;
}
}
elems.push_back(token);
return elems;
}
}