diff options
author | anastasy888 <anastasy888@yandex-team.ru> | 2022-02-10 16:45:54 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:54 +0300 |
commit | 49f765d71da452ea93138a25559dfa68dd76c7f3 (patch) | |
tree | 1016041feb637349e401dcc0fa85217dd2c2c639 /contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h | |
parent | 7353a3fdea9c67c256980c00a2b3b67f09b23a27 (diff) | |
download | ydb-49f765d71da452ea93138a25559dfa68dd76c7f3.tar.gz |
Restoring authorship annotation for <anastasy888@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h')
-rw-r--r-- | contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h index 3164ff1ebc..b766b75d2a 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h @@ -1,91 +1,91 @@ -// -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// File: strip.h -// ----------------------------------------------------------------------------- -// -// This file contains various functions for stripping substrings from a string. -#ifndef ABSL_STRINGS_STRIP_H_ -#define ABSL_STRINGS_STRIP_H_ - -#include <cstddef> +// +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// File: strip.h +// ----------------------------------------------------------------------------- +// +// This file contains various functions for stripping substrings from a string. +#ifndef ABSL_STRINGS_STRIP_H_ +#define ABSL_STRINGS_STRIP_H_ + +#include <cstddef> #include <util/generic/string.h> - + #include "y_absl/base/macros.h" #include "y_absl/strings/ascii.h" #include "y_absl/strings/match.h" #include "y_absl/strings/string_view.h" - + namespace y_absl { ABSL_NAMESPACE_BEGIN - -// ConsumePrefix() -// -// Strips the `expected` prefix from the start of the given string, returning -// `true` if the strip operation succeeded or false otherwise. -// -// Example: -// + +// ConsumePrefix() +// +// Strips the `expected` prefix from the start of the given string, returning +// `true` if the strip operation succeeded or false otherwise. +// +// Example: +// // y_absl::string_view input("abc"); // EXPECT_TRUE(y_absl::ConsumePrefix(&input, "a")); -// EXPECT_EQ(input, "bc"); +// EXPECT_EQ(input, "bc"); inline bool ConsumePrefix(y_absl::string_view* str, y_absl::string_view expected) { if (!y_absl::StartsWith(*str, expected)) return false; - str->remove_prefix(expected.size()); - return true; -} -// ConsumeSuffix() -// -// Strips the `expected` suffix from the end of the given string, returning -// `true` if the strip operation succeeded or false otherwise. -// -// Example: -// + str->remove_prefix(expected.size()); + return true; +} +// ConsumeSuffix() +// +// Strips the `expected` suffix from the end of the given string, returning +// `true` if the strip operation succeeded or false otherwise. +// +// Example: +// // y_absl::string_view input("abcdef"); // EXPECT_TRUE(y_absl::ConsumeSuffix(&input, "def")); -// EXPECT_EQ(input, "abc"); +// EXPECT_EQ(input, "abc"); inline bool ConsumeSuffix(y_absl::string_view* str, y_absl::string_view expected) { if (!y_absl::EndsWith(*str, expected)) return false; - str->remove_suffix(expected.size()); - return true; -} - -// StripPrefix() -// -// Returns a view into the input string 'str' with the given 'prefix' removed, -// but leaving the original string intact. If the prefix does not match at the -// start of the string, returns the original string instead. + str->remove_suffix(expected.size()); + return true; +} + +// StripPrefix() +// +// Returns a view into the input string 'str' with the given 'prefix' removed, +// but leaving the original string intact. If the prefix does not match at the +// start of the string, returns the original string instead. ABSL_MUST_USE_RESULT inline y_absl::string_view StripPrefix( y_absl::string_view str, y_absl::string_view prefix) { if (y_absl::StartsWith(str, prefix)) str.remove_prefix(prefix.size()); - return str; -} - -// StripSuffix() -// -// Returns a view into the input string 'str' with the given 'suffix' removed, -// but leaving the original string intact. If the suffix does not match at the -// end of the string, returns the original string instead. + return str; +} + +// StripSuffix() +// +// Returns a view into the input string 'str' with the given 'suffix' removed, +// but leaving the original string intact. If the suffix does not match at the +// end of the string, returns the original string instead. ABSL_MUST_USE_RESULT inline y_absl::string_view StripSuffix( y_absl::string_view str, y_absl::string_view suffix) { if (y_absl::EndsWith(str, suffix)) str.remove_suffix(suffix.size()); - return str; -} - + return str; +} + ABSL_NAMESPACE_END } // namespace y_absl - -#endif // ABSL_STRINGS_STRIP_H_ + +#endif // ABSL_STRINGS_STRIP_H_ |