mirror of https://github.com/libAthena/athena.git
Added join in zelda::utility
This commit is contained in:
parent
3c737226ba
commit
aa5c37856f
|
@ -1,4 +1,4 @@
|
|||
// This file is part of libZelda.
|
||||
// This file is part of libZelda.
|
||||
//
|
||||
// libZelda is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
@ -42,6 +42,7 @@ bool isSystemBigEndian();
|
|||
void fillRandom(Uint8 * rndArea, Uint8 count);
|
||||
|
||||
std::vector<std::string> split(const std::string &s, char delim);
|
||||
std::string join(const std::vector<std::string>& elems, const std::string& delims);
|
||||
void tolower(std::string& str);
|
||||
void toupper(std::string& str);
|
||||
std::string sprintf(const char* fmt, ...);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// This file is part of libZelda.
|
||||
// This file is part of libZelda.
|
||||
//
|
||||
// libZelda is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,6 +20,7 @@
|
|||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <iterator>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
|
@ -132,6 +133,14 @@ std::vector<std::string> split(const std::string &s, char delim)
|
|||
return elems;
|
||||
}
|
||||
|
||||
std::string join(const std::vector<std::string>& elems, const std::string& delims)
|
||||
{
|
||||
std::ostringstream ret;
|
||||
std::copy(elems.begin(), elems.end(), std::ostream_iterator<std::string>(ret, delims.c_str()));
|
||||
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
void tolower(std::string& str)
|
||||
{
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
|
|
Loading…
Reference in New Issue