summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2019-02-03 16:17:37 -0800
committerGitHub <noreply@github.com>2019-02-03 16:17:37 -0800
commitb396d78982e109dc642611d32578bbca82b210cd (patch)
treee29dce4fdd0c2190860ddbc9f1c611f9eb443a83 /src/util
parente374c7fbde3b3a5148b6e8fc302277b6e786965e (diff)
Add rewrite for contains + const strings replace (#2828)
Diffstat (limited to 'src/util')
-rw-r--r--src/util/regexp.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/regexp.h b/src/util/regexp.h
index 2ab6b659c..1588b5174 100644
--- a/src/util/regexp.h
+++ b/src/util/regexp.h
@@ -149,6 +149,22 @@ class CVC4_PUBLIC String {
String prefix(std::size_t i) const { return substr(0, i); }
String suffix(std::size_t i) const { return substr(size() - i, i); }
+
+ /**
+ * Checks if there is any overlap between this string and another string. This
+ * corresponds to checking whether one string contains the other and wether a
+ * substring of one is a prefix of the other and vice-versa.
+ *
+ * @param y The other string
+ * @return True if there is an overlap, false otherwise
+ */
+ bool noOverlapWith(const String& y) const
+ {
+ return y.find(*this) == std::string::npos
+ && this->find(y) == std::string::npos && this->overlap(y) == 0
+ && y.overlap(*this) == 0;
+ }
+
/** string overlap
*
* if overlap returns m>0,
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback