]> git.sesse.net Git - plocate/blobdiff - needle.h
Move several needle/searching related functions into its own file.
[plocate] / needle.h
diff --git a/needle.h b/needle.h
new file mode 100644 (file)
index 0000000..ce443f2
--- /dev/null
+++ b/needle.h
@@ -0,0 +1,19 @@
+#ifndef _NEEDLE_H
+#define _NEEDLE_H 1
+
+#include <regex.h>
+#include <string>
+
+struct Needle {
+       enum { STRSTR,
+              REGEX,
+              GLOB } type;
+       std::string str;  // Filled in no matter what.
+       regex_t re;  // For REGEX.
+};
+
+bool matches(const Needle &needle, const char *haystack);
+std::string unescape_glob_to_plain_string(const std::string &needle);
+regex_t compile_regex(const std::string &needle);
+
+#endif  // !defined(_NEEDLE_H)