|
@@ -35,6 +35,7 @@
|
|
|
|
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
+#include <cstring>
|
|
#include <google/protobuf/stubs/common.h>
|
|
#include <google/protobuf/stubs/common.h>
|
|
#include <google/protobuf/stubs/stringpiece.h>
|
|
#include <google/protobuf/stubs/stringpiece.h>
|
|
|
|
|
|
@@ -117,6 +118,12 @@ inline bool HasPrefixString(const string& str,
|
|
return str.size() >= prefix.size() &&
|
|
return str.size() >= prefix.size() &&
|
|
str.compare(0, prefix.size(), prefix) == 0;
|
|
str.compare(0, prefix.size(), prefix) == 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+inline bool HasPrefixString(StringPiece str,
|
|
|
|
+ StringPiece prefix) {
|
|
|
|
+ return str.size() >= prefix.size() &&
|
|
|
|
+ memcmp(str.data(), prefix.data(), prefix.size()) == 0;
|
|
|
|
+}
|
|
|
|
|
|
inline string StripPrefixString(const string& str, const string& prefix) {
|
|
inline string StripPrefixString(const string& str, const string& prefix) {
|
|
if (HasPrefixString(str, prefix)) {
|
|
if (HasPrefixString(str, prefix)) {
|