From 248d7c8469f8cb37406ea0ce56d0945e38334cfb Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Mon, 16 May 2011 10:41:19 +0100 Subject: Improved server commands and added player permissions. --HG-- extra : rebase_source : 178fe08f10b7de3ebaba088bd24faad795114216 --- src/utility.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/utility.h') diff --git a/src/utility.h b/src/utility.h index 12d732bea..326ebf161 100644 --- a/src/utility.h +++ b/src/utility.h @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #include #include #include @@ -731,6 +732,19 @@ inline std::string wide_to_narrow(const std::wstring& wcs) return *mbs; } +// Split a string using the given delimiter. Returns a vector containing +// the component parts. +inline std::vector str_split(const std::wstring &str, wchar_t delimiter) +{ + std::vector parts; + std::wstringstream sstr(str); + std::wstring part; + while(std::getline(sstr, part, delimiter)) + parts.push_back(part); + return parts; +} + + /* See test.cpp for example cases. wraps degrees to the range of -360...360 @@ -791,6 +805,11 @@ inline s32 stoi(std::string s) return atoi(s.c_str()); } +inline s32 stoi(std::wstring s) +{ + return atoi(wide_to_narrow(s).c_str()); +} + inline float stof(std::string s) { float f; -- cgit v1.2.3