diff options
author | 2018-03-16 10:10:16 -0700 | |
---|---|---|
committer | 2018-03-16 10:14:17 -0700 | |
commit | 386ba370d41e8872a9db0d45239d7b00c14ef309 (patch) | |
tree | b7aa83e59e1345fcc1fbf6cb89db5601966c91b3 /tensorflow/core/lib/strings/str_util.h | |
parent | a0bd058ad1406585634330772bfda76fd27d87d7 (diff) |
Added StrContains, StartsWith, and EndsWith functions to str_util.h.
Marked contains, starts_with, ends_with, and consume StringPiece methods as deprecated.
This will allow tensorflow::StringPiece to be more easily replaced with absl::string_view (once the deprecated methods are removed) as absl::string_view does not contain those methods.
PiperOrigin-RevId: 189355316
Diffstat (limited to 'tensorflow/core/lib/strings/str_util.h')
-rw-r--r-- | tensorflow/core/lib/strings/str_util.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tensorflow/core/lib/strings/str_util.h b/tensorflow/core/lib/strings/str_util.h index 44c52850fa..f062eddef8 100644 --- a/tensorflow/core/lib/strings/str_util.h +++ b/tensorflow/core/lib/strings/str_util.h @@ -141,6 +141,21 @@ bool SplitAndParseAsInts(StringPiece text, char delim, bool SplitAndParseAsFloats(StringPiece text, char delim, std::vector<float>* result); +// StartsWith() +// +// Returns whether a given string `text` begins with `prefix`. +bool StartsWith(StringPiece text, StringPiece prefix); + +// EndsWith() +// +// Returns whether a given string `text` ends with `suffix`. +bool EndsWith(StringPiece text, StringPiece suffix); + +// StrContains() +// +// Returns whether a given string `haystack` contains the substring `needle`. +bool StrContains(StringPiece haystack, StringPiece needle); + // ------------------------------------------------------------------ // Implementation details below template <typename T> |