summaryrefslogtreecommitdiff
path: root/src/util/string.h
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-02-09 07:08:31 +0100
committerest31 <MTest31@outlook.com>2016-03-07 19:54:26 +0100
commitd494733839e9cf6cb557462326ed21e7a58816c7 (patch)
tree07ead00672b0096aa2a60938b769bf030bba2951 /src/util/string.h
parent88fbe7ca1e5451851ee0c7ab5524c39a7bb703c2 (diff)
downloadminetest-d494733839e9cf6cb557462326ed21e7a58816c7.tar.gz
minetest-d494733839e9cf6cb557462326ed21e7a58816c7.tar.bz2
minetest-d494733839e9cf6cb557462326ed21e7a58816c7.zip
Add minetest.register_lbm() to run code on block load only
Diffstat (limited to 'src/util/string.h')
-rw-r--r--src/util/string.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/util/string.h b/src/util/string.h
index c8f60b802..cf94b7f5f 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -299,15 +299,6 @@ inline s32 mystoi(const std::string &str, s32 min, s32 max)
}
-/// Returns a 64-bit value represented by the string \p str (decimal).
-inline s64 stoi64(const std::string &str)
-{
- std::stringstream tmp(str);
- s64 t;
- tmp >> t;
- return t;
-}
-
// MSVC2010 includes it's own versions of these
//#if !defined(_MSC_VER) || _MSC_VER < 1600
@@ -346,9 +337,22 @@ inline float mystof(const std::string &str)
#define stoi mystoi
#define stof mystof
+/// Returns a value represented by the string \p val.
+template <typename T>
+inline T from_string(const std::string &str)
+{
+ std::stringstream tmp(str);
+ T t;
+ tmp >> t;
+ return t;
+}
+
+/// Returns a 64-bit signed value represented by the string \p str (decimal).
+inline s64 stoi64(const std::string &str) { return from_string<s64>(str); }
+
// TODO: Replace with C++11 std::to_string.
-/// Returns A string representing the value \p val.
+/// Returns a string representing the value \p val.
template <typename T>
inline std::string to_string(T val)
{