From 75b3606424a27dafeb0958450bffa841ae463c2d Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 29 Sep 2003 14:01:48 +0000 Subject: added removeFirstWhitespace --- src/FbTk/StringUtil.cc | 9 ++++++++- src/FbTk/StringUtil.hh | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index e1af2c2..934561f 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: StringUtil.cc,v 1.6 2003/08/22 22:11:19 fluxgen Exp $ +// $Id: StringUtil.cc,v 1.7 2003/09/29 14:01:48 fluxgen Exp $ #include "StringUtil.hh" @@ -178,6 +178,13 @@ std::string basename(const std::string &filename) { return filename; } +string::size_type removeFirstWhitespace(std::string &str) { + string::size_type first_pos = str.find_first_not_of(" \t"); + if (first_pos != string::npos) + str.erase(0, first_pos); + return first_pos; +} + }; // end namespace StringUtil }; // end namespace FbTk diff --git a/src/FbTk/StringUtil.hh b/src/FbTk/StringUtil.hh index 621f0fb..6f3b56a 100644 --- a/src/FbTk/StringUtil.hh +++ b/src/FbTk/StringUtil.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: StringUtil.hh,v 1.5 2003/08/22 22:11:19 fluxgen Exp $ +//$Id: StringUtil.hh,v 1.6 2003/09/29 14:01:48 fluxgen Exp $ #ifndef FBTK_STRINGUTIL_HH #define FBTK_STRINGUTIL_HH @@ -54,6 +54,10 @@ std::string toUpper(const std::string &conv); #endif // basename std::string basename(const std::string &basename); + +/// removes the first whitespace characters of the string +std::string::size_type removeFirstWhitespace(std::string &str); + /// Breaks a string into tokens template static void -- cgit v0.11.2