summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icespider/core/util.cpp19
-rw-r--r--icespider/core/util.h5
2 files changed, 24 insertions, 0 deletions
diff --git a/icespider/core/util.cpp b/icespider/core/util.cpp
new file mode 100644
index 0000000..62de195
--- /dev/null
+++ b/icespider/core/util.cpp
@@ -0,0 +1,19 @@
+#include "util.h"
+
+namespace IceSpider {
+ void
+ remove_trailing(std::string_view & in, const char c)
+ {
+ if (const auto n = in.find_last_not_of(c); n != std::string_view::npos) {
+ in.remove_suffix(in.length() - n - 1);
+ }
+ }
+
+ void
+ remove_leading(std::string_view & in, const char c)
+ {
+ if (const auto n = in.find_first_not_of(c); n != std::string_view::npos) {
+ in.remove_prefix(n);
+ }
+ }
+}
diff --git a/icespider/core/util.h b/icespider/core/util.h
index fcaf93c..9a673e4 100644
--- a/icespider/core/util.h
+++ b/icespider/core/util.h
@@ -121,4 +121,9 @@ private:
}()};
};
+namespace IceSpider {
+ void remove_trailing(std::string_view & in, const char c);
+ void remove_leading(std::string_view & in, const char c);
+}
+
#endif