diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-03-16 10:10:16 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-03-16 10:14:17 -0700 |
commit | 386ba370d41e8872a9db0d45239d7b00c14ef309 (patch) | |
tree | b7aa83e59e1345fcc1fbf6cb89db5601966c91b3 /tensorflow/core/lib/core | |
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/core')
-rw-r--r-- | tensorflow/core/lib/core/stringpiece.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tensorflow/core/lib/core/stringpiece.h b/tensorflow/core/lib/core/stringpiece.h index 910e4d9e2a..79409cce4b 100644 --- a/tensorflow/core/lib/core/stringpiece.h +++ b/tensorflow/core/lib/core/stringpiece.h @@ -88,11 +88,13 @@ class StringPiece { size_t find(char c, size_t pos = 0) const; size_t rfind(char c, size_t pos = npos) const; + // DEPRECATED: Use tensorflow::str_util::StrContains instead. bool contains(StringPiece s) const; // Checks whether StringPiece starts with x and if so advances the beginning // of it to past the match. It's basically a shortcut for starts_with // followed by remove_prefix. + // DEPRECATED: Use tensorflow::str_util::ConsumePrefix instead. bool Consume(StringPiece x) { if (starts_with(x)) { remove_prefix(x.size_); @@ -113,10 +115,12 @@ class StringPiece { int compare(StringPiece b) const; // Return true iff "x" is a prefix of "*this" + // DEPRECATED: Use tensorflow::str_util::StartsWith instead. bool starts_with(StringPiece x) const { return ((size_ >= x.size_) && (memcmp(data_, x.data_, x.size_) == 0)); } // Return true iff "x" is a suffix of "*this" + // DEPRECATED: Use tensorflow::str_util::EndsWith instead. bool ends_with(StringPiece x) const { return ((size_ >= x.size_) && (memcmp(data_ + (size_ - x.size_), x.data_, x.size_) == 0)); |