summaryrefslogtreecommitdiff
path: root/src/core/common
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-05 02:46:00 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-05 02:46:00 +0100
commit68ae3c4fd9db8baef4fea99d91766af5bc210506 (patch)
treeb89b138918c97e2b484040e63aa078bc2862b5a2 /src/core/common
parent811477ac1b6fba8f18ea0cc8b2c273da848346a7 (diff)
Added hasNonWhitepaceChar function
Diffstat (limited to 'src/core/common')
-rw-r--r--src/core/common/Utils.cpp11
-rw-r--r--src/core/common/Utils.hpp8
2 files changed, 18 insertions, 1 deletions
diff --git a/src/core/common/Utils.cpp b/src/core/common/Utils.cpp
index f59061a..e5e2d39 100644
--- a/src/core/common/Utils.cpp
+++ b/src/core/common/Utils.cpp
@@ -46,6 +46,16 @@ bool Utils::isIdentifier(const std::string &name)
return true;
}
+bool Utils::hasNonWhitepaceChar(const std::string &s)
+{
+ for (char c : s) {
+ if (!isWhitespace(c)) {
+ return true;
+ }
+ }
+ return false;
+}
+
std::vector<std::string> Utils::split(const std::string &s, char delim)
{
std::vector<std::string> res;
@@ -84,6 +94,5 @@ std::string Utils::extractFileExtension(const std::string &filename)
}
return std::string{};
}
-
}
diff --git a/src/core/common/Utils.hpp b/src/core/common/Utils.hpp
index a88c716..fa3788a 100644
--- a/src/core/common/Utils.hpp
+++ b/src/core/common/Utils.hpp
@@ -71,6 +71,14 @@ public:
}
/**
+ * Returns true if the given string has a non-whitespace character.
+ *
+ * @param s is the string that should be checked.
+ * @return true if the string contains a non-whitespace character.
+ */
+ static bool hasNonWhitepaceChar(const std::string &s);
+
+ /**
* Returns true if the given character is a whitespace character.
*/
static bool isLinebreak(const char c) { return (c == '\n') || (c == '\r'); }