diff options
author | 2023-08-16 10:08:53 -0700 | |
---|---|---|
committer | 2023-08-16 10:09:41 -0700 | |
commit | 17a3ac4bcc9b16aa1ae020a2f7067008d627ad88 (patch) | |
tree | ad64797c7d86d2c2365303499faf6ad612e91061 /absl/strings/cord.h | |
parent | 334aca32051ef6ede2711487acf45d959e9bdffc (diff) |
Implement `Cord::Find()` and `Cord::Contains()`
PiperOrigin-RevId: 557523229
Change-Id: I959c0b0b14a4a96bee396d4bc09b80328060287d
Diffstat (limited to 'absl/strings/cord.h')
-rw-r--r-- | absl/strings/cord.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/absl/strings/cord.h b/absl/strings/cord.h index 8a37df96..0dede5c7 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -396,6 +396,12 @@ class Cord { bool EndsWith(absl::string_view rhs) const; bool EndsWith(const Cord& rhs) const; + // Cord::Contains() + // + // Determines whether the Cord contains the passed string data `rhs`. + bool Contains(absl::string_view rhs) const; + bool Contains(const Cord& rhs) const; + // Cord::operator std::string() // // Converts a Cord into a `std::string()`. This operator is marked explicit to @@ -747,6 +753,14 @@ class Cord { // If the cord was already flat, the contents are not modified. absl::string_view Flatten() ABSL_ATTRIBUTE_LIFETIME_BOUND; + // Cord::Find() + // + // Returns an iterator to the first occurrance of the substring `needle`. + // + // If the substring `needle` does not occur, `Cord::char_end()` is returned. + CharIterator Find(absl::string_view needle) const; + CharIterator Find(const absl::Cord& needle) const; + // Supports absl::Cord as a sink object for absl::Format(). friend void AbslFormatFlush(absl::Cord* cord, absl::string_view part) { cord->Append(part); @@ -1028,6 +1042,8 @@ class Cord { friend class CrcCord; void SetCrcCordState(crc_internal::CrcCordState state); const crc_internal::CrcCordState* MaybeGetCrcCordState() const; + + CharIterator FindImpl(CharIterator it, absl::string_view needle) const; }; ABSL_NAMESPACE_END |