summaryrefslogtreecommitdiffstats
path: root/source/StringUtils.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-04 22:13:08 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-04 22:13:08 +0100
commit28d8d8419a5b900e9d20ce91dc63e28349b6470a (patch)
treebf5b7bafa902a138339c78877ecec376c055b727 /source/StringUtils.cpp
parentRemoved the unused cHeartbeat object (diff)
downloadcuberite-28d8d8419a5b900e9d20ce91dc63e28349b6470a.tar
cuberite-28d8d8419a5b900e9d20ce91dc63e28349b6470a.tar.gz
cuberite-28d8d8419a5b900e9d20ce91dc63e28349b6470a.tar.bz2
cuberite-28d8d8419a5b900e9d20ce91dc63e28349b6470a.tar.lz
cuberite-28d8d8419a5b900e9d20ce91dc63e28349b6470a.tar.xz
cuberite-28d8d8419a5b900e9d20ce91dc63e28349b6470a.tar.zst
cuberite-28d8d8419a5b900e9d20ce91dc63e28349b6470a.zip
Diffstat (limited to '')
-rw-r--r--source/StringUtils.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp
index 161a8a168..dc128e61d 100644
--- a/source/StringUtils.cpp
+++ b/source/StringUtils.cpp
@@ -535,3 +535,26 @@ AString & CreateHexDump(AString & a_Out, const void * a_Data, int a_Size, int a_
+
+AString Trim(const AString & a_Text)
+{
+ if (a_Text.empty())
+ {
+ return "";
+ }
+ size_t Beginning = a_Text.find_first_not_of(" \r\n\t");
+ if (Beginning == AString::npos)
+ {
+ Beginning = 0;
+ }
+ size_t End = a_Text.find_last_not_of(" \r\n\t");
+ if (End == AString::npos)
+ {
+ End = a_Text.length();
+ }
+ return a_Text.substr(Beginning, End - Beginning + 1);
+}
+
+
+
+