diff options
author | heretic <heretic@yandex-team.ru> | 2022-03-25 12:34:53 +0300 |
---|---|---|
committer | heretic <heretic@yandex-team.ru> | 2022-03-25 12:34:53 +0300 |
commit | a41f3739eed6fceb6f62056a7620d220958a47e7 (patch) | |
tree | 278103258b510cb4a96761ea79d6ccd397ca05a0 /contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h | |
parent | 73d3613a82e5c217fcbe0ab8bbf8120c1ed1af55 (diff) | |
download | ydb-a41f3739eed6fceb6f62056a7620d220958a47e7.tar.gz |
Update grpc to 1.43.2 DTCC-864
ref:50a492c335cda70f458797cf945e49fe739c2715
Diffstat (limited to 'contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h')
-rw-r--r-- | contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h index 0b9752ccff..3de44c8f90 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/slice.h @@ -19,12 +19,13 @@ #ifndef GRPCPP_IMPL_CODEGEN_SLICE_H #define GRPCPP_IMPL_CODEGEN_SLICE_H +// IWYU pragma: private, include <grpcpp/support/slice.h> + +#include <grpc/impl/codegen/slice.h> #include <grpcpp/impl/codegen/config.h> #include <grpcpp/impl/codegen/core_codegen_interface.h> #include <grpcpp/impl/codegen/string_ref.h> -#include <grpc/impl/codegen/slice.h> - namespace grpc { /// A wrapper around \a grpc_slice. @@ -74,6 +75,11 @@ class Slice final { Slice(const Slice& other) : slice_(g_core_codegen_interface->grpc_slice_ref(other.slice_)) {} + /// Move constructor, steals a reference. + Slice(Slice&& other) noexcept : slice_(other.slice_) { + other.slice_ = g_core_codegen_interface->grpc_empty_slice(); + } + /// Assignment, reference count is unchanged. Slice& operator=(Slice other) { std::swap(slice_, other.slice_); @@ -107,6 +113,12 @@ class Slice final { /// Raw pointer to the end (one byte \em past the last element) of the slice. const uint8_t* end() const { return GRPC_SLICE_END_PTR(slice_); } + /// Returns a substring of the `slice` as another slice. + Slice sub(size_t begin, size_t end) const { + return Slice(g_core_codegen_interface->grpc_slice_sub(slice_, begin, end), + STEAL_REF); + } + /// Raw C slice. Caller needs to call grpc_slice_unref when done. grpc_slice c_slice() const { return g_core_codegen_interface->grpc_slice_ref(slice_); |