Extend string helper functions

Moved mxs::strtok into mxb namespace and added mxb::join for joining
objects into strings.
This commit is contained in:
Markus Mäkelä
2019-03-26 17:42:53 +02:00
parent d46778d5d9
commit ac0a3d1d47
2 changed files with 55 additions and 11 deletions

View File

@ -30,6 +30,7 @@
#include <maxscale/buffer.hh>
#include <maxscale/utils.h>
#include <maxscale/jansson.hh>
#include <maxbase/string.hh>
namespace maxscale
{
@ -44,17 +45,7 @@ namespace maxscale
*/
inline std::vector<std::string> strtok(std::string str, const char* delim)
{
std::vector<std::string> rval;
char* save_ptr;
char* tok = strtok_r(&str[0], delim, &save_ptr);
while (tok)
{
rval.emplace_back(tok);
tok = strtok_r(NULL, delim, &save_ptr);
}
return rval;
return mxb::strtok(str, delim);
}
/**