#ifndef __STR_HH__
#define __STR_HH__
+#include <cctype>
+#include <cstring>
#include <sstream>
#include <string>
#include <vector>
-#include <ctype.h>
-
template<class> class Hash;
template<>
class Hash<std::string> {
return ret;
}
+
+/**
+ * Return true if 's' starts with the prefix string 'prefix'.
+ */
+inline bool
+startswith(const char *s, const char *prefix)
+{
+ return (strncmp(s, prefix, strlen(prefix)) == 0);
+}
+
+
+/**
+ * Return true if 's' starts with the prefix string 'prefix'.
+ */
+inline bool
+startswith(const std::string &s, const char *prefix)
+{
+ return (s.compare(0, strlen(prefix), prefix) == 0);
+}
+
+
+/**
+ * Return true if 's' starts with the prefix string 'prefix'.
+ */
+inline bool
+startswith(const std::string &s, const std::string &prefix)
+{
+ return (s.compare(0, prefix.size(), prefix) == 0);
+}
+
+
#endif //__STR_HH__