Skip to content

Commit

Permalink
USE BOOST SPLIT
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 26, 2024
1 parent 2ec7ce1 commit f72968f
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions nano/lib/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <nano/lib/locks.hpp>

#include <boost/algorithm/string.hpp>
#include <boost/current_function.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
Expand Down Expand Up @@ -246,19 +247,10 @@ std::string join (Container const & container, std::string_view delimiter, Func
return join (container.begin (), container.end (), delimiter, transform);
}

inline std::vector<std::string> split (std::string const & str, std::string const & delimiter)
inline std::vector<std::string> split (std::string const & input, std::string_view const & delimiter)
{
std::vector<std::string> result;
std::size_t startPos = 0;
std::size_t delimiterPos = str.find (delimiter, startPos);
while (delimiterPos != std::string::npos)
{
std::string token = str.substr (startPos, delimiterPos - startPos);
result.push_back (token);
startPos = delimiterPos + delimiter.length ();
delimiterPos = str.find (delimiter, startPos);
}
result.push_back (str.substr (startPos));
boost::split (result, input, boost::is_any_of (delimiter));
return result;
}

Expand Down

0 comments on commit f72968f

Please sign in to comment.