aboutsummaryrefslogtreecommitdiff
path: root/core/trygvis/string_utils.h
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-08-05 11:09:53 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-08-05 11:09:53 +0200
commitff87ea9045a6e0979311ae7b25055d6b53b0a13d (patch)
tree8f36e478d37caf819919bc02f55816df4a677607 /core/trygvis/string_utils.h
parentbfeeac6e4889d1e9a1083b3c7efc59652981b168 (diff)
downloadkicad-utils-ff87ea9045a6e0979311ae7b25055d6b53b0a13d.tar.gz
kicad-utils-ff87ea9045a6e0979311ae7b25055d6b53b0a13d.tar.bz2
kicad-utils-ff87ea9045a6e0979311ae7b25055d6b53b0a13d.tar.xz
kicad-utils-ff87ea9045a6e0979311ae7b25055d6b53b0a13d.zip
o Dropping the native library code, we're all Python now!
Diffstat (limited to 'core/trygvis/string_utils.h')
-rw-r--r--core/trygvis/string_utils.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/trygvis/string_utils.h b/core/trygvis/string_utils.h
new file mode 100644
index 0000000..2f2a7a5
--- /dev/null
+++ b/core/trygvis/string_utils.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <string>
+
+namespace trygvis {
+namespace string_utils {
+
+/**
+ * Check if a starts with b.
+ */
+__attribute__((unused))
+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.
+ */
+__attribute__((unused))
+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