aboutsummaryrefslogtreecommitdiff
path: root/core/include-priv/trygvis/string_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/include-priv/trygvis/string_utils.h')
-rw-r--r--core/include-priv/trygvis/string_utils.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/include-priv/trygvis/string_utils.h b/core/include-priv/trygvis/string_utils.h
new file mode 100644
index 0000000..9902a3f
--- /dev/null
+++ b/core/include-priv/trygvis/string_utils.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <string>
+
+namespace trygvis {
+namespace string_utils {
+
+/**
+ * Check if a starts with b.
+ */
+static bool startsWith(const std::string &a, const std::string &b) {
+ return b.length() <= a.length() && a.compare(0, b.length(), b) == 0;
+}
+
+/**
+ * Check if a ends with b.
+ */
+static bool endsWith(const std::string &a, const std::string &b) {
+ return b.length() <= a.length() && a.compare(a.length() - b.length(), b.length(), b) == 0;
+}
+
+} // namespace string_utils
+} // namespace trygvis